diff --git a/headless_dump.txt b/headless_dump.txt index 888c315..70447a7 100644 --- a/headless_dump.txt +++ b/headless_dump.txt @@ -1,10 +1,12 @@ === Verbatim Headless Run: 20 ticks === World: 250x250 -Player start: (125.0, 244.0) -Camera: (85, 232) +Player start: (125.0, 242.0) +Camera: (85, 230) === Tick 0 (initial state) === +30 +31 32 33 34 @@ -13,12 +15,12 @@ Camera: (85, 232) 37 38 39 -40 -41 -42 -43 @@@ """"""""""""" -44""" @@@@ "":::::::::::::""" -45:::""" @@@ """::::::::::::::::::"" +40 @@@@@ +41 @@@@@@ +42 @@@@@@ +43 @@@@@ """"""""""""" +44""" @@@@@ "":::::::::::::""" +45:::""" """::::::::::::::::::"" 46::::::"" "":::::::::::::::::::::::""" 47::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::""""""""" 48:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @@ -28,12 +30,12 @@ Camera: (85, 232) 52???????????????????????????????????????????????????????????????????????????????? 53???????????????????????????????????????????????????????????????????????????????? 54???????????????????????????????????????????????????????????????????????????????? -55???????????????????????????????????????????????????????????????????????????????? -56???????????????????????????????????????????????????????????????????????????????? -Player: "Player hp=100.0/100.0 pos=(125.0,244.0) bodies=10/10 on_fire=false" +Player: "Player hp=100.0/100.0 pos=(125.0,242.0) bodies=27/27 on_fire=false" Entities: 1 === Tick 2 === +30 +31 32 33 34 @@ -42,12 +44,12 @@ Entities: 1 37 38 39 -40 -41 -42 -43 @@@ """"""""""""" -44""" @@@@ "":::::::::::::""" -45:::""" @@@ """::::::::::::::::::"" +40 @@@@@ +41 @@@@@@ +42 @@@@@@ +43 @@@@@ """"""""""""" +44""" @@@@@ "":::::::::::::""" +45:::""" """::::::::::::::::::"" 46::::::"" "":::::::::::::::::::::::""" 47::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::""""""""" 48:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @@ -57,13 +59,13 @@ Entities: 1 52???????????????????????????????????????????????????????????????????????????????? 53???????????????????????????????????????????????????????????????????????????????? 54???????????????????????????????????????????????????????????????????????????????? -55???????????????????????????????????????????????????????????????????????????????? -56???????????????????????????????????????????????????????????????????????????????? -Player: "Player hp=100.0/100.0 pos=(125.0,244.1) bodies=10/10 on_fire=false" +Player: "Player hp=100.0/100.0 pos=(125.0,242.1) bodies=27/27 on_fire=false" Entities: 1 -Alive entities: Player(hp=100, pos=(125.0, 244.11879)) +Alive entities: Player(hp=100, pos=(125.0, 242.11879)) === Tick 4 === +30 +31 32 33 34 @@ -72,12 +74,12 @@ Alive entities: Player(hp=100, pos=(125.0, 244.11879)) 37 38 39 -40 -41 -42 -43 @@@ """"""""""""" -44""" @@@@ "":::::::::::::""" -45:::""" @@@ """::::::::::::::::::"" +40 @@@@@ +41 @@@@@@ +42 @@@@@@ +43 @@@@@ """"""""""""" +44""" @@@@@ "":::::::::::::""" +45:::""" """::::::::::::::::::"" 46::::::"" "":::::::::::::::::::::::""" 47::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::""""""""" 48:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @@ -87,13 +89,42 @@ Alive entities: Player(hp=100, pos=(125.0, 244.11879)) 52???????????????????????????????????????????????????????????????????????????????? 53???????????????????????????????????????????????????????????????????????????????? 54???????????????????????????????????????????????????????????????????????????????? -55???????????????????????????????????????????????????????????????????????????????? -56???????????????????????????????????????????????????????????????????????????????? -Player: "Player hp=100.0/100.0 pos=(125.0,244.4) bodies=10/10 on_fire=false" +Player: "Player hp=100.0/100.0 pos=(125.0,242.4) bodies=27/27 on_fire=false" Entities: 1 -Alive entities: Player(hp=100, pos=(125.0, 244.38817)) +Alive entities: Player(hp=100, pos=(125.0, 242.38817)) === Tick 6 === +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 @@@@@ +41 @@@@@@ +42 @@@@@@ +43 @@@@@ """"""""""""" +44""" @@@@@ "":::::::::::::""" +45:::""" """::::::::::::::::::"" +46::::::"" "":::::::::::::::::::::::""" +47::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::""""""""" +48:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +49################################################################################ +50???????????????????????????????????????????????????????????????????????????????? +51???????????????????????????????????????????????????????????????????????????????? +52???????????????????????????????????????????????????????????????????????????????? +53???????????????????????????????????????????????????????????????????????????????? +54???????????????????????????????????????????????????????????????????????????????? +Player: "Player hp=100.0/100.0 pos=(125.0,242.8) bodies=27/27 on_fire=false" +Entities: 1 +Alive entities: Player(hp=100, pos=(125.0, 242.79922)) + +=== Tick 8 === +31 32 33 34 @@ -103,11 +134,11 @@ Alive entities: Player(hp=100, pos=(125.0, 244.38817)) 38 39 40 -41 -42 -43 @@@ """"""""""""" -44""" @@@@ "":::::::::::::""" -45:::""" @@@ """::::::::::::::::::"" +41 @@@@@ +42 @@@@@@ +43 @@@@@@ """"""""""""" +44""" @@@@@ "":::::::::::::""" +45:::""" @@@@@ """::::::::::::::::::"" 46::::::"" "":::::::::::::::::::::::""" 47::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::""""""""" 48:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @@ -118,42 +149,12 @@ Alive entities: Player(hp=100, pos=(125.0, 244.38817)) 53???????????????????????????????????????????????????????????????????????????????? 54???????????????????????????????????????????????????????????????????????????????? 55???????????????????????????????????????????????????????????????????????????????? -56???????????????????????????????????????????????????????????????????????????????? -Player: "Player hp=100.0/100.0 pos=(125.0,244.8) bodies=10/10 on_fire=false" +Player: "Player hp=100.0/100.0 pos=(125.0,243.3) bodies=27/27 on_fire=false" Entities: 1 -Alive entities: Player(hp=100, pos=(125.0, 244.79922)) - -=== Tick 8 === -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 """"""""""""" -44""" @@@ "":::::::::::::""" -45:::""" @@@@ """::::::::::::::::::"" -46::::::"" @@@ "":::::::::::::::::::::::""" -47::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::""""""""" -48:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -49################################################################################ -50???????????????????????????????????????????????????????????????????????????????? -51???????????????????????????????????????????????????????????????????????????????? -52???????????????????????????????????????????????????????????????????????????????? -53???????????????????????????????????????????????????????????????????????????????? -54???????????????????????????????????????????????????????????????????????????????? -55???????????????????????????????????????????????????????????????????????????????? -56???????????????????????????????????????????????????????????????????????????????? -57???????????????????????????????????????????????????????????????????????????????? -Player: "Player hp=100.0/100.0 pos=(125.0,245.3) bodies=10/10 on_fire=false" -Entities: 1 -Alive entities: Player(hp=100, pos=(125.0, 245.3436)) +Alive entities: Player(hp=100, pos=(125.0, 243.3436)) === Tick 10 === +32 33 34 35 @@ -163,11 +164,11 @@ Alive entities: Player(hp=100, pos=(125.0, 245.3436)) 39 40 41 -42 -43 """"""""""""" -44""" @@@ "":::::::::::::""" -45:::""" @@@@ """::::::::::::::::::"" -46::::::"" @@@ "":::::::::::::::::::::::""" +42 @@@@@ +43 @@@@@@ """"""""""""" +44""" @@@@@@ "":::::::::::::""" +45:::""" @@@@@ """::::::::::::::::::"" +46::::::"" @@@@@"":::::::::::::::::::::::""" 47::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::""""""""" 48:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 49################################################################################ @@ -178,12 +179,12 @@ Alive entities: Player(hp=100, pos=(125.0, 245.3436)) 54???????????????????????????????????????????????????????????????????????????????? 55???????????????????????????????????????????????????????????????????????????????? 56???????????????????????????????????????????????????????????????????????????????? -57???????????????????????????????????????????????????????????????????????????????? -Player: "Player hp=100.0/100.0 pos=(125.0,245.6) bodies=10/10 on_fire=false" +Player: "Player hp=100.0/100.0 pos=(125.0,244.0) bodies=27/27 on_fire=false" Entities: 1 -Alive entities: Player(hp=100, pos=(125.0, 245.55)) +Alive entities: Player(hp=100, pos=(125.0, 244.01338)) === Tick 12 === +32 33 34 35 @@ -193,11 +194,11 @@ Alive entities: Player(hp=100, pos=(125.0, 245.55)) 39 40 41 -42 -43 """"""""""""" -44""" @@@ "":::::::::::::""" -45:::""" @@@@ """::::::::::::::::::"" -46::::::"" @@@ "":::::::::::::::::::::::""" +42 @@@@@ +43 @@@@@@ """"""""""""" +44""" @@@@@@ "":::::::::::::""" +45:::""" @@@@@ """::::::::::::::::::"" +46::::::"" @@@@@"":::::::::::::::::::::::""" 47::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::""""""""" 48:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 49################################################################################ @@ -208,12 +209,12 @@ Alive entities: Player(hp=100, pos=(125.0, 245.55)) 54???????????????????????????????????????????????????????????????????????????????? 55???????????????????????????????????????????????????????????????????????????????? 56???????????????????????????????????????????????????????????????????????????????? -57???????????????????????????????????????????????????????????????????????????????? -Player: "Player hp=100.0/100.0 pos=(125.0,245.6) bodies=10/10 on_fire=false" +Player: "Player hp=100.0/100.0 pos=(125.0,244.5) bodies=27/27 on_fire=false" Entities: 1 -Alive entities: Player(hp=100, pos=(125.0, 245.55)) +Alive entities: Player(hp=100, pos=(125.0, 244.5)) === Tick 14 === +32 33 34 35 @@ -223,12 +224,12 @@ Alive entities: Player(hp=100, pos=(125.0, 245.55)) 39 40 41 -42 -43" """"""""""""" -44:""" @@@ "":::::::::::::""" -45::::""" @@@@ """::::::::::::::::::"" -46:::::::"" @@@ "":::::::::::::::::::::::""" -47:::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::"""""""" +42 @@@@@ +43 @@@@@@ """"""""""""" +44""" @@@@@@ "":::::::::::::""" +45:::""" @@@@@ """::::::::::::::::::"" +46::::::"" @@@@@"":::::::::::::::::::::::""" +47::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::""""""""" 48:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 49################################################################################ 50???????????????????????????????????????????????????????????????????????????????? @@ -238,12 +239,12 @@ Alive entities: Player(hp=100, pos=(125.0, 245.55)) 54???????????????????????????????????????????????????????????????????????????????? 55???????????????????????????????????????????????????????????????????????????????? 56???????????????????????????????????????????????????????????????????????????????? -57???????????????????????????????????????????????????????????????????????????????? -Player: "Player hp=100.0/100.0 pos=(124.6,245.6) bodies=10/10 on_fire=false" +Player: "Player hp=100.0/100.0 pos=(125.0,244.5) bodies=27/27 on_fire=false" Entities: 1 -Alive entities: Player(hp=100, pos=(124.55, 245.55)) +Alive entities: Player(hp=100, pos=(125.0, 244.5)) === Tick 16 === +32 33 34 35 @@ -253,11 +254,11 @@ Alive entities: Player(hp=100, pos=(124.55, 245.55)) 39 40 41 -42 -43" """"""""""""" -44:""" @@@ "":::::::::::::""" -45::::""" @@@@ """::::::::::::::::::"" -46:::::::"" @@@ "":::::::::::::::::::::::""" +42 @@@@@ +43" @@@@@@ """"""""""""" +44:""" @@@@@@ "":::::::::::::""" +45::::""" @@@@@ """::::::::::::::::::"" +46:::::::"" @@@@@ "":::::::::::::::::::::::""" 47:::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::"""""""" 48:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 49################################################################################ @@ -268,12 +269,12 @@ Alive entities: Player(hp=100, pos=(124.55, 245.55)) 54???????????????????????????????????????????????????????????????????????????????? 55???????????????????????????????????????????????????????????????????????????????? 56???????????????????????????????????????????????????????????????????????????????? -57???????????????????????????????????????????????????????????????????????????????? -Player: "Player hp=100.0/100.0 pos=(124.6,245.6) bodies=10/10 on_fire=false" +Player: "Player hp=100.0/100.0 pos=(124.5,244.5) bodies=27/27 on_fire=false" Entities: 1 -Alive entities: Player(hp=100, pos=(124.55, 245.55)) +Alive entities: Player(hp=100, pos=(124.5, 244.5)) === Tick 18 === +32 33 34 35 @@ -283,11 +284,11 @@ Alive entities: Player(hp=100, pos=(124.55, 245.55)) 39 40 41 -42 -43" """"""""""""" -44:""" @@@ "":::::::::::::""" -45::::""" @@@@ """::::::::::::::::::"" -46:::::::"" @@@ "":::::::::::::::::::::::""" +42 @@@@@ +43" @@@@@@ """"""""""""" +44:""" @@@@@@ "":::::::::::::""" +45::::""" @@@@@ """::::::::::::::::::"" +46:::::::"" @@@@@ "":::::::::::::::::::::::""" 47:::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::"""""""" 48:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 49################################################################################ @@ -298,12 +299,12 @@ Alive entities: Player(hp=100, pos=(124.55, 245.55)) 54???????????????????????????????????????????????????????????????????????????????? 55???????????????????????????????????????????????????????????????????????????????? 56???????????????????????????????????????????????????????????????????????????????? -57???????????????????????????????????????????????????????????????????????????????? -Player: "Player hp=100.0/100.0 pos=(124.6,245.6) bodies=10/10 on_fire=false" +Player: "Player hp=100.0/100.0 pos=(124.5,244.5) bodies=27/27 on_fire=false" Entities: 1 -Alive entities: Player(hp=100, pos=(124.55, 245.55)) +Alive entities: Player(hp=100, pos=(124.5, 244.5)) === Tick 20 === +32 33 34 35 @@ -313,11 +314,11 @@ Alive entities: Player(hp=100, pos=(124.55, 245.55)) 39 40 41 -42 -43" """"""""""""" -44:""" @@@ "":::::::::::::""" -45::::""" @@@@ """::::::::::::::::::"" -46:::::::"" @@@ "":::::::::::::::::::::::""" +42 @@@@@ +43" @@@@@@ """"""""""""" +44:""" @@@@@@ "":::::::::::::""" +45::::""" @@@@@ """::::::::::::::::::"" +46:::::::"" @@@@@ "":::::::::::::::::::::::""" 47:::::::::"""""""""""""""""""""""""""""""""""::::::::::::::::::::::::::::"""""""" 48:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 49################################################################################ @@ -328,8 +329,7 @@ Alive entities: Player(hp=100, pos=(124.55, 245.55)) 54???????????????????????????????????????????????????????????????????????????????? 55???????????????????????????????????????????????????????????????????????????????? 56???????????????????????????????????????????????????????????????????????????????? -57???????????????????????????????????????????????????????????????????????????????? -Player: "Player hp=100.0/100.0 pos=(124.6,245.6) bodies=10/10 on_fire=false" +Player: "Player hp=100.0/100.0 pos=(124.5,244.5) bodies=27/27 on_fire=false" Entities: 1 -Alive entities: Player(hp=100, pos=(124.55, 245.55)) +Alive entities: Player(hp=100, pos=(124.5, 244.5)) diff --git a/src/entity/entity.rs b/src/entity/entity.rs index d7a8e10..9ec671e 100644 --- a/src/entity/entity.rs +++ b/src/entity/entity.rs @@ -107,24 +107,27 @@ impl Entity { self.cvx = 0.0; self.cvy = 0.0; - let r = 0.45; + let r = 0.5; let mat = match self.kind { EntityKind::Player => MaterialId::Flesh, EntityKind::Goblin => MaterialId::Flesh, EntityKind::Corpse => MaterialId::Flesh, }; - let layout = [ - (-1.0, -1.0, mat), // 0: top-left - ( 0.0, -1.0, mat), // 1: top-center - ( 1.0, -1.0, mat), // 2: top-right - (-1.0, 0.0, mat), // 3: mid-left - ( 0.0, 0.0, mat), // 4: center - ( 1.0, 0.0, mat), // 5: mid-right - (-1.0, 1.0, mat), // 6: bot-left - ( 0.0, 1.0, mat), // 7: bot-center - ( 1.0, 1.0, mat), // 8: bot-right - ( 2.0, 0.0, mat), // 9: hand + // 5x5 body + 2 arms = 27 bodies + let layout: [(f32, f32, MaterialId); 27] = [ + // Row 0 (top): head + (-2.0, -2.0, mat), (-1.0, -2.0, mat), ( 0.0, -2.0, mat), ( 1.0, -2.0, mat), ( 2.0, -2.0, mat), + // Row 1: shoulders + (-2.0, -1.0, mat), (-1.0, -1.0, mat), ( 0.0, -1.0, mat), ( 1.0, -1.0, mat), ( 2.0, -1.0, mat), + // Row 2: torso + (-2.0, 0.0, mat), (-1.0, 0.0, mat), ( 0.0, 0.0, mat), ( 1.0, 0.0, mat), ( 2.0, 0.0, mat), + // Row 3: hips + (-2.0, 1.0, mat), (-1.0, 1.0, mat), ( 0.0, 1.0, mat), ( 1.0, 1.0, mat), ( 2.0, 1.0, mat), + // Row 4: legs + (-2.0, 2.0, mat), (-1.0, 2.0, mat), ( 0.0, 2.0, mat), ( 1.0, 2.0, mat), ( 2.0, 2.0, mat), + // Arms + ( 3.0, -1.0, mat), ( 3.0, 0.0, mat), ]; for &(ox, oy, m) in &layout { @@ -133,19 +136,23 @@ impl Entity { } let mk = |a: usize, b: usize, len: f32| Constraint::new(a, b, len, 1.0); - self.constraints.push(mk(0, 1, 1.0)); - self.constraints.push(mk(1, 2, 1.0)); - self.constraints.push(mk(3, 4, 1.0)); - self.constraints.push(mk(4, 5, 1.0)); - self.constraints.push(mk(6, 7, 1.0)); - self.constraints.push(mk(7, 8, 1.0)); - self.constraints.push(mk(0, 3, 1.0)); - self.constraints.push(mk(3, 6, 1.0)); - self.constraints.push(mk(1, 4, 1.0)); - self.constraints.push(mk(4, 7, 1.0)); - self.constraints.push(mk(2, 5, 1.0)); - self.constraints.push(mk(5, 8, 1.0)); - self.constraints.push(mk(5, 9, 1.0)); + + // Horizontal connections + for row in 0..5 { + let base = row * 5; + for col in 0..4 { + self.constraints.push(mk(base + col, base + col + 1, 1.0)); + } + } + // Vertical connections + for col in 0..5 { + for row in 0..4 { + self.constraints.push(mk(row * 5 + col, (row + 1) * 5 + col, 1.0)); + } + } + // Arm connections + self.constraints.push(mk(9, 25, 1.0)); + self.constraints.push(mk(25, 26, 1.0)); } pub fn sync_bodies_to_center(&mut self) { diff --git a/src/game.rs b/src/game.rs index 39e8d18..56c259d 100644 --- a/src/game.rs +++ b/src/game.rs @@ -79,7 +79,7 @@ impl Game { break; } } - let cy = (surface_y as f32) - 3.0; + let cy = (surface_y as f32) - 5.0; self.player.spawn_at(&mut self.entities, cx, cy); let (px, py) = self.player.center(&self.entities); @@ -502,7 +502,7 @@ impl Game { break; } } - let spawn_y = surface_y - 3; + let spawn_y = surface_y - 5; if !self.grid.in_bounds(spawn_x, spawn_y) { return; diff --git a/src/render/terminal.rs b/src/render/terminal.rs index 52959cb..3bcf201 100644 --- a/src/render/terminal.rs +++ b/src/render/terminal.rs @@ -31,9 +31,9 @@ impl TerminalRenderer { } fn detect_size(&mut self) -> io::Result<()> { - let (w, h) = term_size().unwrap_or((120, 40)); - self.width = (w as usize).min(250).max(60); - self.height = (h as usize).min(80).max(20); + let (w, h) = term_size().unwrap_or((200, 60)); + self.width = (w as usize).min(250).max(80); + self.height = (h as usize).min(120).max(25); Ok(()) }