diff --git a/game.🗿 b/game.🗿 index feb12c0..519988d 100644 --- a/game.🗿 +++ b/game.🗿 @@ -135,9 +135,41 @@ cursor_update(cursor_x_ptr, cursor_y_ptr) [cursor_x_ptr] = ([cursor_x_ptr] + 1) % 3; } +check_victory(map, new_block_x, new_block_y) +{ + local row = 1; + loop + { + if ([map + ((new_block_x + row) % 3) * 3 + new_block_y] != [map + new_block_x * 3 + new_block_y]) + break; + if (row == 2) + return (1); + row++; + } + row = 1; + loop + { + if ([map + new_block_x * 3 + ((new_block_y + row) % 3)] != [map + new_block_x * 3 + new_block_y]) + break; + if (row == 2) + return (1); + row++; + } + row = 1; + loop + { + if ([map + ((new_block_x + row) % 3) * 3 + ((new_block_y + row) % 3)] != [map + new_block_x * 3 + new_block_y]) + break; + if (row == 2) + return (1); + row++; + } + return (0); +} + map_update(map, cursor_x, cursor_y) { - if (input_space == 0) + if (input_space == 0 | [map + cursor_x * 3 + cursor_y] != 'b') return; if (player_turn) [map + cursor_x * 3 + cursor_y] = 'x'; @@ -150,7 +182,7 @@ 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; @@ -162,6 +194,11 @@ main() draw_map(map, cursor_x, cursor_y); input_update(); cursor_update(&cursor_x, &cursor_y); - map_update(map, cursor_x, cursor_y); + if (input_space) + { + map_update(map, cursor_x, cursor_y); + if (check_victory(map, cursor_x, cursor_y)) + break; + } } }