O
ookki
Guest
Lately I've been dabbling a bit in multiplayer coding and now I've come to a point where I'd like to have some help.
The basic idea is that I generate a random map of 1024x1024 destroyable tiles. Now what I'm wondering is how to transfer this map to the players. The option that makes most sense to me would be sending the whole map at first (or actually just the graphics info of the tilemap) and then send every player an update if and when a tile is destroyed or created. Main problem with this is that I don't know how many tiles I can send in one step. I've understood that you should keep the amount of packets you send per step quite low. This would of course stop the game for a while every time a new player connects. But given the type of a game I'm doing that shouldn't be a huge problem. The concept I'm having in mind at the moment is something like:
The other method to tackle this problem that I've thought of is to send first just the tiles of the players view and then send more tiles every time the player moves. That would mean I wouldn't have to worry about how to send a big chunk of data, but it seems unnecessary to scramble through so much map data all the time, be writing into the clients tilemap all the time and in the end send more data every loop unless the players don't move at all.
The basic idea is that I generate a random map of 1024x1024 destroyable tiles. Now what I'm wondering is how to transfer this map to the players. The option that makes most sense to me would be sending the whole map at first (or actually just the graphics info of the tilemap) and then send every player an update if and when a tile is destroyed or created. Main problem with this is that I don't know how many tiles I can send in one step. I've understood that you should keep the amount of packets you send per step quite low. This would of course stop the game for a while every time a new player connects. But given the type of a game I'm doing that shouldn't be a huge problem. The concept I'm having in mind at the moment is something like:
Code:
-a player connects to the server --> set server state to UPLOAD
-while state is UPLOAD send packets to the client until the client has the whole map, then set server state to PLAY
-while state is PLAY, do regular stuff: movement, collision, etc. and update those to the clients