eco2d/code/game/source/gen/texgen.c

56 lines
1.5 KiB
C
Raw Normal View History

2021-05-12 17:38:11 +00:00
#include "gen/texgen.h"
#include "world/world.h"
2021-05-14 05:39:36 +00:00
#include "texgen_data.c"
2021-07-18 18:30:27 +00:00
#define ZPL_NANO
#include "zpl.h"
static inline
Texture2D LoadImageEco(const char *name) {
2021-07-18 18:30:27 +00:00
static char filename[128];
zpl_snprintf(filename, 128, "art/gen/%s.png", name);
return LoadTexture(filename);
2021-07-18 18:30:27 +00:00
}
Texture2D texgen_build_block(uint32_t biome, uint32_t kind) {
2021-05-12 17:38:11 +00:00
// TODO(zaklaus):
2021-07-18 18:30:27 +00:00
switch (biome) {
case BLOCK_BIOME_DEV: {
switch (kind) {
case BLOCK_KIND_GROUND:{
return LoadImageEco("grass");
}break;
case BLOCK_KIND_DIRT:{
return LoadImageEco("dirt");
}break;
case BLOCK_KIND_WALL:{
return LoadImageEco("asphalt");
}break;
case BLOCK_KIND_HILL_SNOW:
case BLOCK_KIND_HILL:{
return LoadImageEco("rock");
}break;
2021-07-19 08:28:23 +00:00
case BLOCK_KIND_WATER:{
return LoadImageEco("water");
}break;
2021-07-18 18:30:27 +00:00
}
}
}
Image img = GenImageColor(WORLD_BLOCK_SIZE,WORLD_BLOCK_SIZE,ColorFromHSV(biome+kind*30, 0.13f, 0.89f));
Texture2D tex = LoadTextureFromImage(img);
UnloadImage(img);
return tex;
2021-05-12 17:38:11 +00:00
}
Texture2D texgen_build_sprite(asset_id id) {
// TODO(zaklaus):
(void)id;
Image img = GenImageColor(1, 1, RAYWHITE);
Texture2D tex = LoadTextureFromImage(img);
UnloadImage(img);
return tex;
}