Sign in to follow this  

packets frame

Recommended Posts

Hello gamers, I am starting on developing y first simple p2p game. I am using the SDL_net library. I am trying to develope a 2D game where each player (a pad) shoots at the other person. It is very simple game. Now my question is, how often should I send the information to the other side? is it at the rate of 10 msec? Also I a thinking that the only info I need to transmit is the player position and the bullet position... am I missing anything else? Please let me know of you think and any help is appreciated. Thanks alot PS: I am using TCP as using UDP in sdl_net sux big time ( Never relly understood it, if u recoomend a tutorial (otehr than the offical one) then tha will be great). Cheers!

Share this post

Link to post
Share on other sites
I've found that sending 10 or so position updates per second is usually sufficient, especialy with good prediction in place. In terms of actual messages that need to be sent, there are a few that I can think of off the top of my head:
Player position
Player fired a bullet
Player hit another player/got hit
Player scored a point
Player sent a chat message

Of course, things like chat messages depend on your game and if you support chat in the first place.

For p2p, you'll need to make some decisions about how collisions are handled. Since the game is being played over a network, if you have lag issues, one player may think they hit another player when that other player disagrees. In that case, since there is no natural central authority, you need to decide who to trust, the person who thinks they hit someone else or the person who thinks they did/did not get hit.

Also, as long as your physics is deterministic, you don't need to send bullet position every update, just a single message indicating when, where, and at what it was fired.

I'm not too familiar with SDL_net, but for this type of game I would encourage the use of UDP, especialy if SDL_net supplies its own reliability layer.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this