16 NULL_PTR_HANDLER_RETURN(arr, ,
"Draw Map Mode",
"In draw_map_mode given array is NULL");
17 CHECK_ARG_RETURN(height <= 0 || width <= 0, ,
"Draw Map Mode",
18 "In draw_map_mode given height or width is zero or negative");
19 CHECK_ARG_RETURN(anchor.dx < 0 || anchor.dy < 0, ,
"Draw Map Mode",
"In draw_map_mode given anchor is negative");
20 CHECK_ARG_RETURN(player_pos.dx < 0 || player_pos.dy < 0 || player_pos.dx >= width || player_pos.dy >= height, ,
21 "Draw Map Mode",
"In draw_map_mode given player position is negative or out of bounds");
24 print_text(anchor.dy, anchor.dx + width / 2 - 7,
"Dungeon Crawl", RED_TEXT_COLORS);
26 for (
int y = 0; y < height; y++) {
27 for (
int x = 0; x < width; x++) {
29 uint64_t channels = 0;
32 if (x == player_pos.dx && y == player_pos.dy) {
34 print_text(y + anchor.dy, x + anchor.dx,
"@", RED_TEXT_COLORS);
39 const int access_idx = x * height + y;
41 switch (arr[access_idx]) {
43 channels = WALL_COLORS;
47 channels = FLOOR_COLORS;
51 channels = START_DOOR_COLORS;
55 channels = EXIT_DOOR_COLORS;
59 channels = KEY_COLORS;
63 channels = LIFE_FOUNTAIN_COLORS;
67 channels = MANA_FOUNTAIN_COLORS;
71 channels = GOBLIN_COLORS;
75 channels = HIDDEN_COLORS;
79 log_msg(ERROR,
"map_mode",
"Unknown tile type: %d", arr[access_idx]);
81 channels = DEFAULT_COLORS;
85 print_text(y + anchor.dy, x + anchor.dx, ch, channels);
void log_msg(const log_level_t level, const char *module, const char *format,...)
Logs a formatted message with a specified log level and module.
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.
void print_text(int y, int x, const char *text, uint64_t ncchannel)
Print text at a specific position.