diff --git a/graphics/giesela-left-sleeping.png b/graphics/giesela-left-sleeping.png new file mode 100644 index 0000000..733b1da Binary files /dev/null and b/graphics/giesela-left-sleeping.png differ diff --git a/graphics/giesela-right-sleeping.png b/graphics/giesela-right-sleeping.png new file mode 100644 index 0000000..957a82b Binary files /dev/null and b/graphics/giesela-right-sleeping.png differ diff --git a/js/Game.js b/js/Game.js index d6bc28d..578f9bf 100644 --- a/js/Game.js +++ b/js/Game.js @@ -51,10 +51,20 @@ export class Game return; } - if (this.gisela.currentAnimation !== 'LOOK_LEFT' && this.mrCroc.position.x < this.gisela.position.x) { - this.gisela.currentAnimation = 'LOOK_LEFT'; - } else if (this.gisela.currentAnimation !== 'LOOK_RIGHT' && this.mrCroc.position.x >= this.gisela.position.x) { - this.gisela.currentAnimation = 'LOOK_RIGHT'; + /* + if (this.gisela.currentAnimation !== 'SLEEP_LEFT' && this.mrCroc.position.x < this.gisela.position.x) { + this.gisela.currentAnimation = 'SLEEP_LEFT'; + } else if (this.gisela.currentAnimation !== 'SLEEP_RIGHT' && this.mrCroc.position.x >= this.gisela.position.x) { + this.gisela.currentAnimation = 'SLEEP_RIGHT'; + } + */ + + if (!this.gameFinished) { + if (this.mrCroc.position.x < this.gisela.position.x) { + this.gisela.playAnimation('SLEEP_LEFT', timestamp); + } else { + this.gisela.playAnimation('SLEEP_RIGHT', timestamp); + } } this.context.clearRect(0, 0, window.innerWidth, window.innerHeight); @@ -164,6 +174,12 @@ export class Game finish() { + if (this.mrCroc.position.x < this.gisela.position.x) { + this.gisela.currentAnimation = 'LOOK_LEFT'; + } else { + this.gisela.currentAnimation = 'LOOK_RIGHT'; + } + this.gameFinished = true; this.KeyLeft.pressed = false; this.KeyRight.pressed = false; diff --git a/js/Gisela.js b/js/Gisela.js index b91b7f4..3dbb08b 100644 --- a/js/Gisela.js +++ b/js/Gisela.js @@ -15,5 +15,13 @@ export default class Gisela extends Movable 'LOOK_RIGHT', new RetroAnimation(Setting.GRAPHICS_LOCATION + 'gisela-right.png', 1, SCALE, 0.01) ); + this.addAnimation( + 'SLEEP_LEFT', + new RetroAnimation(Setting.GRAPHICS_LOCATION + 'giesela-left-sleeping.png', 4, SCALE, 4) + ); + this.addAnimation( + 'SLEEP_RIGHT', + new RetroAnimation(Setting.GRAPHICS_LOCATION + 'giesela-right-sleeping.png', 4, SCALE, 4) + ); } -} \ No newline at end of file +} diff --git a/js/module.js b/js/module.js index fd867a5..7326f08 100644 --- a/js/module.js +++ b/js/module.js @@ -58,6 +58,8 @@ function loadLevel(level) loader.addImage(Setting.GRAPHICS_LOCATION + 'gisela-right.png'); loader.addImage(Setting.GRAPHICS_LOCATION + 'gisela-left.png'); loader.addImage(Setting.GRAPHICS_LOCATION + 'gisela-left.png'); + loader.addImage(Setting.GRAPHICS_LOCATION + 'giesela-left-sleeping.png'); + loader.addImage(Setting.GRAPHICS_LOCATION + 'giesela-right-sleeping.png'); for (const graphicSet of GraphicSet) { loader.addImage(Setting.TILESET_LOCATION + graphicSet.tileset);