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)
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.
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?