I’ve been trying to make a movement equation without much luck. I might just be over complicating it, but I’m not sure why it’s not working. On my brother’s computer, it runs much too slow (His computer is wicked fast.). And on mine, it runs just right.
Here’s my movement equation that I’ve got. Any criticism is also welcome.
public void move(int delta){
xCollision = false;
yCollision = false;
pastX = x;
pastY = y;
velocity.y += (G_ACCELERATION * delta)/1000.0;
x += (velocity.x * delta)/1000.0;
collisionBox = new CollisionBox(x, y, sprite.getWidth(),sprite.getHeight());
if(doesCollideOnX()){
x = pastX;
velocity.x = 0.0;
xCollision = true;
}
y += (velocity.y * delta)/1000.0;
collisionBox = new CollisionBox(x, y, sprite.getWidth(),sprite.getHeight());
if(doesCollideOnY()){
y = pastY;
velocity.y = 0.0;
yCollision = true;
}
collisionBox = new CollisionBox(x, y, sprite.getWidth(),sprite.getHeight());
}
If it helps any, the main specs on my computer are 2.1ghz Core 2 duo CPU, 4gb RAM, and 256mb on board video memory.