Gisela faces MrCroc automatically.

This commit is contained in:
Mal 2020-02-24 21:18:45 +01:00
parent 479a150f9d
commit 43f2290758
2 changed files with 16 additions and 1 deletions

View File

@ -6,6 +6,14 @@ export default class Gisela extends Movable
{
constructor() {
const SCALE = 2;
super(new RetroAnimation(Setting.GRAPHICS_LOCATION + 'gisela-right.png', 1, SCALE, 1));
super(new RetroAnimation(Setting.GRAPHICS_LOCATION + 'gisela-right.png', 1, SCALE, 0.01));
this.addAnimation(
'LOOK_LEFT',
new RetroAnimation(Setting.GRAPHICS_LOCATION + 'gisela-left.png', 1, SCALE, 0.01)
);
this.addAnimation(
'LOOK_RIGHT',
new RetroAnimation(Setting.GRAPHICS_LOCATION + 'gisela-right.png', 1, SCALE, 0.01)
);
}
}

View File

@ -103,6 +103,12 @@ function MainLoop(timestamp)
/* Drawing */
if (timestamp - lastRendered >= frameDuration) {
if (gisela.currentAnimation !== 'LOOK_LEFT' && mrCroc.position.x < gisela.position.x) {
gisela.currentAnimation = 'LOOK_LEFT';
} else if (gisela.currentAnimation !== 'LOOK_RIGHT' && mrCroc.position.x >= gisela.position.x) {
gisela.currentAnimation = 'LOOK_RIGHT';
}
context.clearRect(0, 0, window.innerWidth, window.innerHeight);
architecture.draw(context, camera);
mrCroc.draw(context, camera);
@ -171,6 +177,7 @@ loader.addImage(Setting.GRAPHICS_LOCATION + 'mr-croc-walk-right.png');
loader.addImage(Setting.GRAPHICS_LOCATION + 'mr-croc-walk-left.png');
loader.addImage(Setting.TILESET_LOCATION + GraphicSet[level.getTilesetId()].tileset);
loader.addImage(Setting.GRAPHICS_LOCATION + 'gisela-right.png');
loader.addImage(Setting.GRAPHICS_LOCATION + 'gisela-left.png');
new FrameRateMeasurer();