add score
This commit is contained in:
parent
842ad58b32
commit
ccb55f766e
|
@ -13,3 +13,4 @@ Limitation: the player must cheat
|
|||
- [ ] win state
|
||||
- [ ] update itch page
|
||||
- [ ] other cheats?
|
||||
- [ ] explicit goal?
|
||||
|
|
14
chi-tor.wren
14
chi-tor.wren
|
@ -163,6 +163,7 @@ class Enemy {
|
|||
|
||||
hit() {
|
||||
_alive = false
|
||||
Game.score = Game.score + 1
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,6 +240,7 @@ class Player {
|
|||
|
||||
die() {
|
||||
_alive = false
|
||||
Game.state = Game.gameover
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -417,7 +419,6 @@ class World {
|
|||
if (collide(bx, by, _player.bw, _player.bh, e.x, e.y, e.w, e.h)) {
|
||||
_player.die()
|
||||
_vfx.add(Explosion.new(_player.x, _player.y))
|
||||
Game.state = Game.gameover
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -487,6 +488,9 @@ class Game is TIC{
|
|||
static pause { "pause" }
|
||||
static gameover { "gameover" }
|
||||
|
||||
static score { __score }
|
||||
static score=(s) { __score = s }
|
||||
|
||||
construct new() {
|
||||
_t=0
|
||||
_x=96
|
||||
|
@ -496,6 +500,7 @@ class Game is TIC{
|
|||
_p_buttons = []
|
||||
_p_index = 0
|
||||
_c_index = 0
|
||||
__score = 0
|
||||
}
|
||||
|
||||
TIC() {
|
||||
|
@ -504,6 +509,13 @@ class Game is TIC{
|
|||
_t=_t+1
|
||||
}
|
||||
|
||||
OVR() {
|
||||
if (Game.state == Game.game) {
|
||||
TIC.print("SCORE: %(__score)", 0, 0, Color.white, true)
|
||||
TIC.print("GOAL: 12", 120, 0, Color.white, true)
|
||||
}
|
||||
}
|
||||
|
||||
update() {
|
||||
if (Game.state == Game.title) {
|
||||
if (TIC.btnp(4)) {
|
||||
|
|
Loading…
Reference in a new issue