Terrain collision.

This commit is contained in:
Mal
2020-01-25 23:30:36 +01:00
parent 0cd532f45a
commit b7f669224d
3 changed files with 146 additions and 44 deletions

View File

@@ -40,6 +40,16 @@ export default class Movable
return this.animations[this.currentAnimation].getRect();
}
getWidth()
{
return this.getRect().width;
}
getHeight()
{
return this.getRect().height;
}
getPositionFootLeft()
{
return new GeometryPoint(
@@ -50,7 +60,23 @@ export default class Movable
getPositionFootRight()
{
return new GeometryPoint(
this.position.x + this.animations[this.currentAnimation].getWidth() * 0.5, this.position.y
this.position.x + this.getWidth() * 0.5, this.position.y
);
}
getPositionHeadLeft()
{
return new GeometryPoint(
this.position.x - this.animations[this.currentAnimation].getWidth() * 0.5,
this.position.y - this.animations[this.currentAnimation].getHeight()
);
}
getPositionHeadRight()
{
return new GeometryPoint(
this.position.x + this.getWidth() * 0.5,
this.position.y - this.animations[this.currentAnimation].getHeight()
);
}