added mega tree

possible3d
Vladyslav Hrytsenko 2022-10-15 20:44:41 +03:00
parent b8e27c9b0d
commit 76dd148671
8 changed files with 24 additions and 2 deletions

BIN
art/gen/bigtree.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View File

@ -141,6 +141,7 @@ static debug_item items[] = {
{ .kind = DITEM_BUTTON, .name = "spawn chest", .on_click = ActSpawnChest }, { .kind = DITEM_BUTTON, .name = "spawn chest", .on_click = ActSpawnChest },
{ .kind = DITEM_BUTTON, .name = "spawn belt", .on_click = ActSpawnBelt }, { .kind = DITEM_BUTTON, .name = "spawn belt", .on_click = ActSpawnBelt },
{ .kind = DITEM_BUTTON, .name = "spawn furnace", .on_click = ActSpawnFurnace }, { .kind = DITEM_BUTTON, .name = "spawn furnace", .on_click = ActSpawnFurnace },
{ .kind = DITEM_BUTTON, .name = "spawn big tree", .on_click = ActSpawnBigTree },
{ .kind = DITEM_BUTTON, .name = "spawn demo blueprint", .on_click = ActSpawnDemoHouseItem }, { .kind = DITEM_BUTTON, .name = "spawn demo blueprint", .on_click = ActSpawnDemoHouseItem },
{ .kind = DITEM_BUTTON, .name = "spawn random durability icemaker", .on_click = ActSpawnDurabilityTest }, { .kind = DITEM_BUTTON, .name = "spawn random durability icemaker", .on_click = ActSpawnDurabilityTest },
{ {

View File

@ -85,6 +85,17 @@ ActSpawnFurnace(void) {
entity_set_position(e, dest->x, dest->y); entity_set_position(e, dest->x, dest->y);
} }
void
ActSpawnBigTree(void) {
ecs_entity_t e = item_spawn(ASSET_BIG_TREE, 32);
ecs_entity_t plr = camera_get().ent_id;
Position const* origin = ecs_get(world_ecs(), plr, Position);
Position * dest = ecs_get_mut(world_ecs(), e, Position);
*dest = *origin;
entity_set_position(e, dest->x, dest->y);
}
void void
ActSpawnDemoHouseItem(void) { ActSpawnDemoHouseItem(void) {
ecs_entity_t e = item_spawn(ASSET_BLUEPRINT, 1); ecs_entity_t e = item_spawn(ASSET_BLUEPRINT, 1);

View File

@ -21,6 +21,7 @@ Texture2D texgen_build_sprite_fallback(asset_id id) {
case ASSET_BLANK: return GenColorEco(WHITE); break; case ASSET_BLANK: return GenColorEco(WHITE); break;
case ASSET_BUILDMODE_HIGHLIGHT: return GenColorEco(WHITE); break; case ASSET_BUILDMODE_HIGHLIGHT: return GenColorEco(WHITE); break;
case ASSET_BLOCK_FRAME: return GenFrameRect(); break; case ASSET_BLOCK_FRAME: return GenFrameRect(); break;
case ASSET_BIG_TREE: return LoadTexEco("bigtree"); break;
// NOTE(zaklaus): items // NOTE(zaklaus): items
case ASSET_COAL: return LoadTexEco("coal"); case ASSET_COAL: return LoadTexEco("coal");

View File

@ -8,6 +8,7 @@ typedef enum {
ASSET_BLANK, ASSET_BLANK,
ASSET_BLOCK_FRAME, ASSET_BLOCK_FRAME,
ASSET_BUILDMODE_HIGHLIGHT, ASSET_BUILDMODE_HIGHLIGHT,
ASSET_BIG_TREE,
// NOTE(zaklaus): entities // NOTE(zaklaus): entities
ASSET_PLAYER, ASSET_PLAYER,

View File

@ -15,6 +15,8 @@ static asset assets[] = {
ASSET_TEX(ASSET_BLANK), ASSET_TEX(ASSET_BLANK),
ASSET_TEX(ASSET_BLOCK_FRAME), ASSET_TEX(ASSET_BLOCK_FRAME),
ASSET_TEX(ASSET_BUILDMODE_HIGHLIGHT), ASSET_TEX(ASSET_BUILDMODE_HIGHLIGHT),
ASSET_TEX(ASSET_BIG_TREE),
ASSET_TEX(ASSET_COAL), ASSET_TEX(ASSET_COAL),
ASSET_TEX(ASSET_CHEST), ASSET_TEX(ASSET_CHEST),
ASSET_TEX(ASSET_FURNACE), ASSET_TEX(ASSET_FURNACE),

View File

@ -23,4 +23,5 @@ static item_desc items[] = {
ITEM_ENT(ASSET_CHEST, 32, ASSET_CHEST), ITEM_ENT(ASSET_CHEST, 32, ASSET_CHEST),
ITEM_ENT(ASSET_FURNACE, 32, ASSET_FURNACE), ITEM_ENT(ASSET_FURNACE, 32, ASSET_FURNACE),
ITEM_ENT(ASSET_BIG_TREE, 32, ASSET_FURNACE),
}; };

View File

@ -40,6 +40,7 @@ void DEBUG_draw_ground(uint64_t key, entity_view * data) {
tex.texture.height *= (int32_t)scale; tex.texture.height *= (int32_t)scale;
// DrawTextureRec(tex.texture, (Rectangle){0, 0, size, -size}, (Vector2){x, y}, ColorAlpha(WHITE, data->tran_time)); // DrawTextureRec(tex.texture, (Rectangle){0, 0, size, -size}, (Vector2){x, y}, ColorAlpha(WHITE, data->tran_time));
DrawCubeTexture(tex.texture, (Vector3){x+half_size, 0.0f, y+half_size}, size, 0.01f, size, WHITE); DrawCubeTexture(tex.texture, (Vector3){x+half_size, 0.0f, y+half_size}, size, 0.01f, size, WHITE);
DrawCubeWires((Vector3){x, 0.f, y}, WORLD_BLOCK_SIZE*view->chunk_size, 66, WORLD_BLOCK_SIZE*view->chunk_size, BLUE);
for (size_t ty = 0; ty < view->chunk_size; ty++) { for (size_t ty = 0; ty < view->chunk_size; ty++) {
for (size_t tx = 0; tx < view->chunk_size; tx++) { for (size_t tx = 0; tx < view->chunk_size; tx++) {
@ -137,6 +138,10 @@ void DEBUG_draw_entities(uint64_t key, entity_view * data) {
// DrawCubeTexture(GetSpriteTexture2D(assets_find(data->asset)), (Vector3){x + half_block_size, 32.0f, y + half_block_size}, 64, 0.01f, 64, WHITE); // DrawCubeTexture(GetSpriteTexture2D(assets_find(data->asset)), (Vector3){x + half_block_size, 32.0f, y + half_block_size}, 64, 0.01f, 64, WHITE);
DrawSpriteTextureEco(GetSpriteTexture2D(assets_find(data->asset)), (Vector3){x + half_block_size, half_block_size/2, y + half_block_size}, 32, 0.01f, 32, WHITE); DrawSpriteTextureEco(GetSpriteTexture2D(assets_find(data->asset)), (Vector3){x + half_block_size, half_block_size/2, y + half_block_size}, 32, 0.01f, 32, WHITE);
if (data->asset == ASSET_BIG_TREE) {
DrawSpriteTextureEco(GetSpriteTexture2D(assets_find(data->asset)), (Vector3){x + half_block_size, 150, y + half_block_size}, 300, 0.01f, 300, WHITE);
}
if (data->quantity > 1) { if (data->quantity > 1) {
DrawTextEco(zpl_bprintf("%d", data->quantity), x, y, 10, ALPHA(RAYWHITE), 0.0f); DrawTextEco(zpl_bprintf("%d", data->quantity), x, y, 10, ALPHA(RAYWHITE), 0.0f);
} }
@ -150,7 +155,7 @@ void DEBUG_draw_entities(uint64_t key, entity_view * data) {
float x = data->x - 32.f; float x = data->x - 32.f;
float y = data->y - 32.f; float y = data->y - 32.f;
// DrawTexturePro(GetSpriteTexture2D(assets_find(data->asset)), ASSET_SRC_RECT(), ASSET_DST_RECT(x,y), (Vector2){0.5f,0.5f}, 0.0f, ALPHA(WHITE)); // DrawTexturePro(GetSpriteTexture2D(assets_find(data->asset)), ASSET_SRC_RECT(), ASSET_DST_RECT(x,y), (Vector2){0.5f,0.5f}, 0.0f, ALPHA(WHITE));
DrawSpriteTextureEco(GetSpriteTexture2D(assets_find(data->asset)), (Vector3){x + half_block_size, half_block_size/2, y + half_block_size}, 64, 0.01f, 64, WHITE); DrawSpriteTextureEco(GetSpriteTexture2D(assets_find(data->asset)), (Vector3){x + half_block_size, 32, y + half_block_size}, 64, 0.01f, 64, WHITE);
if (data->quantity > 1) { if (data->quantity > 1) {
DrawTextEco(zpl_bprintf("%d", data->quantity), x, y, 10, ALPHA(RAYWHITE), 0.0f); DrawTextEco(zpl_bprintf("%d", data->quantity), x, y, 10, ALPHA(RAYWHITE), 0.0f);
@ -239,7 +244,7 @@ void renderer_init(void) {
// render_camera.rotation = 0.0f; // render_camera.rotation = 0.0f;
// render_camera.zoom = 2.9f; // render_camera.zoom = 2.9f;
render_camera.up = (Vector3){0.0f,0.0f,-1.0f}; render_camera.up = (Vector3){0.0f,1.0f,0.0f};
render_camera.fovy = 45.f; render_camera.fovy = 45.f;
render_camera.projection = CAMERA_PERSPECTIVE; render_camera.projection = CAMERA_PERSPECTIVE;