Skip to content

Commit

Permalink
refactor(helpers): tidy gameState
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Jan 30, 2025
1 parent f33c790 commit 9b349ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
14 changes: 4 additions & 10 deletions src/helpers/gameState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,10 @@ class GameState {
score: 5,
increment: 5,
}
}

init() {
this.enemy.multiplier.damage = 1
this.enemy.multiplier.health = 1
this.enemy.multiplier.speed = 1
this.enemy.sprites = []
export let gameState = new GameState()

this.reward.score = 5
this.reward.increment = 5
}
export function resetGameState() {
gameState = new GameState()
}

export const gameState = new GameState()
4 changes: 2 additions & 2 deletions src/scenes/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import {
game,
music,
} from '../gameobjects'
import { gameState, levels } from '../helpers'
import { gameState, levels, resetGameState } from '../helpers'

scene(Scene.Game, () => {
gameState.init()
resetGameState()

addMusic()
music.play()
Expand Down

0 comments on commit 9b349ed

Please sign in to comment.