BIGGERRRRR COMMIT

This commit is contained in:
2026-10-18 11:46:23 -04:00
parent 78e77a0cdc
commit f21b82288c
+66 -20
View File
@@ -325,7 +325,7 @@ void Engine::Initiate()
Mesh* floor = CreateCubeMesh(); Mesh* floor = CreateCubeMesh();
floor->name = "floor"; floor->name = "floor";
floor->meshTexture = blanktex; floor->meshTexture = blanktex;
floor->t.ScaleTo({ 100.0f, 2.0f, 100.0f }); floor->t.ScaleTo({ 80.0f, 2.0f, 40.0f });
floor->t.TranslateTo({ 0.0f, -1.0f, 0.0f }); floor->t.TranslateTo({ 0.0f, -1.0f, 0.0f });
floor->BindToRenderSystem(); floor->BindToRenderSystem();
mainf->AddChild(floor); mainf->AddChild(floor);
@@ -333,18 +333,58 @@ void Engine::Initiate()
floorBody->velocity = false; floorBody->velocity = false;
physicsengine->AddObject(floorBody); physicsengine->AddObject(floorBody);
// Wall: frictionless (player friction is 0 too) so you slide along it // Static map props: axis-aligned blocks (collision is AABB-based, so dome/cones/ramp are
Mesh* wall = CreateCubeMesh(); // built from stacked tiers and stairs). Footprints are recorded so respawns avoid them.
wall->name = "wall"; struct Footprint { float minX, maxX, minZ, maxZ; };
wall->meshTexture = blanktex; std::vector<Footprint> propFootprints;
wall->t.ScaleTo({ 1.0f, 6.0f, 20.0f }); // pos = centre of the block's footprint on the floor; it sits on y = 0 and is `size.y` tall.
wall->t.TranslateTo({ -8.0f, 3.0f, 0.0f }); // Walls are frictionless (player friction is 0 too) so you slide along them.
wall->BindToRenderSystem(); auto AddBlock = [&](const char* name, glm::vec3 pos, glm::vec3 size, bool slippery = false) {
mainf->AddChild(wall); Mesh* m = CreateCubeMesh();
p* wallBody = new p(wall); m->name = name;
wallBody->velocity = false; m->meshTexture = blanktex;
wallBody->friction = 0.0f; m->t.ScaleTo(size);
physicsengine->AddObject(wallBody); m->t.TranslateTo({ pos.x, pos.y + size.y * 0.5f, pos.z });
m->BindToRenderSystem();
mainf->AddChild(m);
p* body = new p(m);
body->velocity = false;
if (slippery) body->friction = 0.0f;
physicsengine->AddObject(body);
propFootprints.push_back({ pos.x - size.x * 0.5f, pos.x + size.x * 0.5f,
pos.z - size.z * 0.5f, pos.z + size.z * 0.5f });
};
// Concentric stack of square tiers, widest at the bottom (stands in for dome / cone)
auto AddTiers = [&](const char* name, glm::vec2 pos, float baseWidth, float tierHeight, int tiers) {
for (int i = 0; i < tiers; ++i) {
const float w = baseWidth * (1.0f - float(i) / float(tiers));
AddBlock(name, { pos.x, tierHeight * i, pos.y }, { w, tierHeight, w });
}
};
// Map is a rectangle: x in [-40, 40], z in [-20, 20]
// Centre dome
AddTiers("dome", { 0.0f, 0.0f }, 18.0f, 1.0f, 5);
// Cones, opposite corners of the dome
AddTiers("cone", { -12.0f, -13.0f }, 6.0f, 1.0f, 5);
AddTiers("cone", { 12.0f, 13.0f }, 6.0f, 1.0f, 5);
// Big cubes either side of the dome
AddBlock("cube", { -24.0f, -2.0f, 0.0f }, { 7.0f, 7.0f, 7.0f });
AddBlock("cube", { 24.0f, 2.0f, 0.0f }, { 7.0f, 7.0f, 7.0f });
// Stairs climbing to a tall back wall (the ramp), back right
AddBlock("stair", { 29.0f, 0.0f, -12.0f }, { 2.5f, 1.0f, 10.0f });
AddBlock("stair", { 31.5f, 0.0f, -12.0f }, { 2.5f, 2.0f, 10.0f });
AddBlock("stair", { 34.0f, 0.0f, -12.0f }, { 2.5f, 3.0f, 10.0f });
AddBlock("wall", { 36.5f, 0.0f, -12.0f }, { 1.0f, 9.0f, 10.0f }, true);
// Stacked boxes, front right
AddBlock("box", { 30.0f, 0.0f, 12.0f }, { 6.0f, 2.5f, 6.0f });
AddBlock("box", { 34.5f, 0.0f, 15.0f }, { 5.0f, 5.0f, 5.0f });
// Long wall with a small block at its end, left front
AddBlock("wall", { -33.0f, 0.0f, 9.0f }, { 1.0f, 7.0f, 18.0f }, true);
AddBlock("box", { -30.0f, 0.0f, 17.5f }, { 3.0f, 2.0f, 3.0f });
// Small box cluster, back left
AddBlock("box", { -26.0f, 0.0f, -12.0f }, { 6.0f, 2.0f, 6.0f });
AddBlock("box", { -22.0f, 0.0f, -15.5f }, { 6.0f, 1.0f, 4.0f });
// Ground check // Ground check
auto IsGrounded = [&]() -> bool { auto IsGrounded = [&]() -> bool {
@@ -419,8 +459,8 @@ void Engine::Initiate()
// fromNet = another player's blast: we only launch ourselves (the other machines launch // fromNet = another player's blast: we only launch ourselves (the other machines launch
// themselves the same way, since remote players are just puppets on this machine). // themselves the same way, since remote players are just puppets on this machine).
auto Explode = [&](const glm::vec3& center, bool fromNet = false, // (Lambda default arguments can't reference locals, so callers pass radius/power explicitly.)
float radius = shockRadius, float power = shockPower) { auto Explode = [&](const glm::vec3& center, bool fromNet, float radius, float power) {
auto launch = [&](const glm::vec3& pos, p* body) { auto launch = [&](const glm::vec3& pos, p* body) {
const glm::vec3 offset = pos - center; const glm::vec3 offset = pos - center;
const float dist = glm::length(offset); const float dist = glm::length(offset);
@@ -469,13 +509,19 @@ void Engine::Initiate()
const int punchDamage = 25; const int punchDamage = 25;
const float headFraction = 0.8f; const float headFraction = 0.8f;
// Random respawn spot on the floor (NPC and player), kept out of the wall (x -9.5..-6.5, z -11..11) // Random respawn spot on the floor (NPC and player), kept clear of every map prop
std::mt19937 respawnRng(std::random_device{}()); std::mt19937 respawnRng(std::random_device{}());
auto RandomSpawn = [&]() -> glm::vec3 { auto RandomSpawn = [&]() -> glm::vec3 {
std::uniform_real_distribution<float> spread(-20.0f, 20.0f); std::uniform_real_distribution<float> spreadX(-37.0f, 37.0f), spreadZ(-17.0f, 17.0f);
const float margin = 1.5f;
for (;;) { for (;;) {
const float x = spread(respawnRng), z = spread(respawnRng); const float x = spreadX(respawnRng), z = spreadZ(respawnRng);
if (x > -9.5f && x < -6.5f && z > -11.0f && z < 11.0f) continue; bool blocked = false;
for (const Footprint& f : propFootprints) {
if (x > f.minX - margin && x < f.maxX + margin &&
z > f.minZ - margin && z < f.maxZ + margin) { blocked = true; break; }
}
if (blocked) continue;
return { x, 0.9f, z }; return { x, 0.9f, z };
} }
}; };
@@ -778,7 +824,7 @@ void Engine::Initiate()
if (d <= bestDist) { bestDist = d; bestPoint = hit.value(); found = true; } if (d <= bestDist) { bestDist = d; bestPoint = hit.value(); found = true; }
} }
if (found) Explode(bestPoint); if (found) Explode(bestPoint, false, shockRadius, shockPower);
else if (shockAge >= shockLifetime) { else if (shockAge >= shockLifetime) {
shockActive = false; shockActive = false;
shockMesh->t.TranslateTo(hiddenPos); shockMesh->t.TranslateTo(hiddenPos);