5

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.

android_eng
  • 1,370
  • 3
  • 17
  • 40

2 Answers2

6

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 ^^

dnlrmrez
  • 61
  • 4
2

I finally got the solution and made the Android application. Simply used java socket programming. It works on Hotspot. This works on client - server framework. Please find the code here and contact me if you require any assistance.

https://github.com/rohitramkumar308/GameOfCards

and this is the link to the app

https://play.google.com/store/apps/details?id=srk.syracuse.gameofcards

Hope this helps you.

android_eng
  • 1,370
  • 3
  • 17
  • 40