From f798b6317558fd40b5362942a536fb5fc2decc09 Mon Sep 17 00:00:00 2001 From: nicknase27 Date: Tue, 29 Sep 2026 12:26:43 +0200 Subject: [PATCH] add constant bounds --- src/main.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3610da3..ddf2fed 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,6 +19,8 @@ use ratatui::{ const PLAYER_X: f64 = 0.0; const ENEMY_X: f64 = 49.0; const PADDLE_Y: f64 = 5.0; +const X_BOUNDS: (f64, f64) = (0.0, 50.0); +const Y_BOUNDS: (f64, f64) = (0.0, 15.0); #[tokio::main] async fn main() -> color_eyre::Result<()> { @@ -226,8 +228,8 @@ impl App { "PongRS | {} - {}", self.player_score, self.enemy_score ))) - .x_bounds([0.0, 50.0]) - .y_bounds([0.0, 15.0]) + .x_bounds([X_BOUNDS.0, X_BOUNDS.1]) + .y_bounds([Y_BOUNDS.0, Y_BOUNDS.1]) .marker(Marker::Block) .paint(|ctx| { ctx.draw(&Points { @@ -251,15 +253,15 @@ impl App { }); let net = Canvas::default() - .x_bounds([0.0, 50.0]) - .y_bounds([0.0, 15.0]) + .x_bounds([X_BOUNDS.0, X_BOUNDS.1]) + .y_bounds([Y_BOUNDS.0, Y_BOUNDS.1]) .marker(Marker::Dot) .paint(|ctx| { ctx.draw(&Line { - x1: 25.0, - y1: 14.5, - x2: 25.0, - y2: 0.5, + x1: X_BOUNDS.1 / 2.0, + y1: Y_BOUNDS.1 - 0.5, + x2: X_BOUNDS.1 / 2.0, + y2: Y_BOUNDS.0 + 0.5, color: ratatui::style::Color::White, }); });