use constants

This commit is contained in:
nicknase27 committed 2026-09-27 12:51:17 +02:00
1 parent 7a85cf1cab
commit e9609e3cc4
1 file changed
+9 -5
+9 -5
View File
@@ -1,5 +1,6 @@
use crossterm::event::{Event, EventStream, KeyCode, KeyEvent, KeyEventKind, KeyModifiers}; use crossterm::event::{Event, EventStream, KeyCode, KeyEvent, KeyEventKind, KeyModifiers};
use futures::{FutureExt, StreamExt}; use futures::{FutureExt, StreamExt};
use tokio::time::{Duration, interval};
use rand::random_range; use rand::random_range;
use ratatui::layout::Constraint::Percentage; use ratatui::layout::Constraint::Percentage;
use ratatui::layout::HorizontalAlignment::Center; use ratatui::layout::HorizontalAlignment::Center;
@@ -13,7 +14,10 @@ use ratatui::{
widgets::Block, widgets::Block,
}; };
use tokio::time::{Duration, interval}; // Constants
const PLAYER_X: f64 = 0.0;
const ENEMY_X: f64 = 49.0;
const PADDLE_Y: f64 = 5.0;
#[tokio::main] #[tokio::main]
async fn main() -> color_eyre::Result<()> { async fn main() -> color_eyre::Result<()> {
@@ -95,8 +99,8 @@ impl App {
App { App {
running: true, running: true,
event_stream: EventStream::new(), event_stream: EventStream::new(),
player: Paddle::new(0.0, 5.0), player: Paddle::new(PLAYER_X, PADDLE_Y),
enemy: Paddle::new(49.0, 5.0), enemy: Paddle::new(ENEMY_X, PADDLE_Y),
ball: Ball::default(), ball: Ball::default(),
state: Gamestate::Playing, state: Gamestate::Playing,
player_score: 0, player_score: 0,
@@ -109,8 +113,8 @@ impl App {
self.enemy_score = 0; self.enemy_score = 0;
self.state = Gamestate::Playing; self.state = Gamestate::Playing;
self.player = Paddle::new(0.0, 5.0); self.player = Paddle::new(PLAYER_X, PADDLE_Y);
self.enemy = Paddle::new(49.0, 5.0); self.enemy = Paddle::new(ENEMY_X, PADDLE_Y);
self.ball = Ball::default(); self.ball = Ball::default();
} }