mr-crocs-adventures/js/MrCroc.js

32 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-01-22 22:50:45 +01:00
import Movable from "./Movable.js";
import RetroAnimation from "./retro/RetroAnimation.js";
import Setting from "./Setting.js";
2020-01-22 22:50:45 +01:00
export default class MrCroc extends Movable
{
constructor() {
2020-02-11 21:20:11 +01:00
const SCALE = 2;
2024-12-21 16:44:58 +01:00
const month = new Date().getMonth();
const animationRight = month === 11 ? 'mr-croc-walk-right-christmas.png' : 'mr-croc-walk-right.png';
const animationLeft = month === 11 ? 'mr-croc-walk-left-christmas.png' : 'mr-croc-walk-left.png';
super(new RetroAnimation(Setting.GRAPHICS_LOCATION + animationRight, 2, SCALE), 7);
2020-01-25 13:11:25 +01:00
this.isJumping = false;
2024-12-21 16:44:58 +01:00
this.addAnimation('WALK_RIGHT', new RetroAnimation(Setting.GRAPHICS_LOCATION + animationRight, 2, SCALE, 10));
this.addAnimation('WALK_LEFT', new RetroAnimation(Setting.GRAPHICS_LOCATION + animationLeft, 2, SCALE, 10));
2020-01-22 22:50:45 +01:00
}
moveRight(timestamp, delta = 1)
{
this.playAnimation('WALK_RIGHT', timestamp);
super.moveRight(delta);
}
moveLeft(timestamp, delta = 1)
{
this.playAnimation('WALK_LEFT', timestamp);
super.moveLeft(delta);
}
2023-09-28 12:04:04 +02:00
}