aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine/app.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/app.cpp')
-rw-r--r--src/engine/app.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/engine/app.cpp b/src/engine/app.cpp
index 64b9f01..d5001c1 100644
--- a/src/engine/app.cpp
+++ b/src/engine/app.cpp
@@ -89,12 +89,14 @@ void App::run() {
// above is sky. Anything that falls into the ground is destroyed.
graph.ground_level = 1.0f;
- // Resolve each material's texture once (nullptr = draw flat colour).
+ // Resolve each material's texture once: prefer BYO Forts art, fall back to
+ // the CC0 placeholder, then to a flat colour (nullptr).
std::vector<SDL_Texture*> mat_tex(graph.materials.size(), nullptr);
for (size_t i = 0; i < graph.materials.size(); i++)
- if (!graph.materials[i].texture.empty())
- mat_tex[i] = renderer.load_texture(graph.materials[i].texture);
- SDL_Texture* ground_tex = renderer.load_texture("data/textures/ground.png");
+ mat_tex[i] = renderer.load_texture_or(graph.materials[i].texture_forts,
+ graph.materials[i].texture);
+ SDL_Texture* ground_tex = renderer.load_texture_or(
+ "forts:environment/midwest/ground/ground1.tga", "data/textures/ground.png");
// Short-lived explosion puffs spawned when debris hits the ground.
struct Explosion { float x, y, life; };
@@ -108,8 +110,16 @@ void App::run() {
if (weapons[i].name == "cannon") cannon_type = (int)i;
if (weapons[i].name == "laser") laser_type = (int)i;
}
- SDL_Texture* turret_tex = renderer.load_texture("data/textures/weapon_turret.png");
- SDL_Texture* shell_tex = renderer.load_texture("data/textures/projectile_laser.png");
+ // Per-weapon turret sprite (BYO Forts art, else CC0 placeholder).
+ std::vector<SDL_Texture*> weapon_tex(weapons.size(), nullptr);
+ for (size_t i = 0; i < weapons.size(); i++)
+ weapon_tex[i] = renderer.load_texture_or(weapons[i].texture_forts,
+ weapons[i].texture);
+ SDL_Texture* shell_tex = nullptr;
+ if (!weapons.empty())
+ shell_tex = renderer.load_texture_or(
+ weapons[cannon_type].projectile_texture_forts,
+ weapons[cannon_type].projectile_texture);
struct Cannon { float x, y, mount, aim, cooldown; int type; };
std::vector<Cannon> cannons;
@@ -127,8 +137,8 @@ void App::run() {
MapData map = load_map(script, "data");
std::vector<SDL_Texture*> dev_tex(device_defs.size(), nullptr);
for (size_t i = 0; i < device_defs.size(); i++)
- if (!device_defs[i].texture.empty())
- dev_tex[i] = renderer.load_texture(device_defs[i].texture);
+ dev_tex[i] = renderer.load_texture_or(device_defs[i].texture_forts,
+ device_defs[i].texture);
SDL_Texture* deposit_tex = renderer.load_texture("data/textures/deposit.png");
struct Device { int def, team; float x, y, hp, max_hp; bool on_deposit; };
@@ -673,8 +683,10 @@ void App::run() {
float bx = c.x + std::cos(c.aim) * bl * 0.5f;
float by = c.y + std::sin(c.aim) * bl * 0.5f;
renderer.draw_box(bx, by, bl * 0.5f, 0.12f, c.aim, 0.30f, 0.30f, 0.34f, 1.0f);
- if (turret_tex) renderer.draw_sprite(c.x, c.y, 0.5f, 0.5f, 0.0f, turret_tex);
- else renderer.draw_box(c.x, c.y, 0.5f, 0.5f, 0.0f, 0.4f, 0.4f, 0.45f, 1.0f);
+ SDL_Texture* wt = (c.type >= 0 && c.type < (int)weapon_tex.size())
+ ? weapon_tex[c.type] : nullptr;
+ if (wt) renderer.draw_sprite(c.x, c.y, 0.5f, 0.5f, 0.0f, wt);
+ else renderer.draw_box(c.x, c.y, 0.5f, 0.5f, 0.0f, 0.4f, 0.4f, 0.45f, 1.0f);
}
// Firing arc of the selected cannon (the cone of allowed directions).