diff options
author | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2024-12-24 17:58:20 +0100 |
---|---|---|
committer | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2024-12-24 17:58:20 +0100 |
commit | 25adfc618e77db9a5ee3b98ce0dab0be832efed0 (patch) | |
tree | 36ca56758ddd4674ab5a43df4b76bbfcc5a47af1 /src/entities/game_over.js | |
parent | a840990bdcabf45fb0d377478ba0ab27222434ae (diff) |
hello kitty base done
Diffstat (limited to 'src/entities/game_over.js')
-rw-r--r-- | src/entities/game_over.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/entities/game_over.js b/src/entities/game_over.js new file mode 100644 index 0000000..fc35938 --- /dev/null +++ b/src/entities/game_over.js @@ -0,0 +1,60 @@ +import { Vector } from "../engine/vector.js" +import { Entity } from "./entity.js" +import { GAME_OVER } from "../assets.js" + +export class GameOver extends Entity { + fadeWaitTime = 40 + opacity = 0 + stage = 0 + + zoomDelay = 7 + zoomWaitTime = this.zoomDelay + zoomGrowth = 10 + zoomedIn = false + initialSize = 400 + maxSize = 550 + + constructor() { + super({ + size: new Vector(400, 400), + position: new Vector(325, 250), + sprite: GAME_OVER, + pixelated: true, + }) + + this.span.style.zIndex = 5 + this.span.style.opacity = 0 + } + + update() { + if (this.stage == 0) this.fadeIn() + this.zoomAnimation() + } + + fadeIn() { + if (this.fadeWaitTime > 0) { this.fadeWaitTime--; return; } + if (this.opacity < 1) { + this.opacity += 0.05 + this.span.style.opacity = this.opacity + return + } + this.stage = 1 + } + + zoomAnimation() { + if (this.zoomWaitTime > 0) { this.zoomWaitTime--; return; } + console.log("hi") + if (this.zoomedIn) this.size.add(new Vector(-this.zoomGrowth, -this.zoomGrowth)) + else this.size.add(new Vector(this.zoomGrowth, this.zoomGrowth)) + console.log(this.size) + if ( + this.size.x == this.initialSize || + this.size.x == this.maxSize + ) { + this.zoomedIn = !this.zoomedIn + this.zoomWaitTime = this.zoomDelay + } + + } +} + |