diff options
| author | Kirill Petrashin <kirill8201@yandex.ru> | 2026-04-22 20:26:03 +0300 |
|---|---|---|
| committer | Kirill Petrashin <kirill8201@yandex.ru> | 2026-04-22 20:26:03 +0300 |
| commit | 1cd0a30593d9b7805752e3e183c93f622211ed0b (patch) | |
| tree | 574653e214edcff4270daa78b3eeeb3ca0cb2d75 /main.c | |
| parent | 8282175440876b28d431167ee0702404b09bf2e6 (diff) | |
| download | astar-1cd0a30593d9b7805752e3e183c93f622211ed0b.tar.xz | |
Document keybindings, add MMB to move in map_editor(), add 'A' keybind to force anim
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 52 |
1 files changed, 51 insertions, 1 deletions
@@ -159,10 +159,54 @@ int main(int argc, char **argv) { while (1) { draw_map(map, cell_costs, width, height, start_pos, end_pos, NULL, path, visited, NULL); int c = getch(); + + /* + * Keybindings: + * [k] \ + * [h] [l] } Move the view + * [j] / + * + * [K] \ + * [H] [L] } Move the view faster + * [J] / + * + * - [i] \ + * [y] [o] } Resize the maze + * [u] + / + * + * [z] - Move the view to the top left corner + * [x] - Move the view to the bottom right corner + * + * [g] followed by: + * [s] - Move the view to the start + * [e] - Move the view to the end + * + * [a] - If path wasn't found, try again. If it was, animate + * [A] - Force animate + * + * [d] - Switch algorithms (A* or Dijsktra's) + * + * [s] - Save the map to a bmp file + * + * [w] - Open a map from a plaintext file + * + * [n] - If in maze mode, generate a new maze + * + * [t] - Show time it took to calculate last path + * + * [c] - Load a costs file + * + * [e] - Enter the map editor + * + * [q] - Exit + * + * Mousebindings: + * Drag with MMB to move the view (buggy) + */ switch (c) { case KEY_MOUSE: if (getmouse(&mevent) == OK && (mevent.bstate & BUTTON2_PRESSED)) { - /* FIXME: it's buggy. if we quickly click mwheel, it doesn't let go */ + /* FIXME: it's buggy. if we quickly click mwheel, it doesn't let go. Same in map_editor() */ mousemask(BUTTON2_PRESSED | BUTTON2_RELEASED | REPORT_MOUSE_POSITION, NULL); printf("\033[?1003h"); fflush(stdout); /* Makes the terminal report mouse movements */ int init_x = mevent.x, @@ -218,6 +262,12 @@ int main(int argc, char **argv) { clear_message(); break; + case 'A': + path_free(path, height); + path = path_func(dirs, map, cell_costs, width, height, start_pos, end_pos, visited, 1); + clear_message(); + break; + case 'd': if (path_func == astar_path) { set_message("Dijkstra"); path_func = &dijkstra_path; } else { set_message("A*"); path_func = &astar_path; }; |
