#include "map.h" #include "lzy.h" #include "cfg.h" #include "maps.h" #include #include struct { const Tmj2cMap *map; const char *name; } maps[] = { { &map_nuancierdesaut_tmj, "nuancier de saut" }, { &map_trailblazer_tmj, "trailblazer" }, { &map_weallstartsomewhere_tmj, "deceptive routing" }, { &map_wakywakysnakysnake_tmj, "waky waky snaky snek" }, { &map_fillerepisode_tmj, "filler episode" }, { &map_idkwymmdr_tmj, "idk wym mdr" }, { &map_brulez_tmj, "brulez" }, }; unsigned int map_id = 0; void map_next(void) { if (map_id + 1 < sizeof(maps) / sizeof(maps[0])) map_id += 1; else map_id = 0; } int map_width(void) { return 25; } int map_height(void) { return 14; } int map_get(int x, int y) { if (x < 0 || y < 0 || x >= map_width() || y >= map_height()) return 1; return maps[map_id].map->layers[0].data[x + y * map_width()]; } int map_get_px(int x, int y) { if (x < 0 || y < 0) return 1; return map_get(x / TSIZE, y / TSIZE); } static void draw_outline(int x, int y) { const int left = (map_get(x - 1, y) == 1); const int right = (map_get(x + 1, y) == 1); const int up = (map_get(x, y - 1) == 1); const int down = (map_get(x, y + 1) == 1); x *= TSIZE; y *= TSIZE; if (!left) (void)LZY_FillRect(x, y, 1, TSIZE); if (!right) (void)LZY_FillRect(x + TSIZE - 1, y, 1, TSIZE); if (!up) (void)LZY_FillRect(x, y, TSIZE, 1); if (!down) (void)LZY_FillRect(x, y + TSIZE - 1, TSIZE, 1); } void map_draw(void) { LZY_DrawSetColor(BLACK); for (int y = 0; y < map_height(); y++) for (int x = 0; x < map_width(); x++) if (map_get(x, y) == 1) draw_outline(x, y); } void map_draw_ui(void) { const char *s = maps[map_id].name; const int x = (DISPLAY_WIDTH - CHR_WIDTH * strlen(s)) / 2; const int y = (DISPLAY_HEIGHT - CHR_HEIGHT) / 2; (void)LZY_DrawText(x, y, s); }