93 lines
1.8 KiB
C
93 lines
1.8 KiB
C
#include "map.h"
|
|
#include "lzy.h"
|
|
#include "cfg.h"
|
|
#include "nuancierdesaut.h"
|
|
#include "trailblazer.h"
|
|
#include "weallstartsomewhere.h"
|
|
#include "wakywakysnakysnake.h"
|
|
#include "idkwymmdr.h"
|
|
#include <stddef.h>
|
|
#include <string.h>
|
|
|
|
#define LOL(x) (unsigned char *)(x)
|
|
unsigned char *maps[] = {
|
|
map_nuancierdesaut_json.data, LOL("nuancier de saut"),
|
|
map_trailblazer_json.data, LOL("trailblazer"),
|
|
map_weallstartsomewhere_json.data, LOL("we all start somewhere"),
|
|
map_wakywakysnakysnake_json.data, LOL("waky waky snaky snake"),
|
|
map_idkwymmdr_json.data, LOL("idk wym mdr"),
|
|
NULL
|
|
};
|
|
unsigned int map_id = 0;
|
|
|
|
void
|
|
map_next(void)
|
|
{
|
|
if (maps[map_id + 2] != NULL)
|
|
map_id += 2;
|
|
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][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) LZY_DrawRect(x, y, 1, TSIZE);
|
|
if (!right) LZY_DrawRect(x + TSIZE - 1, y, 1, TSIZE);
|
|
if (!up) LZY_DrawRect(x, y, TSIZE, 1);
|
|
if (!down) LZY_DrawRect(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 = (char *)maps[1 + map_id];
|
|
const int x = (DISPLAY_WIDTH - CHR_WIDTH * strlen(s)) / 2;
|
|
const int y = (DISPLAY_HEIGHT - CHR_HEIGHT) / 2;
|
|
LZY_DrawText(x, y, s);
|
|
}
|