Synchronizing players

Started by
2 comments, last by executor 24 years ago
I have problems synchronizing two players with DirectPlay. The problem is that one computer is faster than the other and it''s units are moving faster. The efect is that two units (one from each player) that should be moving at the same speed are moving at different speeds. One computer has 40 fps and the other has 20 fps. With each frame the unit is moved two pixels. This way the two units are moving at different speeds. How do I make them move at the same speed? (It''s a RTS game with peer-to-peer DirectPlay multiplayer)
Advertisement
I can think of two solutions. The first (but not the best) is to limit the framerate to the lowest system. What you might want to do instead is limit your framerate to something high, say 60 fps. At each frame you need to determine how much time has passed since the last frame and then move units accordingly. If some units are moving at 1 pixel/frame at 40fps then you might have to create more detailed position information based on some unit rather than pixels, like 4 units = 1 pixel. Tell me how it works out, I’m looking at creating a multiplayer RTS this summer and would be interested to know what other issues come up.
Seperate the update of the units from the frame rate. Synchronize both clients to a timmer, and use that timmer inforamtion + data to extrapalate position of units. That''s the way i do it. Good luck.

-ddn
I''ve seen a lot of games (Yes commercial ones) use time for unit posititioning rather than frams. So the rendering of the screen is a totally different part of the program than the updating of the units. So the frame rate doesn''t matter. So when you update your units you calculate the time it''s been between the last update and now and then use your speed (30 pixels per second or something) and calculate the distance to move it.
Try looking at Microsofts Age of Empires. It works like this. We networked a game from a P133 w/out MMX w/ a 2Mb generic graphics card to a PIII 533Mhz w/ a Voodoo 3 3000 and 128MB of ram. The frame rates were like 12-15fps vs. 60fps. But you could see the unit moving further an the slower computer per frame. The graphics just look a bit choppy on old systems.
Hope that helps!
- Ben

P.S. According to a recent thread on Task and Thread prioities in windows. Many of these games we talk about hav multiple threads running. Maybe they''ve got a thread syncing and moving all the units and thread that paints everything?
__________________________Mencken's Law:"For every human problem, there is a neat, simple solution; and it's always wrong."
"Computers in the future may weigh no more than 1.5 tons."- Popular Mechanics, forecasting the relentless march of science in 1949

This topic is closed to new replies.

Advertisement