Logo Questions Linux Laravel Mysql Ubuntu Git Menu

Multiplayer game on local network without internet

I am creating a multiplayer android game as a part of my coursework. This is my first game. I intended to allow users to connect to the game over a simple network. I don't want to use internet at all hence I wont be using the android game services. How do I go about this. I have no clue at all. I have tried various tutorials but all of them are using a central game server. I just want to create a simple Client - Server network. One user will host a game and others will join.

like image 991
android_eng Avatar asked Mar 16 '23 14:03


1 Answers

it's my first time answering a question here. I usually just read here in stackoverflow. I'm also currently working on my first game. It connects devices using wifi peer-to-peer or WifiDirect (without a wifi hotspot). It requires high version of android OS (4.0 or 4.1?) but I believe you can also try the other way on which the devices needs to connect in the same wifi hotspot for lower OS version requirements. The latter, I haven't tried yet.

After I connect the devices on the same network (peer-to-peer), I use sockets to exchange data between them. I use serializable objects for sending data. I don't know if it's the best way but it works for me.

My game can connect more than two players in wifi peer-to-peer. One device acts as the network owner (and also the game server).

See android's tutorial/documentation for WifiDirect connection : http://developer.android.com/training/connect-devices-wirelessly/wifi-direct.html Be sure to read also the adjacent lessons.

Also, Sockets must be used with Threads so you also need to read about it if haven't.

Hope I helped ^^

like image 148
dnlrmrez Avatar answered Mar 31 '23 20:03