diff options
author | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2024-12-26 14:24:53 +0100 |
---|---|---|
committer | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2024-12-26 14:24:53 +0100 |
commit | 474a7253b6b67e2ed33936f6b633587d5d304b66 (patch) | |
tree | 456b9cef3cb59da8e0eb575b9425a1fedfe67e1e /src/entities/bigdump.js | |
parent | 1fc522bc8c4a96858223e597ced8fea94ba57874 (diff) |
hello kitty stage 1 and 2 done
Diffstat (limited to 'src/entities/bigdump.js')
-rw-r--r-- | src/entities/bigdump.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/entities/bigdump.js b/src/entities/bigdump.js new file mode 100644 index 0000000..90b4a57 --- /dev/null +++ b/src/entities/bigdump.js @@ -0,0 +1,40 @@ +import { ANTICHEESE } from "../assets.js" +import { Vector } from "../engine/vector.js" +import { Engine } from "../engine.js" +import { Entity } from "./entity.js" +import { boshy } from "../main.js" + +export class BigDump extends Entity { + constructor(bottom = false) { + let position = bottom ? + new Vector(0, boshy.position.y) : + new Vector(boshy.position.x, 0) + + super({ + size: new Vector(200, 10), + position: position, + sprite: ANTICHEESE, + degrees: bottom ? 270 : 0, + }) + + this.bottom = bottom + } + + speed = 10 + maxSize = 200 + + update() { + if (this.size.y < this.maxSize) this.size.y += this.speed * 0.75 + if (this.bottom) this.position.x += this.speed + else this.position.y += this.speed + + console.log("dump", this.position) + + if (Engine.collision.collidingWithBoshy(this.position, this.hitbox)) { + boshy.die() + } + if (Engine.screen.isOffLimits(this.position, this.size)) { + this.remove() + } + } +} |