From e41d798efc1b00680b741df36dfc9be810ced857 Mon Sep 17 00:00:00 2001 From: Mathmagician8191 <50558333+Mathmagician8191@users.noreply.github.com> Date: Fri, 13 Sep 2024 18:30:35 +1200 Subject: [PATCH] Fix formatting and colour rendering not working --- enterprise/src/main.rs | 1 + midway/src/main.rs | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/enterprise/src/main.rs b/enterprise/src/main.rs index 5d4c7a1..a5c392e 100644 --- a/enterprise/src/main.rs +++ b/enterprise/src/main.rs @@ -450,6 +450,7 @@ fn handle_midway_connection(stream: TcpStream, tx: &Sender) -> Op fn main() { let viewport = ViewportBuilder::default() + .with_min_inner_size(vec2(480.0, 360.0)) .with_inner_size(vec2(1280.0, 800.0)) .with_resizable(true); let options = NativeOptions { diff --git a/midway/src/main.rs b/midway/src/main.rs index fe7f852..2d6bfe9 100644 --- a/midway/src/main.rs +++ b/midway/src/main.rs @@ -17,7 +17,7 @@ const PORT: u16 = 25565; const TIME_ACCELERATION_FACTOR: f32 = 5.0; const TPS: u32 = 60; -const COLOUR: &str = "f00"; +const COLOUR: &str = "#999"; const MAP_RADIUS: Option = Some(5000.0); const KRAKEN_NAME: &str = "Kraken"; @@ -90,13 +90,13 @@ impl Ship { } fn distance_from_origin(&self) -> f32 { - (self.coords.0.powi(2) + self.coords.1.powi(2)).sqrt() + self.coords.0.hypot(self.coords.1) } fn distance(&self, other: &Self) -> f32 { let x_distance = self.coords.0 - other.coords.0; let y_distance = self.coords.1 - other.coords.1; - (x_distance.powi(2) + y_distance.powi(2)).sqrt() + x_distance.hypot(y_distance) } fn damage(&mut self, amount: f32) { @@ -339,7 +339,8 @@ fn main() { let texture = ship.stats.texture; let size = ship.stats.length; let health = ship.stats.health / ship.stats.mass; - let message = format!("ship {name} {x} {y} {angle} {velocity} {size} {texture} {COLOUR} {health}\n"); + let message = + format!("ship {name} {x} {y} {angle} {velocity} {size} {texture} {COLOUR} {health}\n"); for connection2 in connections.values_mut() { connection2.stream.write_all(message.as_bytes()).ok(); }