diff options
| author | Kirill Petrashin <kirill8201@yandex.ru> | 2026-03-16 19:48:24 +0300 |
|---|---|---|
| committer | Kirill Petrashin <kirill8201@yandex.ru> | 2026-03-16 19:48:24 +0300 |
| commit | 5e07b322725c603038647aad873c4da480c7c520 (patch) | |
| tree | 670b46c7365d43c76376893cf87940f8540d47d8 /main.c | |
| parent | b1337798203e1ea4ddb7c76e6ca343e904fb19aa (diff) | |
Add ability to move the map around
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -45,8 +45,18 @@ int main(void) { Map map = rbt_maze_map(width, height, (unsigned int) time(NULL)); Position fake_start_position_to_pass_into_draw_map = {0, 0}; Position fake_goal_position_to_pass_into_draw_map = {width*2-2, height*2-2}; - draw_map(map, width*2-1, height*2-1, fake_start_position_to_pass_into_draw_map, fake_goal_position_to_pass_into_draw_map); - getch(); + int offset_x = 0, offset_y = 0; + while (1) { + draw_map(map, width*2-1, height*2-1, offset_x, offset_y, fake_start_position_to_pass_into_draw_map, fake_goal_position_to_pass_into_draw_map); + char c = getch(); + switch (c) { + case 'h': offset_x -= 2; break; + case 'l': offset_x += 2; break; + case 'j': offset_y += 1; break; + case 'k': offset_y -= 1; break; + case 'q': endwin(); return 0; + } + } endwin(); return 0; |
