aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorKirill Petrashin <kirill8201@yandex.ru>2026-03-20 22:57:32 +0300
committerKirill Petrashin <kirill8201@yandex.ru>2026-03-20 22:57:32 +0300
commita08e4c138734fd59246e70260c51b9d7b68be007 (patch)
tree52d8eec4570acbea5d91177a05549abd9798c5b9 /main.c
parenta0604cc84ef5286d7fe42a1ad125e654ce7eacf6 (diff)
Add ability to read plaintext maps from files
Diffstat (limited to 'main.c')
-rw-r--r--main.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/main.c b/main.c
index 3d9e29c..1142134 100644
--- a/main.c
+++ b/main.c
@@ -12,6 +12,7 @@
/* So, TODO for now:
- Implement Dijkstra and greedy-best-first search algorithms
- Implement the A* algorithm
+ - Implement it with 4 and 8 directions
- Implement adding maps from files (with rle, preferably)
- Implement controls (to change maps, move start/goal, etc.)
- Clean up unused `#include`s */
@@ -43,23 +44,31 @@ int main(void) {
initialize_colors();
/* FIXME: shitty. sometimes leaves enough space on the right for a bigger map */
- size_t height = LINES/2 - DRAW_MAP_OFFSET_Y,
+ /* size_t height = LINES/2 - DRAW_MAP_OFFSET_Y,
width = COLS/4 - 1;
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};
+ Position fake_goal_position_to_pass_into_draw_map = {width*2-2, height*2-2}; */
+
+ size_t width, height;
+ Position start_pos, end_pos;
+ Map map = file_plaintext_map("maps/test", &width, &height, &start_pos, &end_pos);
+
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);
+ draw_map(map, width, height, offset_x, offset_y, start_pos, end_pos);
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 'n':
+ FIXME: free it before generating a new one
map = rbt_maze_map(width, height, (unsigned int) time(NULL));
break;
+ */
case 'q': endwin(); return 0;
}
}