use constants
This commit is contained in:
1 parent
7a85cf1cab
commit
e9609e3cc4
1 file changed
+9
-5
+9
-5
@@ -1,5 +1,6 @@
|
||||
use crossterm::event::{Event, EventStream, KeyCode, KeyEvent, KeyEventKind, KeyModifiers};
|
||||
use futures::{FutureExt, StreamExt};
|
||||
use tokio::time::{Duration, interval};
|
||||
use rand::random_range;
|
||||
use ratatui::layout::Constraint::Percentage;
|
||||
use ratatui::layout::HorizontalAlignment::Center;
|
||||
@@ -13,7 +14,10 @@ use ratatui::{
|
||||
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]
|
||||
async fn main() -> color_eyre::Result<()> {
|
||||
@@ -95,8 +99,8 @@ impl App {
|
||||
App {
|
||||
running: true,
|
||||
event_stream: EventStream::new(),
|
||||
player: Paddle::new(0.0, 5.0),
|
||||
enemy: Paddle::new(49.0, 5.0),
|
||||
player: Paddle::new(PLAYER_X, PADDLE_Y),
|
||||
enemy: Paddle::new(ENEMY_X, PADDLE_Y),
|
||||
ball: Ball::default(),
|
||||
state: Gamestate::Playing,
|
||||
player_score: 0,
|
||||
@@ -109,8 +113,8 @@ impl App {
|
||||
self.enemy_score = 0;
|
||||
self.state = Gamestate::Playing;
|
||||
|
||||
self.player = Paddle::new(0.0, 5.0);
|
||||
self.enemy = Paddle::new(49.0, 5.0);
|
||||
self.player = Paddle::new(PLAYER_X, PADDLE_Y);
|
||||
self.enemy = Paddle::new(ENEMY_X, PADDLE_Y);
|
||||
self.ball = Ball::default();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user