I would like to build a multi-player game with rotation and speed. I use the tutorial code and have problems with the synchronization of the movement. I replaced the code as follows:
- Code: Select all
if(players[player].keyUp){
// Calculate speed and trajectory based on rotation
players[player].speedX += players[player].thrust*Math.sin(players[player].rotation*(Math.PI/180));
players[player].speedY += players[player].thrust*Math.cos(players[player].rotation*(Math.PI/180));
//players[player].y -= diff/5
}
if(players[player].keyDown){
players[player].speedX *= players[player].decay;
players[player].speedY *= players[player].decay;
//players[player].y += diff/5
}
if(players[player].keyRight){
players[player].rotation += players[player].rotationSpeed;
//players[player].x += diff/5
}
if(players[player].keyLeft){
players[player].rotation -= players[player].rotationSpeed;
//players[player].x -= diff/5
}
players[player].y -= players[player].speedY;
players[player].x += players[player].speedX;
Now he synchronized not in polar coordinates, so I have to change the .dll file and change the delay in the .fla file. Unfortunately I have currently no idea how I could do it.
Best regards,
Grandement.