summaryrefslogtreecommitdiff
path: root/src/entities/hello_kitty_background.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/hello_kitty_background.js
parenta840990bdcabf45fb0d377478ba0ab27222434ae (diff)
hello kitty base done
Diffstat (limited to 'src/entities/hello_kitty_background.js')
-rw-r--r--src/entities/hello_kitty_background.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/entities/hello_kitty_background.js b/src/entities/hello_kitty_background.js
new file mode 100644
index 0000000..4d9a81f
--- /dev/null
+++ b/src/entities/hello_kitty_background.js
@@ -0,0 +1,41 @@
+import { Vector } from "../engine/vector.js"
+import { BACKGROUND } from "../assets.js"
+import { Entity } from "../entities/entity.js"
+import { Engine } from "../engine.js"
+
+export class HelloKittyBackground extends Entity {
+ speed = 20
+ stage = 0
+
+ constructor(position = null) {
+ let size = new Vector(1300, 2080)
+ let x_margin = 0
+ if (position == null) position = new Vector(
+ size.x / 2 + Engine.screen.viewport / 2 - x_margin,
+ - (size.y / 2) + Engine.screen.viewport.y,
+ )
+ super({
+ //size: new Vector(650, 1040),
+ size: size,
+ position: position,
+ sprite: BACKGROUND.KITTY,
+ })
+ this.span.style.zIndex = -3
+ this.max_down = (this.size.y / 2)
+ this.x_margin = x_margin
+ }
+
+ update() {
+ this.position.y += this.speed
+ if (this.stage == 0 && this.position.y > this.max_down) {
+ let margin = this.position.y - this.max_down
+ let newPos = new Vector(
+ this.size.x / 2 - this.x_margin,
+ - (this.size.y / 2) + margin
+ )
+
+ new HelloKittyBackground(newPos)
+ this.stage++
+ }
+ }
+}