Moved app to game
authorTomas Wenström <tomas.wenstrom@gmail.com>
Sat, 2 Jan 2021 18:35:16 +0000 (19:35 +0100)
committerTomas Wenström <tomas.wenstrom@gmail.com>
Sat, 2 Jan 2021 18:35:16 +0000 (19:35 +0100)
src/game/app.rs [moved from src/app.rs with 98% similarity]
src/game/mod.rs [new file with mode: 0644]
src/main.rs

similarity index 98%
rename from src/app.rs
rename to src/game/app.rs
index 3efa791..438f2e7 100644 (file)
@@ -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<Window>,
     pub event_pump: EventPump,
     pub sprites: SpriteManager,
-    pub state: Box<AppState>,
+    pub state: Box<dyn AppState>,
 }
 
 impl App {
diff --git a/src/game/mod.rs b/src/game/mod.rs
new file mode 100644 (file)
index 0000000..02c0277
--- /dev/null
@@ -0,0 +1 @@
+pub mod app;
\ No newline at end of file
index 4c399c6..18a29b6 100644 (file)
@@ -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 }
         }