eco2d/code/games/minimal/src/texgen.c

77 lines
2.3 KiB
C
Raw Normal View History

2021-05-12 17:38:11 +00:00
#include "gen/texgen.h"
#include "world/world.h"
2021-07-18 18:30:27 +00:00
#include "zpl.h"
static inline
2021-11-04 12:34:15 +00:00
Texture2D LoadTexEco(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
}
2021-11-04 12:34:15 +00:00
static inline
Image LoadImageEco(const char *name) {
static char filename[128];
zpl_snprintf(filename, 128, "art/gen/%s.png", name);
return LoadImage(filename);
}
static inline
Texture2D Image2TexEco(Image image) {
Texture2D tex = LoadTextureFromImage(image);
UnloadImage(image);
return tex;
}
static inline
Texture2D GenColorEco(Color color) {
Image img = GenImageColor(1, 1, color);
return Image2TexEco(img);
}
Texture2D texgen_build_anim(asset_id id, int64_t counter) {
(void)counter;
2021-08-25 21:36:20 +00:00
switch (id) {
2022-09-27 11:58:35 +00:00
case ASSET_WATER: {
Image img = LoadImageEco("water");
ImageColorBrightness(&img, zpl_abs((counter % 64 - 32)*2));
return Image2TexEco(img);
}break;
2022-09-28 18:40:59 +00:00
2021-11-04 12:34:15 +00:00
default: return GenColorEco(PINK); break;
}
}
Texture2D texgen_build_sprite(asset_id id) {
switch (id) {
2022-08-09 14:46:23 +00:00
case ASSET_BLANK: return GenColorEco(WHITE); break;
2021-11-04 12:34:15 +00:00
case ASSET_BUILDMODE_HIGHLIGHT: return GenColorEco(WHITE); break;
2022-09-28 18:40:59 +00:00
2021-11-04 12:34:15 +00:00
// NOTE(zaklaus): items
case ASSET_DEMO_ICEMAKER: return LoadTexEco("demo_icemaker");
2022-09-28 18:40:59 +00:00
2021-11-02 11:49:03 +00:00
// NOTE(zaklaus): blocks
2021-11-04 12:34:15 +00:00
case ASSET_FENCE: return LoadTexEco("fence");
case ASSET_GROUND: return LoadTexEco("grass");
case ASSET_DIRT: return LoadTexEco("dirt");
case ASSET_WALL: return LoadTexEco("asphalt");
2021-11-02 11:49:03 +00:00
case ASSET_HILL_SNOW:
2021-11-04 12:34:15 +00:00
case ASSET_HILL: return LoadTexEco("rock");
case ASSET_LAVA: return LoadTexEco("lava");
case ASSET_WOOD: return LoadTexEco("wood");
case ASSET_TREE: return LoadTexEco("tree");
2022-09-27 11:58:35 +00:00
// case ASSET_WATER: return LoadTexEco("water");
2021-11-02 17:58:55 +00:00
case ASSET_BELT:
2021-11-04 12:34:15 +00:00
case ASSET_BELT_RIGHT: return LoadTexEco("belt_right");
case ASSET_BELT_LEFT: return LoadTexEco("belt_left");
case ASSET_BELT_UP: return LoadTexEco("belt_up");
case ASSET_BELT_DOWN: return LoadTexEco("belt_down");
2022-09-28 18:40:59 +00:00
2022-08-09 15:32:58 +00:00
// NOTE(zaklaus): devices
case ASSET_CHEST: return LoadTexEco("chest");
2022-09-28 18:40:59 +00:00
2021-11-04 12:34:15 +00:00
default: return GenColorEco(PINK); break;
2021-08-25 21:36:20 +00:00
}
2021-05-12 17:38:11 +00:00
}