kitchen: README + MISSIONS/engine-c keep-drop notes
This commit is contained in:
parent
1d351918da
commit
575d7d29b8
130 changed files with 9817 additions and 1 deletions
29
openkknd2-am-coder/src/ok_map.c
Normal file
29
openkknd2-am-coder/src/ok_map.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include "ok_map.h"
|
||||
#include <string.h>
|
||||
|
||||
static uint32_t rng_u32(uint32_t *s) {
|
||||
*s = *s * 1664525u + 1013904223u;
|
||||
return *s;
|
||||
}
|
||||
|
||||
void ok_map_init(OkWorld *w, uint32_t seed) {
|
||||
memset(w, 0, sizeof(*w));
|
||||
uint32_t s = seed ? seed : 1u;
|
||||
for (int y = 0; y < OK_WORLD_H; y++) {
|
||||
for (int x = 0; x < OK_WORLD_W; x++) {
|
||||
uint32_t r = rng_u32(&s);
|
||||
if ((r % 17u) == 0u) w->tiles[y][x] = OK_TILE_BLOCK;
|
||||
else if ((r % 11u) == 0u) w->tiles[y][x] = OK_TILE_RES;
|
||||
else w->tiles[y][x] = OK_TILE_EMPTY;
|
||||
}
|
||||
}
|
||||
w->tiles[1][1] = OK_TILE_EMPTY;
|
||||
w->tiles[OK_WORLD_H - 2][OK_WORLD_W - 2] = OK_TILE_EMPTY;
|
||||
w->resources_a = 100;
|
||||
w->resources_b = 100;
|
||||
}
|
||||
|
||||
bool ok_map_walkable(const OkWorld *w, int x, int y) {
|
||||
if (x < 0 || y < 0 || x >= OK_WORLD_W || y >= OK_WORLD_H) return false;
|
||||
return w->tiles[y][x] != OK_TILE_BLOCK;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue