code: small changes

isolation_bkp/dynres
Dominik Madarász 2021-01-14 17:03:10 +01:00
parent d10ae63aa7
commit 553eca86aa
4 changed files with 32 additions and 4 deletions

8
.gitignore vendored
View File

@ -1,2 +1,6 @@
build build
.vscode .vscode
GPATH
GRTAGS
GTAGS

View File

@ -3,12 +3,11 @@
// todo: csv parsing + utils // todo: csv parsing + utils
#define BLOCK_NAMELEN 80
#define BLOCKS_COUNT (sizeof(blocks)/sizeof(block)) #define BLOCKS_COUNT (sizeof(blocks)/sizeof(block))
typedef struct { typedef struct {
uint8_t tex_id; uint8_t tex_id;
char name[BLOCK_NAMELEN]; const char *name;
uint32_t flags; uint32_t flags;
uint32_t kind; uint32_t kind;
uint32_t biome; uint32_t biome;

View File

@ -31,6 +31,26 @@ static void world_fill_rect(uint32_t id, uint32_t x, uint32_t y, uint32_t w, uin
} }
} }
static void world_fill_circle(uint32_t id, uint32_t x, uint32_t y, uint32_t w, uint32_t h, world_block_observer_proc *proc) {
for (uint32_t cy=y; cy<y+h; cy++) {
for (uint32_t cx=x; cx<x+w; cx++) {
if (cx < 0 || cx >= world_width) continue;
if (cy < 0 || cy >= world_height) continue;
uint32_t i = (cy*world_width) + cx;
if (proc) {
uint32_t new_id = (*proc)(id, i);
if (new_id != BLOCK_INVALID) {
id = new_id;
}
else continue;
}
world[i] = id;
}
}
}
static void world_fill_rect_anchor(uint32_t id, uint32_t x, uint32_t y, uint32_t w, uint32_t h, float ax, float ay, world_block_observer_proc *proc) { static void world_fill_rect_anchor(uint32_t id, uint32_t x, uint32_t y, uint32_t w, uint32_t h, float ax, float ay, world_block_observer_proc *proc) {
uint32_t w2 = (uint32_t)floorf(w*ax); uint32_t w2 = (uint32_t)floorf(w*ax);
uint32_t h2 = (uint32_t)floorf(h*ay); uint32_t h2 = (uint32_t)floorf(h*ay);
@ -74,6 +94,10 @@ static WORLD_BLOCK_OBSERVER(shaper_noise33) {
return world_perlin_cond(block_idx, 0.33) ? shaper(id, block_idx) : BLOCK_INVALID; return world_perlin_cond(block_idx, 0.33) ? shaper(id, block_idx) : BLOCK_INVALID;
} }
static void world_fill_mountain(uint32_t x, uint32_t y) {
}
#define RAND_RANGE(x,y) (x + (uint32_t)rand()%(y-(x))) #define RAND_RANGE(x,y) (x + (uint32_t)rand()%(y-(x)))
int32_t world_gen() { int32_t world_gen() {

View File

@ -1,3 +1,4 @@
#pragma once #pragma once
#include <stdint.h> #include <stdint.h>
#include <inttypes.h>