diff options
| author | Kirill Petrashin <kirill8201@yandex.ru> | 2026-04-13 14:52:42 +0300 |
|---|---|---|
| committer | Kirill Petrashin <kirill8201@yandex.ru> | 2026-04-13 14:52:42 +0300 |
| commit | 300db4c7ce51b04715c08e6603a225b292964a76 (patch) | |
| tree | 8feaa21443621fd7428b3720cf5621aec6aaf57d | |
| parent | f817a761f00f07b7f57518065da0f5fd8ccf4c9d (diff) | |
| download | astar-300db4c7ce51b04715c08e6603a225b292964a76.tar.xz | |
Handle when trying to shrink the map too much
| -rw-r--r-- | main.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -153,12 +153,15 @@ int main(int argc, char **argv) { case 'l': map_offset_x -= 2; break; case 'j': map_offset_y -= 1; break; case 'k': map_offset_y += 1; break; + case 'H': clear(); map_offset_x += 20; break; case 'L': clear(); map_offset_x -= 20; break; case 'J': clear(); map_offset_y -= 10; break; case 'K': clear(); map_offset_y += 10; break; + case 'z': clear(); map_offset_x = 2; map_offset_y = 1; break; /* Move to top left corner */ case 'x': clear(); map_offset_x = - width * 2 + COLS - 2; map_offset_y = - height + LINES - 2; break; /* Move to bottom right corner */ + case 'g': switch (getch()) { case 's': @@ -173,18 +176,19 @@ int main(int argc, char **argv) { break; } break; + case 'a': anim = !anim; break; + case 'y': case 'o': case 'u': case 'i': if(is_maze) { switch (c) { - /* TODO: handle if it's zero */ - case 'y': mwidth -= 1; break; + case 'y': if (mwidth > 1) mwidth -= 1; break; case 'o': mwidth += 1; break; case 'u': mheight += 1; break; - case 'i': mheight -= 1; break; + case 'i': if (mheight > 1) mheight -= 1; break; } map_free(map, height); visited_free(visited, height); @@ -200,6 +204,7 @@ int main(int argc, char **argv) { path = path_func(dirs, map, width, height, start_pos, end_pos, visited, anim); } break; + case 's': message(height, "Filename: "); /* TODO: figure out how to show the cursor and echo the characters */ @@ -213,6 +218,7 @@ int main(int argc, char **argv) { message(height, "Saved to %s", filename); getch(); break; + case 'n': if (is_maze) { map_free(map, height); @@ -221,6 +227,7 @@ int main(int argc, char **argv) { path = path_func(dirs, map, width, height, start_pos, end_pos, visited, anim); } break; + case 'e': is_maze = 0; visited_free(visited, height); @@ -232,7 +239,9 @@ int main(int argc, char **argv) { visited = visited_new(width, height); path = path_func(dirs, map, width, height, start_pos, end_pos, visited, anim); break; + case KEY_RESIZE: clear(); break; + case 'q': map_free(map, height); path_free(path, height); endwin(); return 0; } } |
