Android Question Question Game Online Real-Time

Douglas Farias

Expert
Licensed User
Longtime User
Good Morning :)

I have a question about games and basic4android.
I need ideias!!!

what i need know, or study to make one online game in real time?

i m making this game
http://www.b4x.com/android/forum/threads/my-first-game-in-progress.42811/

i have one VPS with fixed IP
but i never see this or work on this, my game is based on tile, tile game.

what i need study to make a online server to this game, for all users conect in 1 world.

- All players in 1 world online
- 10 + Maps

i m already make the register and login via mysql and php, i m making the inventory based on user db
itens, coins etc.

if someone know about this help me pls.

if u have ideia how to make, sample or links send my pls
i dont know where i begin xD

TXH TO ALL.:)
 

KMatle

Expert
Licensed User
Longtime User
Youe have a register/login ready. So you need to know (we can't know that) how your game works (storyline). As you've said, you know how to use php and MySql, so what's the problem exactly?

I have a hosted (shared) server for about $8 a month with some databases. Here I can use 5 DB's with 2 GB each.

If you bring your app to the market be carefull to limit the users getting online at the same time or you will need to rent a lot of hardware :cool:
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
yes !
but i want to add massive multiplayer online
for exemplo you log on and i see u on the game

players conected = 50 for example
chat in game etc

i have a vps to run this but i dont realy know what i need to start, on the internet i found many abou UDP connection
but have a another way to make this with my vps , i dont want use google services.

-open the app
-register or login
-select the character
-and go to world

a real time game, if u is on the world and see your friend u can talk hi *-*
i need to know how i start this *-*
what i need to study to make this
and if is possible make this on b4a
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
You mean a chat function? Easy. Coming near to a "friend" in your game you can let the player chose some actions like "talk to xxx". Open a new panel with that functions to chose from.

To have a chat you have two functions: Talk and listen.

To talk let the player type in a message. Call your php script and store it in a table (message, from, to, ...).

To listen start a timer which calls your script every x seconds to see if a message is there (same table).
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
good ideia, but hard is place the hero on the map

my hero

and my friend hero

if he is moving i can see
etc
 
Upvote 0

WAZUMBi

Well-Known Member
Licensed User
Longtime User
but i want to add massive multiplayer online
for exemplo you log on and i see u on the game

players conected = 50 for example
chat in game etc

I would recommend paying for a dedicated server, ip address, and SSL for this.
It will cost you but you will have problems with this on any shared or hosted server package guaranteed.
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
yes i have xD

now i need to know how to start.

i know make maps on game tile
i know make login and register android-mysql
i know put sounds etc etc

but i dont know how to make this on real time online.
for exemplo i m in the game and you enter in the game
same map etc and i see u, i talk hi and u talk hi *-* < real time

i want to know how to start this *-*
i can make with queries but it go is very slow
i need to make when client - server

this server can run o my dedicated server, a .exe file with conection
but i dotn have ideia how to make this *-*
 
Upvote 0

WAZUMBi

Well-Known Member
Licensed User
Longtime User
I can give you a basic idea with my Multiplayer Fingerboard game.

I assume you have a database with a table containing your user data.

When a player logs in I set a boolean flag to 'online' for example.
Now your game queries your server at a set interval (every 5 seconds in my case) to see who's online and returns their status.
I suppose in your game you need to know each players real time map coordinates, name, health, score, etc... from another table storing this information.

Also you need to know when a player logs out or quits without properly logging out.
In my game each time a players device queries the server I make a timestamp. If they have not queried within the last 10 seconds then they are considered offline.

Just some ides. My game is a very basic turned based game.
Your welcome to download the apk directly and check out the code:
http://www.appzumbi.com/developers/wazumbi/app_106/fingerboardOrDie.apk

It's not commented and I'm not sure if this is the most efficient approach but maybe it will help.:)
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
yes i have this ideia too but the problem is the user movimentation
need conect with 1s -

i cant run many querys , many times to set all users position
for exemple

you is on tile 59 i m on tile 70

if you move to 60 i see on my screnn < it need made fast
1 s - i think only with a connector java or i realy idk

is the same ideia of the pc games mmorpg
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
My girlfriend's daughter has a nintendo DS. In a game it's the same situation. The player meets another character and then the game holds for some interaction.

To cast the position of the player httputils2 should do because it works asynchronus.

With a little intelligence in your code it will work for you. F.e. store the position only when there's no movement for x time.
 
Upvote 0

MaFu

Well-Known Member
Licensed User
Longtime User
With a little intelligence in your code it will work for you. F.e. store the position only when there's no movement for x time.
Bit if i run continuously no one can follow in this case.
The position should stored on stop and after a certain amount of steps.

As i said before: i would use WebSockets and keep the data as small as possible.
Transfer only the changed data and use the smallest needed data type.
Example:
If 65535 different positions fair enough for the map then use a word (2 bytes) instead of integer for x and y.
One byte for id (= type of sending data, e.g. position coordinates), four bytes for x/y and an additionally byte for checksum is only six bytes for player position to send.
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
@MaFu
but i need save the position of the players on db?

and about the map i need load this on the server or app?

for example what happens when u move the hero tile 1x to 2x . what data i send
ok i send user id + next tile 2x in this case, but what hapens now? i have the hero position data i need send this to all conected users?
 
Upvote 0

MaFu

Well-Known Member
Licensed User
Longtime User
Sure, the server should must save the data from all players.

You can embed the maps in the app or load from server. Both has pros and cons.

If you use WebSockets it's no need to send the player id. The server knows the player because each client connection has its corresponding server thread. Then the server should check all player positions and push your position to all players in your visibility range. Sending the position to a player on the other side of the map doesn't make sense (imho).
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
*-* i go try begin on this on this night thx for u suport man.
u have a online game ?
 
Upvote 0

MaFu

Well-Known Member
Licensed User
Longtime User
*-* i go try begin on this on this night thx for u suport man.
u have a online game ?
No, but experience with IPC. And it's not a big difference between games and other program types, the (abstract) base logic are almost the same.
 
Upvote 0
Top