SlimTim Posted April 2, 2014 Share Posted April 2, 2014 I realized that I need to set the velocity of the player in order to move, but that requires adding physics to the player which is pointless since no physics is used in the game. Is there a way to emulate velocity without adding physics? Link to comment Share on other sites More sharing options...
ram64 Posted April 2, 2014 Share Posted April 2, 2014 Maybe add in the update loop something like:var xVel = 5; // Velocity on the X directionplayer.x += xVel; Or if you want to have acceleration also: Define the acceleration and set the velocity to 0var xAcc = 0.5; // Acceleration on X axisvar xVel = 0; // Initial velocity is 0And in the update loop:xVel += xAcc;player.x += xVel; Link to comment Share on other sites More sharing options...
valueerror Posted April 2, 2014 Share Posted April 2, 2014 player.x += 20; will move it 20px aproximate 60 times a second.. so 120px in one second.. to move left you type player.x -= 20; i didn't test it but i think it should work as expected... Link to comment Share on other sites More sharing options...
SlimTim Posted April 2, 2014 Author Share Posted April 2, 2014 Made it work, thanks. Link to comment Share on other sites More sharing options...
Recommended Posts