mirror of
https://git.leinelab.org/Mal/mr-crocs-adventures.git
synced 2025-09-11 02:57:36 +02:00
Gravity and ground height.
This commit is contained in:
@@ -10,6 +10,7 @@ export default class Movable
|
||||
};
|
||||
this.position = new GeometryPoint();
|
||||
this.speed = speed;
|
||||
this.jumpHeight = 35;
|
||||
this.fallSpeed = 0;
|
||||
}
|
||||
|
||||
@@ -39,6 +40,39 @@ export default class Movable
|
||||
return this.animations[this.currentAnimation].getRect();
|
||||
}
|
||||
|
||||
getPositionFootLeft()
|
||||
{
|
||||
return new GeometryPoint(
|
||||
this.position.x - this.animations[this.currentAnimation].getWidth() * 0.5, this.position.y
|
||||
);
|
||||
}
|
||||
|
||||
getPositionFootRight()
|
||||
{
|
||||
return new GeometryPoint(
|
||||
this.position.x + this.animations[this.currentAnimation].getWidth() * 0.5, this.position.y
|
||||
);
|
||||
}
|
||||
|
||||
jump()
|
||||
{
|
||||
this.fallSpeed -= this.jumpHeight;
|
||||
this.isJumping = true;
|
||||
}
|
||||
|
||||
getFootHeight()
|
||||
{
|
||||
return new GeometryPoint(
|
||||
this.position.x,
|
||||
this.position.y + this.animations[this.currentAnimation].getHeight()
|
||||
);
|
||||
}
|
||||
|
||||
setFootHeight(height)
|
||||
{
|
||||
this.position.y = height - this.animations[this.currentAnimation].getHeight();
|
||||
}
|
||||
|
||||
draw(context)
|
||||
{
|
||||
this.animations[this.currentAnimation].setFootPosition(this.position.x, this.position.y);
|
||||
|
||||
Reference in New Issue
Block a user