diff --git a/chi-tor.wren b/chi-tor.wren index 560f991..90a673c 100644 --- a/chi-tor.wren +++ b/chi-tor.wren @@ -228,7 +228,7 @@ class World { // init background for (i in 0..W) { - update() + update(Game.title) } _remap = Fn.new {|tile, x, y| @@ -258,9 +258,12 @@ class World { TIC.mset(x, y, 0) } - update() { + update(state) { if (_player.alive) { - _player.update() + + if (state == Game.game) { + _player.update() + } for (s in _stars) { s.update() @@ -292,10 +295,12 @@ class World { } // Map scrolling - if (_t % _world_scroll_speed == 0) { - _world_x = _world_x + 1 + if (state == Game.game) { + if (_t % _world_scroll_speed == 0) { + _world_x = _world_x + 1 + } + _w_offset_x = -(_t % _world_scroll_speed) / (_world_scroll_speed / 8) } - _w_offset_x = -(_t % _world_scroll_speed) / (_world_scroll_speed / 8) if (_player.alive) { _t = _t + 1 @@ -385,7 +390,7 @@ class World { return false } - draw() { + draw(state) { for (s in _stars) { s.draw() } @@ -406,14 +411,14 @@ class World { class Game is TIC{ state { _state } - static start { "start" } + static title { "title" } static game { "game" } construct new() { _t=0 _x=96 _y=24 - _state = Game.start + _state = Game.title _world = World.new() } @@ -423,13 +428,33 @@ class Game is TIC{ _t=_t+1 } + OVR() { + if (state == Game.title) { + TIC.print("Chi-Tor", W/4, H/4, Color.white, false, 3) + TIC.print("Chi-Tor", W/4-1, H/4-1, Color.red, false, 3) + TIC.print("Z", W/5, 4*H/5, Color.red) + TIC.print(": shoot", W/5+8, 4*H/5, Color.white) + TIC.print("X", W/5, 4*H/5+10, Color.red) + TIC.print(": pause", W/5+8, 4*H/5+10, Color.white) + } + } + update() { - _world.update() + if (state == Game.title) { + if (TIC.btn(4)) { + _state = Game.game + } + } + _world.update(state) } draw() { TIC.cls(0) - _world.draw() + if (state == Game.title) { + _world.draw(state) + } else if (state == Game.game) { + _world.draw(state) + } } }