diff options
Diffstat (limited to 'src/entities')
-rw-r--r-- | src/entities/hello_kitty.js | 2 | ||||
-rw-r--r-- | src/entities/hello_kitty_background.js | 12 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/entities/hello_kitty.js b/src/entities/hello_kitty.js index eb7552a..69646fd 100644 --- a/src/entities/hello_kitty.js +++ b/src/entities/hello_kitty.js @@ -8,7 +8,7 @@ export class HelloKitty extends Entity { max_hp = 500 hp = this.max_hp previous = 0 - moveInterval = 30 + moveInterval = 26 justGotHit = false turningRight = false 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 } } |