#ifndef H_MAZE_GAME_GAME #define H_MAZE_GAME_GAME #include #include #include #include "maze.h" enum game_res { GR_MENU, GR_QUIT }; enum signs { RS_NONE, RS_SOLVE, RS_PATH }; struct maze_display { struct point maze_pos; struct point player_pos; struct maze *maze; enum signs **signs; bool display_player_path; }; struct game_state { struct maze_display *display; struct point new_maze_pos; struct point new_player_pos; int steps_taken; bool center; bool win; char cmd_history[100][256]; size_t cmd_count; enum game_res result; }; struct game_state *create_game_state(struct maze *maze); void draw_line_win(); void draw_line_info(int steps_taken, int steps_remaining); int get_command(char prompt, char *command); static inline int is_movable(struct maze_display *display, int x, int y) { return display->maze->map[display->player_pos.x + x][display->player_pos.y + y] == 0; } static inline struct point get_player_center(struct point player_pos) { int width = getmaxx(stdscr); int height = getmaxy(stdscr) - 1; struct point maze_pos; maze_pos.x = (width / 2) - player_pos.x; maze_pos.y = (height / 2) - player_pos.y; return maze_pos; } #endif