From 6834ffa31842ca249514854bac8bae0f0022f104 Mon Sep 17 00:00:00 2001 From: Kirill Petrashin Date: Thu, 23 Apr 2026 14:29:15 +0300 Subject: Make wraparound toggleable with a keybind --- main.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index 93dfc1e..db1d7a8 100644 --- a/main.c +++ b/main.c @@ -186,6 +186,8 @@ int main(int argc, char **argv) { * * [d] - Switch algorithms (A* or Dijsktra's) * + * [f] - Toggle wraparound + * * [r] - Reverse the path and switch start/end around * * [s] - Save the map to a bmp file @@ -271,13 +273,26 @@ int main(int argc, char **argv) { break; case 'd': - if (path_func == astar_path) { set_message("Dijkstra"); path_func = &dijkstra_path; } + if (path_func == astar_path) { set_message("Dijkstra's"); path_func = &dijkstra_path; } else { set_message("A*"); path_func = &astar_path; }; path_free(path, height); path = path_func(dirs, map, cell_costs, width, height, start_pos, end_pos, visited, anim); /* TODO: print time */ break; + case 'f': + wraparound_enabled = !wraparound_enabled; + if (wraparound_enabled) + set_message("Enabled wraparound, only works on Dijkstra's") + else + set_message("Disabled wraparound"); + + if (path_func == dijkstra_path) { + path_free(path, height); + path = path_func(dirs, map, cell_costs, width, height, start_pos, end_pos, visited, anim); + } + break; + case 'r': path_reverse(&path, width, height, &start_pos, &end_pos); break; -- cgit v1.2.3