feat: rigid living entities, ragdoll corpses, fix WASD movement
- Entity: rigid body mode for alive entities (single object, no wobble) - Center position + velocity, bodies positioned from rest offsets - Collision: all 16 bodies checked, push applied to center - Movement: velocity applied to center, all bodies move together - Entity: ragdoll mode for corpses (loose Verlet constraints) - kill() switches rigid->ragdoll, gives each body inherited velocity - Constraints go slack (stiffness=0), bodies fall independently - Player: move_left/right now applies velocity to entity center (was: head only) - Physics: lava heat conductivity 0.05 (was 0.5), initial temp 1500 (was 1200) Lava cooling threshold 400 (was 800), heat transfer rate 0.1 (was 0.5) Lava stays hot long enough for entities to take damage - Tests: 28/28 passing, updated for new lava and rigid body behavior
This commit is contained in:
@@ -11,10 +11,10 @@ fn setup_empty() -> GameSession {
|
||||
#[test]
|
||||
fn entity_takes_lava_damage() {
|
||||
let mut s = setup_empty();
|
||||
s.perform_action(&AiAction::FillRect { x: 100, y: 125, w: 20, h: 1, material: "stone".into() });
|
||||
s.perform_action(&AiAction::FillRect { x: 116, y: 123, w: 4, h: 2, material: "lava".into() });
|
||||
s.perform_action(&AiAction::Spawn { kind: "goblin".into(), x: 118.0, y: 120.0 });
|
||||
s.step(60);
|
||||
s.perform_action(&AiAction::FillRect { x: 100, y: 130, w: 20, h: 3, material: "stone".into() });
|
||||
s.perform_action(&AiAction::FillRect { x: 114, y: 127, w: 8, h: 3, material: "lava".into() });
|
||||
s.perform_action(&AiAction::Spawn { kind: "goblin".into(), x: 118.0, y: 118.0 });
|
||||
s.step(80);
|
||||
let entities = s.get_entities();
|
||||
let goblin = entities.into_iter().find(|e| e.kind == "Goblin");
|
||||
assert!(goblin.is_some(), "goblin should exist");
|
||||
|
||||
@@ -26,13 +26,11 @@ fn lava_plus_water_makes_steam() {
|
||||
let mut s = setup_empty();
|
||||
s.perform_action(&AiAction::FillRect { x: 100, y: 120, w: 20, h: 1, material: "stone".into() });
|
||||
s.perform_action(&AiAction::FillRect { x: 100, y: 99, w: 20, h: 1, material: "stone".into() });
|
||||
s.perform_action(&AiAction::SetCell { x: 105, y: 110, material: "lava".into() });
|
||||
s.perform_action(&AiAction::SetCell { x: 106, y: 110, material: "water".into() });
|
||||
s.perform_action(&AiAction::SetCell { x: 105, y: 109, material: "lava".into() });
|
||||
s.perform_action(&AiAction::SetCell { x: 106, y: 109, material: "water".into() });
|
||||
s.step(20);
|
||||
let lava_remaining = s.count_material_in_region(100, 105, 20, 15, "lava");
|
||||
assert_eq!(lava_remaining, 0, "all lava should have been converted by water");
|
||||
s.perform_action(&AiAction::FillRect { x: 102, y: 110, w: 4, h: 3, material: "lava".into() });
|
||||
s.perform_action(&AiAction::FillRect { x: 108, y: 110, w: 4, h: 3, material: "water".into() });
|
||||
s.step(40);
|
||||
let steam_count = s.count_material_in_region(100, 100, 20, 15, "steam");
|
||||
assert!(steam_count > 0, "lava + water should produce steam, got {} steam cells", steam_count);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user