Jump to content

I won't be needing physics, any way to move the player without it?


SlimTim
 Share

Recommended Posts

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

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 0

var xAcc = 0.5; // Acceleration on X axisvar xVel = 0; // Initial velocity is 0

And in the update loop:

xVel += xAcc;player.x += xVel;
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...