Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Need some info about how the multiplayer works...

Author
Message
Brny
8
Years of Service
User Offline
Joined: 12th Oct 2015
Location:
Posted: 30th Dec 2015 12:48 Edited at: 30th Dec 2015 13:07
Hi, i'm configuring the multiplayer for my game, but i need to know how it works in the deep, in the AppGameKit manuals and guides there's two examples, but to make something more like a game, with bullets, kills, etc. it goes a little bit further than that...

I would like to ask if there's some extensive guide about how the AppGameKit multiplayer works, if a guide of BASIC will work (i'm in tier1) or where i can find some documentation and examples?


I'm very lost with that, so any help will be very helpful...

Thanks
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 30th Dec 2015 14:26 Edited at: 30th Dec 2015 14:27
what kind of game you do?

easy said one app act as host and others can connect as clients.
data transfer via messages. a message is a list of integers,floats,strings.
clients send her input and the server send updates to the clients.
clients do what the server say.
AGK (Steam) V2.0.16 : Windows 10 Pro 64 Bit : AMD (15.30.1025) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Brny
8
Years of Service
User Offline
Joined: 12th Oct 2015
Location:
Posted: 30th Dec 2015 14:52 Edited at: 30th Dec 2015 15:29
Ok, now that i started thinking about what you wrote

I'm doing a 2D shooter

So, the clients send only their information to the server, and then the server sends ALL the information to each client, right?


But, if when you send the data you use the option 0, that's "send to all" you are sending it to everyone not only to the server... that must be configured using the client names or how...?

Thanks


BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 30th Dec 2015 15:27
You should treat the messages like a queue, and process them sequentially. You will get all of the messages, even when one client is faster than the other.
If a message requires a return response then you should give them an identifier that you can send back with the response, so they can be matched.

I wrote a simple tutorial here.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Brny
8
Years of Service
User Offline
Joined: 12th Oct 2015
Location:
Posted: 30th Dec 2015 15:37 Edited at: 30th Dec 2015 15:53
Hallo Vatbink, thank you very much for the tutorial

I try to send 2 messages by the host and receive 2 messages by the client (is a position of a house) only once and it doesent works... maybe because the other is not yet initialised and the messages get lost... i dont know

The identifier is that?

message1 = CreateNetworkMessage()

"message1"?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 30th Dec 2015 15:53
for a message you can give a string or integer as command name / typ with it, then u can use select case and do something with this name/command.
for a 2 player tank game it will work but normal the host collect all input , means all messages each sync and send out updates.
same for client, a client process all messages each sync.
the new player position will be set via interpolation, not direct. similar a move to. this will look better.
see https://en.wikipedia.org/wiki/Linear_interpolation
maybe u can use the tween commands.
the message struct itself stay same but if you have more than 2 players the input packets come in mixed order from clients.
tcp using a output buffer and also a input buffer / stack and each port u can understand as a drinking straw.
a special thing is a broadcast message. its a message from one to all.
see also the using of user defined structs / types.
http://www.appgamekit.com/documentation/principles/1_datatypes.htm


AGK (Steam) V2.0.16 : Windows 10 Pro 64 Bit : AMD (15.30.1025) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Brny
8
Years of Service
User Offline
Joined: 12th Oct 2015
Location:
Posted: 30th Dec 2015 16:02
Yea Markus, there's my concern, if the player 2 loops faster than the player 3, the player one can find in his buffer two consecutive times the player 2 data and think it's managing the player 3 data?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 30th Dec 2015 16:05 Edited at: 30th Dec 2015 16:09
for each message u get a client id with it, so you know from which player it comes.
GetNetworkMessageFromClient( iMsgID )
the long command names are a little bit confusing.

see also
GetNetworkNumClients
GetNetworkFirstClient
GetNetworkNextClient
GetNetworkMyClientID
GetNetworkServerID
AGK (Steam) V2.0.16 : Windows 10 Pro 64 Bit : AMD (15.30.1025) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Brny
8
Years of Service
User Offline
Joined: 12th Oct 2015
Location:
Posted: 30th Dec 2015 16:41 Edited at: 30th Dec 2015 16:41
Ok... so i must use that command... ok, what i was thinking....

I dont know yet how to use it since it says it doesent work for messages created using CreateNetworkMessage. ¿?

I use createnetworkmessage, i add all the data and then i use sendnetworkmessage...

I didnt know those commands, thanks!
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 30th Dec 2015 16:51 Edited at: 30th Dec 2015 16:52
Print(...) & Log(...) & Debug Mode + Breakpoints are your Friends
AGK (Steam) V2.0.16 : Windows 10 Pro 64 Bit : AMD (15.30.1025) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)

Login to post a reply

Server time is: 2024-09-29 09:19:58
Your offset time is: 2024-09-29 09:19:58