aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/main.c b/main.c
index 20c3b57..4347551 100644
--- a/main.c
+++ b/main.c
@@ -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; };