Skip to content

Commit

Permalink
feat(helpers): add reward bubble stun
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Jan 30, 2025
1 parent d11bf1d commit 640c076
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/events/states.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Animation, Sprite, State } from '../constants'
import { addBadBubble, addProjectile, getPlayer } from '../gameobjects'
import { gameState } from '../helpers'
import type { Enemy } from '../types'

export function addEnemyState(enemy: Enemy) {
enemy.onStateEnter(State.Idle, () => {
enemy.play(Animation.Idle)
wait(rand(0.3, 1), () => enemy.enterState(State.Move))
const seconds = rand(0.3, 1)
wait(seconds, () => enemy.enterState(State.Move))
})

enemy.onStateEnter(State.Move, () => {
Expand Down Expand Up @@ -36,12 +38,14 @@ export function addEnemyState(enemy: Enemy) {

enemy.onStateEnter(State.Cooldown, () => {
enemy.play(Animation.Cooldown)
wait(rand(1, 3), () => enemy.enterState(State.Move))
const seconds = rand(1, 3)
wait(seconds, () => enemy.enterState(State.Move))
})

enemy.onStateEnter(State.Stunned, () => {
enemy.play(Animation.Stunned)
wait(rand(0.3, 1), () => enemy.enterState(State.Move))
const seconds = rand(0.3, 1) * gameState.player.bubble.stun
wait(seconds, () => enemy.enterState(State.Move))
})

enemy.onStateUpdate(State.Move, () => {
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/gameState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ class GameState {
player = {
bubble: {
damage: 20,
speed: 200,
size: 1,
speed: 200,
stun: 1,
},
}

Expand Down
14 changes: 14 additions & 0 deletions src/helpers/rewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ const rewards = [
gameState.player.bubble.size *= (100 + this.percentage) / 100
},
},

// bubble stun
{
percentage: 0,
setPercentage(percentage = randi(10, 25)) {
this.percentage = percentage
},
get text() {
return `Bubble Stun +${this.percentage}%`
},
action() {
gameState.player.bubble.stun *= (100 + this.percentage) / 100
},
},
]

export function getRewards(total = 2) {
Expand Down

0 comments on commit 640c076

Please sign in to comment.