add: move

This commit is contained in:
starnakin 2023-06-20 21:40:16 +02:00
parent 24ae92916d
commit 78987c9012

View File

@ -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() main()
{ {
local cursor_x, cursor_y;
local map = {'b', 'b', 'b','b', 'b', 'b', 'b', 'b', 'b'}; local map = {'b', 'b', 'b','b', 'b', 'b', 'b', 'b', 'b'};
cursor_x = SPAWN_X;
cursor_y = SPAWN_Y;
loop loop
{ {
slp; slp;
draw_map(map, 0, 0); draw_map(map, cursor_x, cursor_y);
input_update();
cursor_update(&cursor_x, &cursor_y);
} }
} }