ShadowEnforcer Posted March 26, 2016 Share Posted March 26, 2016 Hello, I have a little problem with the code from my own browsergame. The browsergame is for the moment a client in combination with a server where you start with an ship and fly through an huge map. The player clicks on a point on the map and fly with the ship to this point. When the player draggs the mouse, while he is clicking on this point, the player is flying further and further. When he moves the mouse, the ship would be reinserted into the canvas element und moves to the exactly point. My problem is now, that I register an mousemove event, everytime the player draggs the mouse while clicking on this point, but the player is to fast each more often he's moving the mouse. When he only click on this point, the player moves with the correct speed. Here is the code for the movement. mousemove++; velX = (tx1 / dist1) * speed; velY = (ty1 / dist1) * speed; velX = velX/1.6; velY = velY/1.6; posX1 += velX; posY1 += velY; backgroundX -= velX; backgroundY -= velY; backgroundX1 -= velX*background_factor; backgroundY1 -= velY*background_factor; var playerX1 = 960-backgroundX1; var playerY1 = 461-backgroundY1; playerX = playerX1; playerY = playerY1; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.