summaryrefslogtreecommitdiff
path: root/src/entities/hello_kitty_background.js
diff options
context:
space:
mode:
authorniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2024-12-25 09:32:05 +0100
committerniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2024-12-25 09:32:05 +0100
commit1fc522bc8c4a96858223e597ced8fea94ba57874 (patch)
treee7dc943a068d8d5ae7db0511348029700c8f767e /src/entities/hello_kitty_background.js
parentfe63ca3c64d2dd310268df7391ba6de5e9b7a2f2 (diff)
fixed background
Diffstat (limited to 'src/entities/hello_kitty_background.js')
-rw-r--r--src/entities/hello_kitty_background.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/entities/hello_kitty_background.js b/src/entities/hello_kitty_background.js
index 70f0b9d..0ff405b 100644
--- a/src/entities/hello_kitty_background.js
+++ b/src/entities/hello_kitty_background.js
@@ -3,11 +3,14 @@ import { BACKGROUND } from "../assets.js"
import { Entity } from "../entities/entity.js"
import { Engine } from "../engine.js"
+// i am aware this code is a mess
+// but i don't have enough time to clean it up
+
export class HelloKittyBackground extends Entity {
speed = 20
- stage = 0
constructor(position = null) {
+ let first = (position == null)
let size = new Vector(1300, 2080)
let x_margin = 0
if (position == null) position = new Vector(
@@ -15,7 +18,6 @@ export class HelloKittyBackground extends Entity {
- (size.y / 2) + Engine.screen.viewport.y,
)
super({
- //size: new Vector(650, 1040),
size: size,
position: position,
sprite: BACKGROUND.KITTY,
@@ -23,6 +25,7 @@ export class HelloKittyBackground extends Entity {
this.span.style.zIndex = -3
this.max_down = (this.size.y / 2)
this.x_margin = x_margin
+ this.stage = first ? 0 : 1
}
update() {
@@ -39,6 +42,9 @@ export class HelloKittyBackground extends Entity {
this.stage++
return
}
- if (Engine.screen.isOffLimits(this.position, this.size)) this.remove()
+ if (
+ this.position.y > 0 &&
+ Engine.screen.isOffLimits(this.position, this.size)
+ ) this.position.y -= this.size.y * 2
}
}