add: space

This commit is contained in:
starnakin 2023-06-20 23:03:35 +02:00
parent a456b62b38
commit 950e932a3a

View File

@ -4,6 +4,8 @@ define SPAWN_X = 1;
define SPAWN_Y = 1;
define CASE_SIZE = 42;
global player_turn = 0;
draw_pixel(x, y, c)
{
[SCREEN + (x & 127) + (y & 127) * 128] = c;
@ -110,6 +112,7 @@ global input_left;
global input_right;
global input_up;
global input_down;
global input_space;
input_update() {
local input = [INPUT];
@ -117,6 +120,7 @@ input_update() {
input_down = (input & 0x20) != 0;
input_left = (input & 0x40) != 0;
input_right = (input & 0x80) != 0;
input_space = (input & 0x1) != 0;
}
cursor_update(cursor_x_ptr, cursor_y_ptr)
@ -131,6 +135,17 @@ cursor_update(cursor_x_ptr, cursor_y_ptr)
[cursor_x_ptr] = ([cursor_x_ptr] + 1) % 3;
}
map_update(map, cursor_x, cursor_y)
{
if (input_space == 0)
return;
if (player_turn)
[map + cursor_x * 3 + cursor_y] = 'x';
else
[map + cursor_x * 3 + cursor_y] = 'o';
player_turn = player_turn == 0;
}
main()
{
local cursor_x, cursor_y;
@ -147,5 +162,6 @@ main()
draw_map(map, cursor_x, cursor_y);
input_update();
cursor_update(&cursor_x, &cursor_y);
map_update(map, cursor_x, cursor_y);
}
}