Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Understanding network code


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Anddos   Members   -  Reputation: 519

Like
0Likes
Like

Posted 22 May 2014 - 06:30 PM

I am trying to understand how a server communicates properly with the clients

 

Player1 Moves which means his new position needs to be updated on the server

Player2 Moves which means his new position needs to be updated on the server

Player1 screen needs to see the updated position of Player 2

Player2 screen needs to see the updated positon of player 1

 

My question is how do you make the server only send the clients that need updating and not its self,this is going to be become more trickyer with more clients so i am unsure how to implement updating of the clients screen correctly,what i mean is like

 

5 Players on the server

Player1 Moves

Player2 to 5 needs to see Player1 updated position

Player3 Moves

Player1,2,4,5 needs to see Players3 updated position

 

see what i am getting at?

 

 


:)

Sponsor:

#2 Nikopol_AU   Members   -  Reputation: 468

Like
0Likes
Like

Posted 22 May 2014 - 06:59 PM

Basic idea:

 

Player 1 moves, and sends its own updated position to server.

Server sends Player 1's updated position to Players 2,3,4 and 5.

 

And then there is a whole world of magic like

"lag compensation", "cheating prevention", "bandwidth management", "dynamic game entry/leave", etc...


Edited by Nikopol_AU, 22 May 2014 - 07:02 PM.


#3 hplus0603   Moderators   -  Reputation: 5723

Like
0Likes
Like

Posted 23 May 2014 - 10:58 AM

The typical way this is solved:

 

1) Set a fixed send rate -- say, 10 times a second, or 20 times a second

2) Each time the send time comes up, iterate through all the players

3) For each player, get the data they need to receive, and send it in one packet

 

Note that, on a bigger map, you may not want to send all the data for all the players; you may want to do interest management and only send data about players that can be seen, for example.


enum Bool { True, False, FileNotFound };




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS