19 lines
531 B
C
19 lines
531 B
C
#include "ok_map.h"
|
|
#include <stdlib.h>
|
|
|
|
void ok_map_generate(OkMap *m) {
|
|
for (int y = 0; y < OK_MAP_H; y++) {
|
|
for (int x = 0; x < OK_MAP_W; x++) {
|
|
m->tile[y][x] = 0;
|
|
if (x == 0 || y == 0 || x == OK_MAP_W - 1 || y == OK_MAP_H - 1)
|
|
m->tile[y][x] = 1;
|
|
else if ((x * 17 + y * 31) % 47 == 0)
|
|
m->tile[y][x] = 2; /* scrap pile */
|
|
}
|
|
}
|
|
}
|
|
|
|
bool ok_map_walkable(const OkMap *m, int x, int y) {
|
|
if (x < 0 || y < 0 || x >= OK_MAP_W || y >= OK_MAP_H) return false;
|
|
return m->tile[y][x] != 1;
|
|
}
|