summaryrefslogtreecommitdiff
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
parent1fc522bc8c4a96858223e597ced8fea94ba57874 (diff)
hello kitty stage 1 and 2 done
-rw-r--r--assets/sprites/anticheese.pngbin0 -> 68222 bytes
-rw-r--r--src/anticheese.js25
-rw-r--r--src/assets.js2
-rw-r--r--src/engine.js1
-rw-r--r--src/engine/screen.js51
-rw-r--r--src/engine/vector.js36
-rw-r--r--src/entities/bigdump.js40
-rw-r--r--src/entities/boshy.js21
-rw-r--r--src/entities/boshybullet.js2
-rw-r--r--src/entities/entity.js6
-rw-r--r--src/entities/hello_kitty.js186
-rw-r--r--src/entities/hello_kitty/bullet.js58
-rw-r--r--src/entities/hello_kitty/bullet_particles.js29
-rw-r--r--src/entities/hello_kitty/laser.js72
-rw-r--r--src/entities/hello_kitty_background.js20
-rw-r--r--src/entities/hp_bar.js1
-rw-r--r--src/scenes/hello_kitty.js2
-rw-r--r--todo4
18 files changed, 507 insertions, 49 deletions
diff --git a/assets/sprites/anticheese.png b/assets/sprites/anticheese.png
new file mode 100644
index 0000000..d88cbba
--- /dev/null
+++ b/assets/sprites/anticheese.png
Binary files differ
diff --git a/src/anticheese.js b/src/anticheese.js
new file mode 100644
index 0000000..fc88b8f
--- /dev/null
+++ b/src/anticheese.js
@@ -0,0 +1,25 @@
+import { boshy } from "./main.js"
+import { Engine } from "./engine.js"
+import { BigDump } from "./entities/bigdump.js"
+
+const maxTime = 200
+const margin = 30
+let timeH = 0
+let timeV = 0
+
+export function update() {
+ if (boshy.dead) return
+
+ timeH = (
+ boshy.position.x > Engine.screen.viewport.x - margin ||
+ boshy.position.x < margin
+ ) ? timeH + 1 : 0
+
+ timeV = (
+ boshy.position.y > Engine.screen.viewport.y - margin ||
+ boshy.position.y < margin
+ ) ? timeV + 1 : 0
+
+ if (timeH == maxTime) new BigDump(false)
+ if (timeV == maxTime) new BigDump(true)
+}
diff --git a/src/assets.js b/src/assets.js
index 0b65e7d..bf63044 100644
--- a/src/assets.js
+++ b/src/assets.js
@@ -58,7 +58,9 @@ export const HELLO_KITTY = {
],
BULLET : './assets/sprites/hello_kitty_heart.png',
HIT_SOUND : './assets/sounds/exciteshoot.ogg',
+ LASER_SOUND : './assets/sounds/BLAAHLouder.ogg',
}
export const WHITE = './assets/sprites/white.png'
export const GAME_OVER = './assets/sprites/deathtext.png'
+export const ANTICHEESE = './assets/sprites/anticheese.png'
diff --git a/src/engine.js b/src/engine.js
index 1d71148..0adb528 100644
--- a/src/engine.js
+++ b/src/engine.js
@@ -20,6 +20,7 @@ export class Engine {
static updateEngine() {
update()
+ Engine.screen.update()
draw()
}
diff --git a/src/engine/screen.js b/src/engine/screen.js
index e9e5ef4..b1da92d 100644
--- a/src/engine/screen.js
+++ b/src/engine/screen.js
@@ -76,11 +76,12 @@ export class Screen {
///////////////////// COMMANDS //////////////////////
append(element) { this.spawn.appendChild(element) }
- draw(span, position, size, /* rotation = 0 */) {
+ draw(span, position, size, rotation) {
span.style.width = `${size.x * this.scale}px`
span.style.height = `${size.y * this.scale}px`
- span.style.top = `${(position.y - size.y / 2) * this.scale}px`
- span.style.left = `${(position.x - size.x / 2) * this.scale}px`
+ span.style.top = `${(position.y - size.y / 2 + this.additionalPosition.y) * this.scale}px`
+ span.style.left = `${(position.x - size.x / 2 + this.additionalPosition.x) * this.scale}px`
+ span.style.rotate = `${rotation}deg`
}
setBackground(img) { this.background.src = img }
@@ -95,4 +96,48 @@ export class Screen {
position.y - size.y / 2 > this.viewport.y
)
}
+
+ shaking = false
+ additionalPosition = new Vector(0, 0)
+ shake() {
+ this.shaking = true
+ this.shakingTimeLeft = 6
+ }
+
+ update() {
+ if (this.shaking) {
+ switch (this.shakingTimeLeft) {
+ case 6:
+ this.additionalPosition.x = 9
+ this.additionalPosition.y = -3
+ break
+
+ case 5:
+ this.additionalPosition.x = -8
+ this.additionalPosition.y = 2
+ break
+
+ case 4:
+ this.additionalPosition.x = 5
+ this.additionalPosition.y = 1
+ break
+
+ case 3:
+ this.additionalPosition.x = -4
+ this.additionalPosition.y = -2
+ break
+
+ case 2:
+ this.additionalPosition.x = 3
+ this.additionalPosition.y = -1
+ break
+
+ case 1:
+ this.additionalPosition.x = 0
+ this.shaking = false
+ break
+ }
+ this.shakingTimeLeft --
+ }
+ }
}
diff --git a/src/engine/vector.js b/src/engine/vector.js
index f596c51..739daaf 100644
--- a/src/engine/vector.js
+++ b/src/engine/vector.js
@@ -11,12 +11,17 @@ export class Vector {
normalize() {
if (this.x != 0 && 0 != this.y) {
- let hyp = Math.abs(this.x)
- let cSquared = Math.pow(hyp, 2) / 2
- let c = Math.sqrt(cSquared, 2)
+ /* this is what it should be doing: */
+ // let hyp = Math.abs(this.x)
+ // let cSquared = Math.pow(hyp, 2) / 2
+ // let c = Math.sqrt(cSquared, 2)
- this.x = this.x / Math.abs(this.x) * c
- this.y = this.y / Math.abs(this.x) * c
+ // this.x = this.x / Math.abs(this.x) * c
+ // this.y = this.y / Math.abs(this.x) * c
+
+ /* but we need to save resources */
+ this.x = this.x / 4 * 3
+ this.y = this.y / 4 * 3
}
}
@@ -29,6 +34,13 @@ export class Vector {
return new Vector(this.x, this.y)
}
+ static substraction(vector_a, vector_b) {
+ return new Vector(
+ vector_a.x - vector_b.x,
+ vector_a.y - vector_b.y
+ )
+ }
+
static division(vector_a, vector_b) {
return new Vector(
vector_a.x / vector_b.x,
@@ -41,4 +53,18 @@ export class Vector {
this.y = Math.floor(this.y)
return this
}
+
+ toDeg() {
+ var angle = Math.atan2(this.y, this.x) //radians
+ var degrees = 180*angle/Math.PI //degrees
+ return (360+Math.round(degrees))%360 //round number, avoid decimal fragments
+ }
+
+ static fromDeg(degrees) {
+ let radians = degrees*Math.PI/180
+ return new Vector(
+ Math.cos(radians),
+ Math.sin(radians)
+ )
+ }
}
diff --git a/src/entities/bigdump.js b/src/entities/bigdump.js
new file mode 100644
index 0000000..90b4a57
--- /dev/null
+++ b/src/entities/bigdump.js
@@ -0,0 +1,40 @@
+import { ANTICHEESE } from "../assets.js"
+import { Vector } from "../engine/vector.js"
+import { Engine } from "../engine.js"
+import { Entity } from "./entity.js"
+import { boshy } from "../main.js"
+
+export class BigDump extends Entity {
+ constructor(bottom = false) {
+ let position = bottom ?
+ new Vector(0, boshy.position.y) :
+ new Vector(boshy.position.x, 0)
+
+ super({
+ size: new Vector(200, 10),
+ position: position,
+ sprite: ANTICHEESE,
+ degrees: bottom ? 270 : 0,
+ })
+
+ this.bottom = bottom
+ }
+
+ speed = 10
+ maxSize = 200
+
+ update() {
+ if (this.size.y < this.maxSize) this.size.y += this.speed * 0.75
+ if (this.bottom) this.position.x += this.speed
+ else this.position.y += this.speed
+
+ console.log("dump", this.position)
+
+ if (Engine.collision.collidingWithBoshy(this.position, this.hitbox)) {
+ boshy.die()
+ }
+ if (Engine.screen.isOffLimits(this.position, this.size)) {
+ this.remove()
+ }
+ }
+}
diff --git a/src/entities/boshy.js b/src/entities/boshy.js
index 9a2b589..d2d723f 100644
--- a/src/entities/boshy.js
+++ b/src/entities/boshy.js
@@ -22,6 +22,7 @@ export class Boshy extends Entity {
sprite: BOSHY.NORMAL,
})
+ /* play initial sound */
switch (currentScene) {
case SCENES.PREQUEL:
Engine.radio.playSound(BOSHY.SOUNDS.INTRO2)
@@ -67,15 +68,18 @@ export class Boshy extends Entity {
this.lastShot = Engine.frame /*(reset reload)*/
- let bullet_a_position = this.position.clone()
- let bullet_b_position = this.position.clone()
+ /* it was supposed to shoot twice */
+ // let bullet_a_position = this.position.clone()
+ // let bullet_b_position = this.position.clone()
- bullet_a_position.x = bullet_a_position.x + 5
- bullet_b_position.x = bullet_b_position.x - 5
+ // bullet_a_position.x = bullet_a_position.x + 5
+ // bullet_b_position.x = bullet_b_position.x - 5
- new BoshyBullet(bullet_a_position)
- new BoshyBullet(bullet_b_position)
- // new BoshyBullet(this.position.clone())
+ // new BoshyBullet(bullet_a_position)
+ // new BoshyBullet(bullet_b_position)
+
+ /* but once again, we need to save resources */
+ new BoshyBullet(this.position.clone())
Engine.radio.playSound(BOSHY.SOUNDS.SHOOT)
}
@@ -84,6 +88,7 @@ export class Boshy extends Entity {
this.dead = true
this.playDeathSounds()
this.spawnBlood()
+ Engine.screen.shake()
this.position.x = 0
this.position.y = Engine.screen.viewport.y
@@ -104,7 +109,7 @@ export class Boshy extends Entity {
spawnBlood() {
for (let i = 0; i<20; i++) {
- new Blood(this.position.clone().floor())
+ new Blood(this.position.clone())
}
}
}
diff --git a/src/entities/boshybullet.js b/src/entities/boshybullet.js
index a87e159..8c8a191 100644
--- a/src/entities/boshybullet.js
+++ b/src/entities/boshybullet.js
@@ -10,7 +10,7 @@ export class BoshyBullet extends Entity {
constructor(position = new Vector(0,0)) {
super({
size: new Vector(5, 5),
- position: position.floor(),
+ position: position,
sprite: BOSHY.BULLET,
})
}
diff --git a/src/entities/entity.js b/src/entities/entity.js
index 9d27508..0dbe00c 100644
--- a/src/entities/entity.js
+++ b/src/entities/entity.js
@@ -3,16 +3,20 @@ import { Engine } from "../engine.js"
import { entities } from "../main.js"
export class Entity {
+ rotation = 0
+
constructor({
size,
hitbox = size,
sprite,
position = new Vector(0,0),
pixelated = false,
+ degrees = 0,
}) {
this.size = size
this.hitbox = hitbox
this.position = position
+ this.rotation = degrees
this.span = document.createElement("img")
this.span.src = sprite
@@ -25,7 +29,7 @@ export class Entity {
update() {}
draw() {
- Engine.screen.draw(this.span, this.position, this.size)
+ Engine.screen.draw(this.span, this.position, this.size, this.rotation)
}
diff --git a/src/entities/hello_kitty.js b/src/entities/hello_kitty.js
index 69646fd..65fa30b 100644
--- a/src/entities/hello_kitty.js
+++ b/src/entities/hello_kitty.js
@@ -3,16 +3,21 @@ import { Engine } from "../engine.js"
import { Entity } from "./entity.js"
import { HELLO_KITTY } from "../assets.js"
import { setEnemy, boshy } from "../main.js"
+import { Bullet } from "./hello_kitty/bullet.js"
+import { Laser } from "./hello_kitty/laser.js"
export class HelloKitty extends Entity {
- max_hp = 500
+ max_hp = 300
hp = this.max_hp
- previous = 0
moveInterval = 26
+ previous = 0
+ stage = 1
justGotHit = false
turningRight = false
+ bulletMarginY = 40
+
constructor() {
super({
size: new Vector(200, 200),
@@ -22,30 +27,25 @@ export class HelloKitty extends Entity {
pixelated: true,
})
+
this.span.style.zIndex = 1
setEnemy(this)
}
update() {
- this.move()
+ switch (this.stage) {
+ case 0: this.stage0()
+ case 1: this.stage1(); break
+ case 2: this.stage2(); break
+ }
if (Engine.collision.collidingWithBoshy(this.position, this.hitbox)) {
boshy.die()
}
}
- move() {
- /* get position */
- let localscale = Math.sin((Engine.frame - this.previous) / this.moveInterval)
- let viewport = Engine.screen.viewport
- let newPos = (viewport.x / 2) + (localscale * viewport.x / 2) * 0.6
-
- this.turningRight = this.position.x < newPos
- this.position.x = newPos
- // this.position.x += this.speed
- // if (this.position.x > 325) this.speed -= this.acceleration
- // else this.speed += this.acceleration
- }
-
+ delayBetweenFrames = 10
+ timeUntilNextFrame = this.delayBetweenFrames
+ frameAlternator = false
draw() {
/* hit effect */
if (this.justGotHit) {
@@ -55,18 +55,162 @@ export class HelloKitty extends Entity {
this.span.style.filter = "brightness(100%)"
}
- if (this.turningRight) this.span.style.transform = "scaleX(-1)"
- else this.span.style.transform = "scaleX(1)"
+ if (this.speed > 0) this.span.style.transform = "scaleX(-1)"
+ else if (this.speed < 0) this.span.style.transform = "scaleX(1)"
/* frame */
- this.span.src = (Math.floor(Engine.frame / 10 % 2) == 0) ?
- HELLO_KITTY.MAIN[0] :
- HELLO_KITTY.MAIN[1]
+ /* this is what it should be doing */
+ // this.span.src = (Math.floor(Engine.frame / 10 % 2) == 0) ?
+ // HELLO_KITTY.MAIN[0] :
+ // HELLO_KITTY.MAIN[1]
+ /* but no hi ha pressupost for it */
+ /* here's the alternative: */
+ if (!this.timeUntilNextFrame) {
+ this.timeUntilNextFrame = this.delayBetweenFrames
+ this.span.src = this.frameAlternator ?
+ HELLO_KITTY.MAIN[0] :
+ HELLO_KITTY.MAIN[1]
+ this.frameAlternator = !this.frameAlternator
+ }
+ this.timeUntilNextFrame--
/* draw */
super.draw()
}
+ attacksUntilNextStage = 6
+ normalAttackDelay = 100
+ attackWaitTime = this.normalAttackDelay
+
+ stage0() {
+ this.innerStage = 0
+ this.timeUntilNextInnerStage = 0
+ this.attackWaitTime = this.normalAttackDelay
+ // this.prepareMoving()
+ this.stage++
+ }
+ /* single shoots stage */
+ stage1() {
+ this.move()
+
+ if (!this.attackWaitTime) {
+ if (!this.attacksUntilNextStage) {
+ this.stage++
+ this.attacksUntilNextStage = 4
+ } else {
+ this.normalAttack()
+ this.attackWaitTime = this.normalAttackDelay
+ this.attacksUntilNextStage--
+ }
+ }
+
+ this.attackWaitTime--
+
+ }
+
+ innerStage = 0
+ timeUntilNextInnerStage = 0
+
+ /* laser stage */
+ stage2() {
+ switch (this.innerStage) {
+ case 0: /*(preparation)*/
+ this.laserAttackDelay = 120
+ this.attackWaitTime = this.laserAttackDelay + 100
+
+ this.timeUntilNextInnerStage = 120
+ this.innerStage++
+ case 1: /*(chasing player)*/
+ this.moveToPlayer()
+ this.timeUntilNextInnerStage--
+ if (!this.timeUntilNextInnerStage) {
+ this.timeUntilNextInnerStage = 100
+ this.innerStage++
+ this.laserAttack(true)
+ }
+ return
+ case 2: /*(first laser shot, waiting)*/
+ this.timeUntilNextInnerStage--
+ if (!this.timeUntilNextInnerStage) {
+ this.prepareMoving()
+ this.innerStage++
+ }
+ return
+ }
+
+ /* post-preparation behaviour */
+ this.move()
+ if (!this.attackWaitTime) {
+ if (!this.attacksUntilNextStage) {
+ this.stage = 0
+ this.attacksUntilNextStage = 6
+ } else {
+ this.laserAttack()
+
+ this.attackWaitTime = this.laserAttackDelay
+ this.laserAttackDelay -= 20
+ this.attacksUntilNextStage--
+ }
+ }
+ this.attackWaitTime--
+ }
+
+
+ speed = 9
+ acceleration = 0.2
+
+ prepareMoving() {
+ this.position.x = Engine.screen.viewport.x / 2
+ this.speed = 9
+ }
+
+ move() {
+ this.position.x += this.speed
+ if (this.position.x > 325) this.speed -= this.acceleration
+ else this.speed += this.acceleration
+ }
+
+ moveToPlayer() {
+ let distance = Math.floor(this.position.x - boshy.position.x)
+
+ switch (true) {
+ case (distance < 10 && distance > -10): this.speed = 0; break
+ case (distance < -50): this.speed = 10; break
+ case (distance < -20): this.speed = 5; break
+ case (distance < 0): this.speed = 2; break
+ case (distance > 50): this.speed = -10; break
+ case (distance > 20): this.speed = -5; break
+ case (distance > 0): this.speed = -2; break
+ }
+ this.position.x += this.speed
+ }
+
+ normalAttack() {
+ let angleToPlayer = this.getBulletAngleToPlayer()
+ let bulletCenter = this.position.clone()
+ bulletCenter.y += this.bulletMarginY
+ new Bullet({
+ position: bulletCenter.clone(),
+ speed: 10,
+ degrees: angleToPlayer + Engine.random(-10, 10),
+ })
+
+ Engine.screen.shake()
+ }
+
+ laserAttack(delayed = false) {
+ new Laser(boshy.position.x, delayed)
+ }
+
+ getBulletAngleToPlayer() {
+ let v1 = this.position.clone()
+ v1.y += this.bulletMarginY
+
+ let v2 = boshy.position
+ let diff = Vector.substraction(v2, v1)
+ return Math.floor(diff.toDeg())
+ }
+
hit() {
this.hp--
if (!this.justGotHit) Engine.radio.playSound(HELLO_KITTY.HIT_SOUND)
diff --git a/src/entities/hello_kitty/bullet.js b/src/entities/hello_kitty/bullet.js
new file mode 100644
index 0000000..1caeb7c
--- /dev/null
+++ b/src/entities/hello_kitty/bullet.js
@@ -0,0 +1,58 @@
+import { HELLO_KITTY } from "../../assets.js"
+import { Vector } from "../../engine/vector.js"
+import { Engine } from "../../engine.js"
+import { Entity } from "../entity.js"
+import { boshy } from "../../main.js"
+import { BulletParticle } from "./bullet_particles.js"
+
+export class Bullet extends Entity {
+ constructor({
+ position,
+ speed,
+ spinning = false,
+ degrees = 0,
+ gravity = 0,
+ }) {
+ super({
+ size: new Vector(30, 30),
+ position: position,
+ sprite: HELLO_KITTY.BULLET,
+ degrees: degrees
+ })
+
+ this.spinning = spinning
+ this.velocity = Vector.fromDeg(degrees)
+ this.velocity.multiply(speed)
+ this.velocity.floor()
+
+ this.gravity = gravity
+
+ if (speed > 6) this.emittingParticles = true
+ }
+
+ particleReloadTime = 10
+ particleTimeWait = this.particleReloadTime
+ spinSpeed = 10
+
+ update() {
+ this.velocity.y += this.gravity
+ this.position.add(this.velocity)
+
+ if (this.emittingParticles) {
+ if (!this.particleTimeWait) {
+ this.particleTimeWait = this.particleReloadTime
+ new BulletParticle(this.position.clone())
+ }
+ this.particleTimeWait--
+ }
+
+ if (this.spinning) this.rotation += this.spinSpeed
+
+ if (Engine.collision.collidingWithBoshy(this.position, this.hitbox)) {
+ boshy.die()
+ }
+ if (Engine.screen.isOffLimits(this.position, this.size)) {
+ this.remove()
+ }
+ }
+}
diff --git a/src/entities/hello_kitty/bullet_particles.js b/src/entities/hello_kitty/bullet_particles.js
new file mode 100644
index 0000000..c4dee60
--- /dev/null
+++ b/src/entities/hello_kitty/bullet_particles.js
@@ -0,0 +1,29 @@
+import { HELLO_KITTY } from "../../assets.js"
+import { Vector } from "../../engine/vector.js"
+import { Engine } from "../../engine.js"
+import { Entity } from "../entity.js"
+
+export class BulletParticle extends Entity {
+ constructor(position) {
+ super({
+ size: new Vector(20, 20),
+ position: position,
+ sprite: HELLO_KITTY.BULLET,
+ })
+ this.rotation = Engine.random(0, 360)
+ this.rotationSpeed = Engine.random(-10, 10)
+ this.velocity = new Vector(
+ Engine.random(-2, 2),
+ Engine.random(-2, 2),
+ )
+ }
+
+ update() {
+ this.position.add(this.velocity)
+ this.rotation += this.rotationSpeed
+ this.size.x = this.size.y -= 1
+ if (this.size.x <= 0) {
+ this.remove()
+ }
+ }
+}
diff --git a/src/entities/hello_kitty/laser.js b/src/entities/hello_kitty/laser.js
new file mode 100644
index 0000000..b8e480d
--- /dev/null
+++ b/src/entities/hello_kitty/laser.js
@@ -0,0 +1,72 @@
+import { WHITE, HELLO_KITTY } from "../../assets.js"
+import { Vector } from "../../engine/vector.js"
+import { Engine } from "../../engine.js"
+import { Entity } from "../entity.js"
+import { boshy } from "../../main.js"
+import { Bullet } from "./bullet.js"
+
+export class Laser extends Entity {
+ attacking = false
+ loadingTimeLeft = 70
+ attackTimeLeft = 40
+
+ attackSize = 150
+ shrinkSpeed = 15
+
+ constructor(x, delayed) {
+ super({
+ size: new Vector(40, Engine.screen.viewport.y),
+ position: new Vector(x, Engine.screen.viewport.y / 2),
+ sprite: WHITE,
+ pixelated: true,
+ })
+ this.span.style.zIndex = -1
+ if (delayed) {
+ this.size.x = 60
+ this.loadingTimeLeft = 100
+ }
+ }
+
+ update() {
+ if (this.loadingTimeLeft) {
+ if (this.size.x) this.size.x -= 1
+ this.loadingTimeLeft--
+ if (!this.loadingTimeLeft) {
+ this.attacking = true
+ this.size.x = 100
+ Engine.radio.playSound(HELLO_KITTY.LASER_SOUND)
+ Engine.screen.shake()
+ this.spawnBullets()
+ }
+ return
+ }
+
+ if (this.attackTimeLeft) {
+ if (this.size.x == this.attackSize) this.size.x += 10
+ else this.size.x = this.attackSize
+ this.attackTimeLeft--
+ if (Engine.collision.collidingWithBoshy(this.position, this.hitbox)) {
+ boshy.die()
+ }
+ return
+ }
+
+ this.size.x -= this.shrinkSpeed
+ if (this.size.x <= 0) this.remove()
+
+ }
+
+ spawnBullets() {
+ let bulletCenter = new Vector(this.position.x, Engine.screen.viewport.y)
+ let randomness_angle = Engine.random(-20, 20)
+ for (let i = -1; i < 2; i++) {
+ new Bullet({
+ position: bulletCenter.clone(),
+ speed: 6,
+ spinning: true,
+ degrees: 270 + 40 * i + randomness_angle,
+ gravity: 0.15,
+ })
+ }
+ }
+}
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
+ }
}
}
diff --git a/src/entities/hp_bar.js b/src/entities/hp_bar.js
index d6e68bb..a5e5f50 100644
--- a/src/entities/hp_bar.js
+++ b/src/entities/hp_bar.js
@@ -14,6 +14,7 @@ export class HPBar extends Entity {
pixelated: true,
})
+ this.span.style.zIndex = 1
this.lasthp = enemy.hp
}
diff --git a/src/scenes/hello_kitty.js b/src/scenes/hello_kitty.js
index f7b5c8c..68cfc95 100644
--- a/src/scenes/hello_kitty.js
+++ b/src/scenes/hello_kitty.js
@@ -2,6 +2,7 @@ import { Engine } from "../engine.js"
import { MUSIC } from "../assets.js"
import { HelloKittyBackground } from "../entities/hello_kitty_background.js"
import { HelloKitty } from "../entities/hello_kitty.js"
+import * as anticheese from "../anticheese.js"
export function start() {
Engine.radio.playMusic(MUSIC.HELL)
@@ -11,6 +12,7 @@ export function start() {
export function update() {
+ anticheese.update()
}
export function draw() {
diff --git a/todo b/todo
new file mode 100644
index 0000000..7acbe6b
--- /dev/null
+++ b/todo
@@ -0,0 +1,4 @@
+[ ] - implement anti-cheesing poop
+[ ] - mini-spamton like attack with raining hearts (stage 3)
+[ ] - touhou-like attack (stage 4)
+[ ] - make lasers shoot hearts, shoot extra hearts when low hp