summaryrefslogtreecommitdiff
path: root/src/entities/hello_kitty_background.js
diff options
context:
space:
mode:
authorniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2024-12-26 14:24:53 +0100
committerniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2024-12-26 14:24:53 +0100
commit474a7253b6b67e2ed33936f6b633587d5d304b66 (patch)
tree456b9cef3cb59da8e0eb575b9425a1fedfe67e1e /src/entities/hello_kitty_background.js
parent1fc522bc8c4a96858223e597ced8fea94ba57874 (diff)
hello kitty stage 1 and 2 done
Diffstat (limited to 'src/entities/hello_kitty_background.js')
-rw-r--r--src/entities/hello_kitty_background.js20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/entities/hello_kitty_background.js b/src/entities/hello_kitty_background.js
index 0ff405b..658f3a3 100644
--- a/src/entities/hello_kitty_background.js
+++ b/src/entities/hello_kitty_background.js
@@ -3,8 +3,8 @@ 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
+// this is the single worst code in the game
+// i'm sorry to whoever is reading this
export class HelloKittyBackground extends Entity {
speed = 20
@@ -12,7 +12,7 @@ export class HelloKittyBackground extends Entity {
constructor(position = null) {
let first = (position == null)
let size = new Vector(1300, 2080)
- let x_margin = 0
+ let x_margin = 20
if (position == null) position = new Vector(
size.x / 2 + Engine.screen.viewport / 2 - x_margin,
- (size.y / 2) + Engine.screen.viewport.y,
@@ -23,7 +23,8 @@ export class HelloKittyBackground extends Entity {
sprite: BACKGROUND.KITTY,
})
this.span.style.zIndex = -3
- this.max_down = (this.size.y / 2)
+ this.maxDownBeforeSpawningNew = (this.size.y / 2)
+ this.maxDown = this.size.y / 2 + Engine.screen.viewport.y
this.x_margin = x_margin
this.stage = first ? 0 : 1
}
@@ -31,8 +32,8 @@ export class HelloKittyBackground extends Entity {
update() {
this.position.y += this.speed
if (this.stage == 0) {
- if (this.position.y < this.max_down) return
- let margin = this.position.y - this.max_down
+ if (this.position.y < this.maxDownBeforeSpawningNew) return
+ let margin = this.position.y - this.maxDownBeforeSpawningNew
let newPos = new Vector(
this.size.x / 2 - this.x_margin,
- (this.size.y / 2) + margin
@@ -42,9 +43,8 @@ export class HelloKittyBackground extends Entity {
this.stage++
return
}
- if (
- this.position.y > 0 &&
- Engine.screen.isOffLimits(this.position, this.size)
- ) this.position.y -= this.size.y * 2
+ if (this.position.y >= this.maxDown) {
+ this.position.y -= this.size.y * 2
+ }
}
}