summaryrefslogtreecommitdiff
path: root/src/entities/portal.js
diff options
context:
space:
mode:
authorniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2024-12-24 17:58:20 +0100
committerniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2024-12-24 17:58:20 +0100
commit25adfc618e77db9a5ee3b98ce0dab0be832efed0 (patch)
tree36ca56758ddd4674ab5a43df4b76bbfcc5a47af1 /src/entities/portal.js
parenta840990bdcabf45fb0d377478ba0ab27222434ae (diff)
hello kitty base done
Diffstat (limited to 'src/entities/portal.js')
-rw-r--r--src/entities/portal.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/entities/portal.js b/src/entities/portal.js
new file mode 100644
index 0000000..8e3c6c9
--- /dev/null
+++ b/src/entities/portal.js
@@ -0,0 +1,28 @@
+import { Entity } from "./entity.js"
+import { PORTAL } from "../assets.js"
+import { Vector } from "../engine/vector.js"
+import { Engine } from "../engine.js"
+import { SCENE, SCENES } from "../scenes.js"
+
+export class Portal extends Entity {
+ constructor() {
+ super({
+ size: new Vector(150, 150),
+ position: new Vector(325, 100),
+ sprite: PORTAL[0],
+ })
+
+ frames = PORTAL.length
+ }
+
+ update() {
+ if (Engine.collision.collidingWithBoshy(this.position, this.hitbox)) {
+ SCENE.load(SCENES.HELLO_KITTY)
+ }
+ }
+
+ draw() {
+ this.span.src = PORTAL[Math.floor(Engine.frame / 2) % frames]
+ super.draw()
+ }
+}