consider non-collision blocks as ground blocks
parent
671445d4a7
commit
2d09fd90cd
|
@ -288,7 +288,13 @@ static void game__world_view_render_push_entry(uint64_t key, entity_view * data)
|
||||||
.blk_id = blk_id,
|
.blk_id = blk_id,
|
||||||
.x = (data->x*size + offset) + (float)tx*WORLD_BLOCK_SIZE + WORLD_BLOCK_SIZE/2,
|
.x = (data->x*size + offset) + (float)tx*WORLD_BLOCK_SIZE + WORLD_BLOCK_SIZE/2,
|
||||||
.y = (data->y*size + offset) + (float)ty*WORLD_BLOCK_SIZE + WORLD_BLOCK_SIZE/2,
|
.y = (data->y*size + offset) + (float)ty*WORLD_BLOCK_SIZE + WORLD_BLOCK_SIZE/2,
|
||||||
|
.cy = (data->y*size + offset) + (float)ty*WORLD_BLOCK_SIZE + WORLD_BLOCK_SIZE/2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!(blocks_get_flags(blk_id) & BLOCK_FLAG_COLLISION)) {
|
||||||
|
entry.cy = ZPL_F32_MIN;
|
||||||
|
}
|
||||||
|
|
||||||
zpl_array_append(render_queue, entry);
|
zpl_array_append(render_queue, entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,6 +307,7 @@ static void game__world_view_render_push_entry(uint64_t key, entity_view * data)
|
||||||
.data = data,
|
.data = data,
|
||||||
.x = data->x,
|
.x = data->x,
|
||||||
.y = data->y,
|
.y = data->y,
|
||||||
|
.cy = data->y,
|
||||||
.blk_id = 0,
|
.blk_id = 0,
|
||||||
};
|
};
|
||||||
zpl_array_append(render_queue, entry);
|
zpl_array_append(render_queue, entry);
|
||||||
|
@ -320,7 +327,7 @@ void game_world_view_render_world(void) {
|
||||||
|
|
||||||
profile(PROF_RENDER_PUSH_AND_SORT_ENTRIES) {
|
profile(PROF_RENDER_PUSH_AND_SORT_ENTRIES) {
|
||||||
game_world_view_active_entity_map(game__world_view_render_push_entry);
|
game_world_view_active_entity_map(game__world_view_render_push_entry);
|
||||||
zpl_sort_array(render_queue, zpl_array_count(render_queue), zpl_f32_cmp(zpl_offset_of(game_world_render_entry, y)));
|
zpl_sort_array(render_queue, zpl_array_count(render_queue), zpl_f32_cmp(zpl_offset_of(game_world_render_entry, cy)));
|
||||||
}
|
}
|
||||||
|
|
||||||
game_world_view_active_entity_map(game__world_view_render_ground);
|
game_world_view_active_entity_map(game__world_view_render_ground);
|
||||||
|
|
|
@ -114,7 +114,7 @@ void buildmode_draw(void) {
|
||||||
|
|
||||||
for (size_t i = 0; i < build_num_placements; i++) {
|
for (size_t i = 0; i < build_num_placements; i++) {
|
||||||
item_placement *it = &build_placements[i];
|
item_placement *it = &build_placements[i];
|
||||||
renderer_draw_single(it->x, it->y, ASSET_BUILDMODE_HIGHLIGHT, ColorAlpha(build_is_deletion_mode ? RED : WHITE, 0.4f));
|
renderer_draw_single(it->x, it->y, !build_is_deletion_mode ? item->kind : ASSET_BUILDMODE_HIGHLIGHT, ColorAlpha(build_is_deletion_mode ? RED : WHITE, 0.4f));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (build_is_in_draw_mode) {
|
if (build_is_in_draw_mode) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ typedef struct {
|
||||||
entity_view *data;
|
entity_view *data;
|
||||||
float x;
|
float x;
|
||||||
float y;
|
float y;
|
||||||
|
float cy;
|
||||||
block_id blk_id;
|
block_id blk_id;
|
||||||
} game_world_render_entry;
|
} game_world_render_entry;
|
||||||
|
|
||||||
|
|
|
@ -250,13 +250,13 @@ void renderer_debug_draw(void) {
|
||||||
EndMode2D();
|
EndMode2D();
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderer_draw_single(float x, float y, asset_id id, Color color) {
|
void renderer_draw_single(float x1, float y1, asset_id id, Color color) {
|
||||||
BeginMode2D(render_camera);
|
BeginMode2D(render_camera);
|
||||||
|
|
||||||
x -= 32.0f;
|
Texture2D tex = GetSpriteTexture2D(assets_find(id));
|
||||||
y -= 32.0f;
|
float x = x1 - tex.width/2;
|
||||||
|
float y = y1 - (tex.height-WORLD_BLOCK_SIZE/2);
|
||||||
DrawTexturePro(GetSpriteTexture2D(assets_find(id)), ASSET_SRC_RECT(), ASSET_DST_RECT(x,y), (Vector2){0.5f,0.5f}, 0.0f, color);
|
DrawTexturePro(tex, ASSET_SRC_RECT_TEX(tex.width, tex.height), ASSET_DST_RECT_TEX(x,y, tex.width, tex.height), (Vector2){0.5f,0.5f}, 0.0f, color);
|
||||||
|
|
||||||
EndMode2D();
|
EndMode2D();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue