Unify stage prop layers
This commit is contained in:
@@ -62,11 +62,6 @@ struct StageLayer {
|
||||
std::vector<StageRect> rects;
|
||||
};
|
||||
|
||||
struct WhiteboxProp {
|
||||
frostbite2D::Rect bounds;
|
||||
frostbite2D::Color color;
|
||||
};
|
||||
|
||||
struct LevelDefinition {
|
||||
float worldWidth = 0.0f;
|
||||
float worldHeight = 0.0f;
|
||||
@@ -74,7 +69,6 @@ struct LevelDefinition {
|
||||
frostbite2D::Rect cameraBounds;
|
||||
PlatformWorld collision;
|
||||
std::vector<StageLayer> layers;
|
||||
std::vector<WhiteboxProp> props;
|
||||
std::vector<BattleZoneDefinition> battleZones;
|
||||
};
|
||||
|
||||
|
||||
@@ -100,14 +100,18 @@ LevelDefinition CreateWhiteboxLevel() {
|
||||
{frostbite2D::Rect(3040.0f, 315.0f, 82.0f, 285.0f),
|
||||
frostbite2D::Color(0.26f, 0.30f, 0.34f, 1.0f),
|
||||
StageLayerRole::PropsBack}}},
|
||||
};
|
||||
level.props = {
|
||||
{frostbite2D::Rect(118.0f, 392.0f, 88.0f, 208.0f),
|
||||
frostbite2D::Color(0.26f, 0.30f, 0.34f, 1.0f)},
|
||||
{frostbite2D::Rect(780.0f, 250.0f, 72.0f, 180.0f),
|
||||
frostbite2D::Color(0.26f, 0.30f, 0.34f, 1.0f)},
|
||||
{frostbite2D::Rect(1440.0f, 300.0f, 80.0f, 300.0f),
|
||||
frostbite2D::Color(0.26f, 0.30f, 0.34f, 1.0f)},
|
||||
{"props_front",
|
||||
StageLayerRole::PropsFront,
|
||||
1.0f,
|
||||
{{frostbite2D::Rect(520.0f, 580.0f, 220.0f, 34.0f),
|
||||
frostbite2D::Color(0.14f, 0.17f, 0.18f, 0.90f),
|
||||
StageLayerRole::PropsFront},
|
||||
{frostbite2D::Rect(1510.0f, 570.0f, 280.0f, 42.0f),
|
||||
frostbite2D::Color(0.14f, 0.17f, 0.18f, 0.90f),
|
||||
StageLayerRole::PropsFront},
|
||||
{frostbite2D::Rect(2580.0f, 572.0f, 260.0f, 38.0f),
|
||||
frostbite2D::Color(0.14f, 0.17f, 0.18f, 0.90f),
|
||||
StageLayerRole::PropsFront}}},
|
||||
};
|
||||
level.battleZones = {
|
||||
{"zone_01_intro",
|
||||
|
||||
@@ -52,6 +52,7 @@ bool WhiteboxScene::OnEvent(const frostbite2D::Event& event) {
|
||||
void WhiteboxScene::Render() {
|
||||
stageRenderer_.Render(level_, debugFlags_);
|
||||
frostbite2D::Scene::Render();
|
||||
stageRenderer_.RenderForeground(level_);
|
||||
const frostbite2D::Rect playerBounds =
|
||||
player_ ? player_->GetWorldBounds() : frostbite2D::Rect::Zero();
|
||||
const std::vector<BattleZoneDebugInfo> battleZoneDebug =
|
||||
|
||||
@@ -44,6 +44,9 @@ void StageRenderer::Render(const LevelDefinition& level,
|
||||
const DebugFlags& debugFlags) const {
|
||||
drawBackground(level);
|
||||
for (const StageLayer& layer : level.layers) {
|
||||
if (layer.role == StageLayerRole::PropsFront) {
|
||||
continue;
|
||||
}
|
||||
drawLayer(level, layer);
|
||||
}
|
||||
if (debugFlags.showStageGrid) {
|
||||
@@ -51,6 +54,14 @@ void StageRenderer::Render(const LevelDefinition& level,
|
||||
}
|
||||
}
|
||||
|
||||
void StageRenderer::RenderForeground(const LevelDefinition& level) const {
|
||||
for (const StageLayer& layer : level.layers) {
|
||||
if (layer.role == StageLayerRole::PropsFront) {
|
||||
drawLayer(level, layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StageRenderer::drawBackground(const LevelDefinition& level) const {
|
||||
drawRect(frostbite2D::Rect(level.collision.levelLeft, 0.0f,
|
||||
worldWidthOf(level), config::kVirtualHeight),
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace ns_game {
|
||||
class StageRenderer {
|
||||
public:
|
||||
void Render(const LevelDefinition& level, const DebugFlags& debugFlags) const;
|
||||
void RenderForeground(const LevelDefinition& level) const;
|
||||
|
||||
private:
|
||||
void drawBackground(const LevelDefinition& level) const;
|
||||
|
||||
Reference in New Issue
Block a user