From 9c06350b0eb8603683b73f3863cd0095b55b4df5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tomas=20Wenstr=C3=B6m?= Date: Sat, 2 Jan 2021 19:35:16 +0100 Subject: [PATCH] Moved app to game --- src/{ => game}/app.rs | 4 ++-- src/game/mod.rs | 1 + src/main.rs | 11 ++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) rename src/{ => game}/app.rs (98%) create mode 100644 src/game/mod.rs diff --git a/src/app.rs b/src/game/app.rs similarity index 98% rename from src/app.rs rename to src/game/app.rs index 3efa791..438f2e7 100644 --- a/src/app.rs +++ b/src/game/app.rs @@ -7,7 +7,7 @@ use sdl2::render::BlendMode; use sdl2::render::Canvas; use sdl2::video::Window; -use {SCREEN_HEIGHT, SCREEN_WIDTH}; +use ::{SCREEN_HEIGHT, SCREEN_WIDTH}; use boll::*; use common::Point2D; use sprites::SpriteManager; @@ -20,7 +20,7 @@ pub struct App { pub canvas: Canvas, pub event_pump: EventPump, pub sprites: SpriteManager, - pub state: Box, + pub state: Box, } impl App { diff --git a/src/game/mod.rs b/src/game/mod.rs new file mode 100644 index 0000000..02c0277 --- /dev/null +++ b/src/game/mod.rs @@ -0,0 +1 @@ +pub mod app; \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 4c399c6..18a29b6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,10 +13,10 @@ use sdl2::rect::Rect; use sdl2::video::FullscreenType; use time::PreciseTime; -use app::*; +use game::app::*; use common::Point2D; -mod app; +mod game; #[macro_use] mod common; mod boll; mod sprites; @@ -61,7 +61,12 @@ fn main() { let radius = 110.0 + size as f32 * 0.5; let angle = (mario_angle as f32 - 90.0) * PI / 180.0; let offset2 = point!((angle.cos() * radius) as i32, (angle.sin() * radius) as i32); - app.canvas.copy_ex(app.sprites.get("mario"), None, Rect::new(offset.x + offset2.x, offset.y + offset2.y, size as u32, size as u32), mario_angle, sdl2::rect::Point::new(size / 2, size / 2), false, false).unwrap(); + app.canvas.copy_ex( + app.sprites.get("mario"), + None, Rect::new(offset.x + offset2.x, offset.y + offset2.y, size as u32, size as u32), + mario_angle, + sdl2::rect::Point::new(size / 2, size / 2), + false, false).unwrap(); mario_angle += 1.0; if mario_angle >= 360.0 { mario_angle -= 360.0 } } -- 2.11.0