diff --git a/README.md b/README.md index 0a95a54..ea2799e 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,5 @@ Limitation: the player must cheat - [ ] update itch page - [ ] other cheats? - [ ] explicit goal? +- [ ] bug: respawn killed enemies +- [ ] bug: bullets collide with bg? diff --git a/chi-tor.wren b/chi-tor.wren index 010413f..204e540 100644 --- a/chi-tor.wren +++ b/chi-tor.wren @@ -163,7 +163,11 @@ class Enemy { hit() { _alive = false - Game.score = Game.score + 1 + var points = 1 + if (Cheat.doublePoints) { + points = 2 + } + Game.score = Game.score + points } } @@ -278,6 +282,8 @@ class Explosion { } class World { + endReached { _world_x >= 210 } + construct new() { _t = 0 _stars = [] @@ -357,7 +363,7 @@ class World { // medium stars var width = 10 var spaceBetween = width * 10 - var speed = 0.1 + var speed = 0.5 var mediumTick = (spaceBetween + width) / speed if (_t % mediumTick == 0) { var dir = -1 @@ -370,7 +376,7 @@ class World { // Map scrolling if (Game.state == Game.game) { - if (_world_x < 210) { + if (!endReached) { if (_t % _world_scroll_speed == 0) { _world_x = _world_x + 1 } @@ -482,6 +488,22 @@ class World { } _player.draw() + + if (endReached) { + var w = 80 + var h = H/2-10 + if (Game.score >= Game.goal) { + TIC.print("YOU WIN", w+1, h+1, Color.black, true, 2) + TIC.print("YOU WIN", w, h, Color.white, true, 2) + } else { + TIC.print("YOU LOSE", w+1, h+1, Color.black, true, 2) + TIC.print("YOU LOSE", w, h, Color.white, true, 2) + + var p = Game.goal - Game.score + TIC.print("You need %(p) more points to win", w+1, h + 21, Color.black, false, 1, true) + TIC.print("You need %(p) more points to win", w, h + 20, Color.white, false, 1, true) + } + } } } @@ -495,6 +517,7 @@ class Game is TIC{ static score { __score } static score=(s) { __score = s } + static goal { __goal } construct new() { _t=0 @@ -506,6 +529,7 @@ class Game is TIC{ _p_index = 0 _c_index = 0 __score = 0 + __goal = 30 _t_delay = 0 } @@ -520,8 +544,8 @@ class Game is TIC{ Game.state == Game.gameover) { TIC.print("SCORE: %(__score)", 1, 1, Color.black, true) TIC.print("SCORE: %(__score)", 0, 0, Color.white, true) - TIC.print("GOAL: 12", 121, 1, Color.black, true) - TIC.print("GOAL: 12", 120, 0, Color.white, true) + TIC.print("GOAL: %(__goal)", 121, 1, Color.black, true) + TIC.print("GOAL: %(__goal)", 120, 0, Color.white, true) } if (Game.state == Game.gameover) { @@ -550,6 +574,7 @@ class Game is TIC{ } else if (Game.state == Game.gameover) { if (_t_delay > 10) { if (TIC.btnp(4)) { + _world = World.new() newGame() } } @@ -583,7 +608,6 @@ class Game is TIC{ } newGame() { - _world = World.new() __state = Game.game __score = 0 _t_delay = 0