diff --git a/chi-tor.wren b/chi-tor.wren index 98164fe..c12b8b2 100644 --- a/chi-tor.wren +++ b/chi-tor.wren @@ -23,6 +23,13 @@ class Color { static white { 12 } } +class D { + static up { 0 } + static down { 1 } + static left { 2 } + static right { 3 } +} + class Star { construct new(x, y, size, scrollSpeed, color) { _x = x @@ -428,6 +435,7 @@ class Game is TIC{ _p_buttons = [] _p_index = 0 _d_enabled = false + _cheat_seq = [D.up, D.up, D.left, D.right, D.up, D.down] } TIC() { @@ -469,9 +477,29 @@ class Game is TIC{ _p_index = _p_index + 1 } } + + if (cheatFound()) { + _d_enabled = true + } } _world.update(state) } + + cheatFound() { + var end = _p_index + var start = (end - _cheat_seq.count) + if (start < 0) { + return false + } + for (i in 0..._cheat_seq.count) { + var dir = _p_buttons[(start + i) % _p_buttons.count] + var cheat = _cheat_seq[i] + if (dir != cheat) { + return false + } + } + return true + } draw() { TIC.cls(0) @@ -481,30 +509,31 @@ class Game is TIC{ _world.draw(state) } else if (state == Game.pause) { TIC.print("PAUSE", 90, H/4, Color.white, false, 2) - TIC.print("debug mode: disabled", 60, H - 10, Color.white) - var end = _p_index - var start = (end - 10).max(0) - //System.print("start: %(start)") - System.print("c: %(_p_index - start)") - var c = 0 - for (i in start...end) { - //System.print("%(_p_buttons) i: %(i%_p_buttons.count)") - var pos = i - start - var dir = _p_buttons[i % _p_buttons.count] - var sprId = 84 - if (dir == 0) { // up - TIC.spr(sprId, 5 + pos * 10, H - 20, 0) - } - if (dir == 1) { // down - TIC.spr(sprId, 5 + pos * 10, H - 20, 0, 1, 2) - } - if (dir == 2) { // left - TIC.spr(sprId, 5 + pos * 10, H - 20, 0, 1, 0, 3) - } - if (dir == 3) { // right - TIC.spr(sprId, 5 + pos * 10, H - 20, 0, 1, 0, 1) + if (!_d_enabled) { + TIC.print("debug mode: disabled", 60, H - 10, Color.white) + + var end = _p_index + var start = (end - 10).max(0) + for (i in start...end) { + var pos = i - start + var dir = _p_buttons[i % _p_buttons.count] + var sprId = 84 + if (dir == D.up) { + TIC.spr(sprId, 5 + pos * 10, H - 20, 0) + } + if (dir == D.down) { + TIC.spr(sprId, 5 + pos * 10, H - 20, 0, 1, 2) + } + if (dir == D.left) { + TIC.spr(sprId, 5 + pos * 10, H - 20, 0, 1, 0, 3) + } + if (dir == D.right) { + TIC.spr(sprId, 5 + pos * 10, H - 20, 0, 1, 0, 1) + } } + } else { + TIC.print("debug mode: enabled", 60, H - 10, Color.white) } } }