Monday, April 13, 2015

SDL_net networking and multiplayer test

This video shows a "Soldat meets Quake 2 arena" multiplayer prototype I basically made already in January. It took some time to get motivated to fix bugs, add some features and make it look decent.

The first part of the video shows networking based on SDL_net tutorial by thecplusplusguy. It uses TCP to send data between server and clients. The data is just plain text. I'm not saying all this works and is how it should be done, this is just to show what I've been working on, to do some testing and get some feedback.

As for other players in the video, those are not people playing with me. They are just "bots" who read my stored input commands and send them to server to move each other.

Only thing that I try to keep in sync is the player. The client sends input commands to the server, server updates the game world and players, and sends the player states and the input commands back to to the clients.
For example, player fires a bullet on the client after he gets his own state and commands back from the server. The bullet on the client and server have nothing to do with each other, they exist in their own Box2D world, but only the collision with the players on the server counts:
- It can happen that the bullet goes trough the player on the client if the server kills him before the local collision is detected.
- Also ragdolls are not in sync, because they don't get velocity and rotation values from server.
- Explosion force and gibbing are disabled on multiplayer.

The second half of the video(1:30) shows an offline bot match. As said above there is no real AI, just stored commands that they read. It doesn't really work, but is good enough for testing and to have some fun.

I only managed to make multiplayer work using local IP of computers connected to my wireless router. When I host a server and try to connect using its public IP address, it fails. I did port forwarding on my router, but it didn't help. I don't know if the problem is with my code, or router and firewall settings. I newer hosted a multiplayer server, so it would be great if someone more experienced would try to test it out.
I downloaded a game called Teeworld to test their server. Sometimes I can connect, sometimes I don't, so I assume it's because of my router or firewall. 

 Either way, any feedback is welcome. Even letting me know if it started successfully(or not) would be something.

MD5: A2DFC602CA5C1E3A46D1D9DD85B06ED3 
Missing READ ME

SDL_net tutorials by thecplusplusguy:

Original map design by HardcoreMazu: 

Disclaimer: I don't own any of the textures and sounds used to make this demo. I advise you not to download if you don't own a legal copy of Quake 2 by id Software.

No comments:

Post a Comment