Hi all! I'm trying to make a game that works on LAN - and it uses the DirectPlay object. I use DirectPlay because it does not need Internet and I can test it.
This will be a platformer for 2 players max - I got to the part when they connect to each other. At the moment the connection is made the first level is fired. Movements are correct for both players (though the OTHER player (the one received by the computer) has a bit of a fizzing on the Y axis (I mean it goes up/down 1 pixel fast) and there is no lag. Than I wanted to insert shots.
They work fine too, but are laggy, even though they don't affect movement. Sometimes the lag is awful large, taking seconds! How can you reduce this lag (for TCP/IP connection)?
Here's what I tried (I leave out the stuff needed for the standard platform engine):
Is message waiting? -- Produce a message
GROUP SEND MOVEMENT
Always -- Send X, Y, Dir, Speed, Anim# from Player 1
On Receive X, Y, Dir, Speed, Anim# -- /apply values to player 2 object, everything normally except at Y values which are received Y - 13; otherwise the position is incorrect/
GROUP SEND MOVEMENT OVER
Player 1 is facing direction (right)
Upon pressing Space Bar -- Deactivate Group SEND MOVEMENT ; (player 1)Shoot bullet at (right), speed 100 ; Send Single Value 1 ; Activate Group SEND MOVEMENT
Player 1 is facing direction (left)
Upon pressing Space Bar -- Deactivate Group SEND MOVEMENT ; (player 1)Shoot bullet at (left), speed 100 ; Send Single Value 2 ; Activate Group SEND MOVEMENT
Received Single Value 1 -- (player 2) Shoot bullet at (right), speed 100
Received Single Value 2 -- (player 2) Shoot bullet at (left), speed 100
That's all - please help!!!
I make other people create vaporware
There shouldn't be too much lag even if your coding isn't too snappy. But try removing the 'always' from
On Receive X, Y, Dir, Speed, Anim# -- /apply values to player 2 object, everything normally except at Y values which are received Y - 13; otherwise the position is incorrect.
If you are still lagging bad check your router connections. If there is still lag then you will probabley need to code some sort of dead reckoning system.
Creator of Faerie Solitaire:
Also creator of ZDay20 and Dungeon Dash.