From 78987c90129c5b192ccc9c85a96731742c12f7b3 Mon Sep 17 00:00:00 2001 From: starnakin Date: Tue, 20 Jun 2023 21:40:16 +0200 Subject: [PATCH] add: move --- game.🗿 | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/game.🗿 b/game.🗿 index 789e6ad..3dcdcb3 100644 --- a/game.🗿 +++ b/game.🗿 @@ -106,13 +106,44 @@ draw_map(map, cursor_x, cursor_y) } } +global input_left; +global input_right; +global input_up; +global input_down; + +input_update() { + local input = [INPUT]; + input_up = (input & 0x10) != 0; + input_down = (input & 0x20) != 0; + input_left = (input & 0x40) != 0; + input_right = (input & 0x80) != 0; +} + +cursor_update(cursor_x_ptr, cursor_y_ptr) +{ + if (input_up) + [cursor_y_ptr] = ([cursor_y_ptr] - 1) % 3; + if (input_down) + [cursor_y_ptr] = ([cursor_y_ptr] + 1) % 3; + if (input_left) + [cursor_x_ptr] = ([cursor_x_ptr] - 1) % 3; + if (input_right) + [cursor_x_ptr] = ([cursor_x_ptr] + 1) % 3; +} main() { + local cursor_x, cursor_y; local map = {'b', 'b', 'b','b', 'b', 'b', 'b', 'b', 'b'}; + + cursor_x = SPAWN_X; + cursor_y = SPAWN_Y; + loop { slp; - draw_map(map, 0, 0); + draw_map(map, cursor_x, cursor_y); + input_update(); + cursor_update(&cursor_x, &cursor_y); } }