diff --git a/js/Gisela.js b/js/Gisela.js index a5ccec1..b91b7f4 100644 --- a/js/Gisela.js +++ b/js/Gisela.js @@ -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) + ); } } \ No newline at end of file diff --git a/js/module.js b/js/module.js index 3155ef1..c1942e8 100644 --- a/js/module.js +++ b/js/module.js @@ -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();