22int player_has_key = 0;
23bool first_function_call =
true;
27 player_pos.dx = player_x;
28 player_pos.dy = player_y;
30 revealed_map[player_pos.dx][player_pos.dy] = FLOOR;
38 int new_x = player_pos.dx;
39 int new_y = player_pos.dy;
41 if (input_event->type == INPUT_QUIT)
return QUIT;
42 if (input_event->type == INPUT_MENU)
return SHOW_MENU;
45 if (input_event->type == INPUT_INVENTORY)
return SHOW_INVENTORY;
46 if (input_event->type == INPUT_STATS)
return SHOW_STATS;
49 switch (input_event->type) {
67 if (new_x >= 0 && new_x < WIDTH && new_y >= 0 && new_y < HEIGHT) {
68 switch (map[new_x][new_y]) {
77 player_pos.dx = new_x;
78 player_pos.dy = new_y;
79 revealed_map[new_x][new_y] = FLOOR;
84 player_pos.dx = new_x;
85 player_pos.dy = new_y;
90 player->current_resources.health = player->max_resources.health;
91 player_pos.dx = new_x;
92 player_pos.dy = new_y;
93 revealed_map[new_x][new_y] = FLOOR;
96 player->current_resources.mana = player->max_resources.mana;
97 player_pos.dx = new_x;
98 player_pos.dy = new_y;
99 revealed_map[new_x][new_y] = FLOOR;
102 player_pos.dx = new_x;
103 player_pos.dy = new_y;
104 map[new_x][new_y] = FLOOR;
105 revealed_map[new_x][new_y] = FLOOR;
108 player_pos.dx = new_x;
109 player_pos.dy = new_y;
117 map_mode_result_t next_state = CONTINUE;
119 if (!first_function_call) {
127 first_function_call =
false;
131 draw_light_on_player((map_tile_t*) map, (map_tile_t*) revealed_map, HEIGHT, WIDTH, player_pos, LIGHT_RADIUS);
132 draw_map_mode((
const map_tile_t*) revealed_map, HEIGHT, WIDTH, map_anchor, player_pos);
140 for (
int y = 0; y < HEIGHT; y++) {
141 for (
int x = 0; x < WIDTH; x++) {
142 revealed_map[x][y] = HIDDEN;
void draw_light_on_player(map_tile_t *arr1, map_tile_t *arr2, int height, int width, vector2d_t player, const int light_radius)
Draws light around the player.
Exposes functions for drawing light on player.
Declares core game states, global database connection, and main game control functions.
Exposes functions for working with the inventory mode.
Exposes functions for the IO-Handler.
Exposes common types and constants for the games map.
map_mode_result_t handle_input(const input_event_t *input_event, character_t *player)
Functions is only exposed for testing purposes.
map_mode_result_t map_mode_update(character_t *player)
Updates the player position based on the player's input and redraws the maze.
void init_map_mode(void)
Initializes the map mode.
vector2d_t get_player_pos()
Get the current player position.
void shutdown_map_mode(void)
Frees any resources associated with the map mode.
void set_player_start_pos(const int player_x, const int player_y)
Sets the starting position of the player.
Defines and manages functions for map exploration, player movement, and map interactions in map mode.
void draw_map_mode(const map_tile_t *arr, const int height, const int width, const vector2d_t anchor, const vector2d_t player_pos)
Draws the map mode UI based on the given parameters.
Exposes functions for outputing to the screen while in the map mode.
bool render_frame(void)
Render the current frame.
void clear_screen(void)
Clear the screen.
Exposes functions for outputting to the console.
2-dimensional vector struct