61 lines
1.6 KiB
JavaScript
61 lines
1.6 KiB
JavaScript
import Movable from "./Movable.js";
|
|
import RetroAnimation from "./retro/RetroAnimation.js";
|
|
import Setting from "./Setting.js";
|
|
|
|
export default class MrCroc extends Movable
|
|
{
|
|
constructor() {
|
|
const SCALE = 2;
|
|
super(new RetroAnimation(Setting.GRAPHICS_LOCATION + 'mr-croc-walk-right.png', 2, SCALE), 7);
|
|
this.isJumping = false;
|
|
this.addAnimation('WALK_RIGHT', new RetroAnimation(Setting.GRAPHICS_LOCATION + 'mr-croc-walk-right.png', 2, SCALE, 10));
|
|
this.addAnimation('WALK_LEFT', new RetroAnimation(Setting.GRAPHICS_LOCATION + 'mr-croc-walk-left.png', 2, SCALE, 10));
|
|
}
|
|
|
|
moveRight(timestamp, delta = 1)
|
|
{
|
|
this.playAnimation('WALK_RIGHT', timestamp);
|
|
super.moveRight(delta);
|
|
}
|
|
|
|
moveLeft(timestamp, delta = 1)
|
|
{
|
|
this.playAnimation('WALK_LEFT', timestamp);
|
|
super.moveLeft(delta);
|
|
}
|
|
|
|
getPositionFootLeft() {
|
|
const position = super.getPositionFootLeft();
|
|
position.x += 10;
|
|
|
|
return position;
|
|
}
|
|
|
|
getPositionFootRight() {
|
|
const position = super.getPositionFootRight();
|
|
position.x -= 10;
|
|
|
|
return position;
|
|
}
|
|
|
|
getPositionHeadLeft() {
|
|
const position = super.getPositionHeadLeft();
|
|
|
|
if (this.currentAnimation === 'WALK_RIGHT') {
|
|
position.x += 10;
|
|
}
|
|
|
|
return position;
|
|
}
|
|
|
|
getPositionHeadRight() {
|
|
const position = super.getPositionHeadRight();
|
|
|
|
if (this.currentAnimation === 'WALK_LEFT') {
|
|
position.x += 10;
|
|
}
|
|
|
|
return position;
|
|
}
|
|
}
|