game: map units combat and SDL2 render slice
This commit is contained in:
parent
87d99f7007
commit
4dedf5943b
5 changed files with 228 additions and 0 deletions
19
src/map.c
Normal file
19
src/map.c
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue