From 5e07b322725c603038647aad873c4da480c7c520 Mon Sep 17 00:00:00 2001 From: Kirill Petrashin Date: Mon, 16 Mar 2026 19:48:24 +0300 Subject: Add ability to move the map around --- main.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 5734db8..c7b941c 100644 --- a/main.c +++ b/main.c @@ -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; -- cgit v1.2.3