Browse Source

cargo fmt

Getty Ritter 1 year ago
parent
commit
3e8f222e8c
4 changed files with 33 additions and 61 deletions
  1. 2 6
      carpet/src/lib.rs
  2. 15 27
      ch2/src/main.rs
  3. 15 27
      ch3/src/main.rs
  4. 1 1
      ch5/src/systems.rs

+ 2 - 6
carpet/src/lib.rs

@@ -4,7 +4,7 @@ use ggez::{Context, GameError};
 use specs::WorldExt;
 use std::path::Path;
 
-pub use ggez::input::keyboard::{KeyCode,KeyMods};
+pub use ggez::input::keyboard::{KeyCode, KeyMods};
 
 mod board;
 mod types;
@@ -325,11 +325,7 @@ impl<Idx: Tile + 'static> Game<Idx> {
     }
 
     pub fn run(self) -> ggez::GameResult<()> {
-        let Game {
-            world,
-            ctx,
-            evloop,
-        } = self;
+        let Game { world, ctx, evloop } = self;
         ggez::event::run(ctx, evloop, world)
     }
 

+ 15 - 27
ch2/src/main.rs

@@ -131,33 +131,21 @@ fn main() -> Result<(), GameError> {
             .build();
     }
 
-    game.on_key(
-        (carpet::KeyCode::W, carpet::KeyMods::NONE),
-        |world| {
-            Motion::move_player(world, -1, 0);
-        },
-    );
-
-    game.on_key(
-        (carpet::KeyCode::A, carpet::KeyMods::NONE),
-        |world| {
-            Motion::move_player(world, 0, -1);
-        },
-    );
-
-    game.on_key(
-        (carpet::KeyCode::S, carpet::KeyMods::NONE),
-        |world| {
-            Motion::move_player(world, 1, 0);
-        },
-    );
-
-    game.on_key(
-        (carpet::KeyCode::D, carpet::KeyMods::NONE),
-        |world| {
-            Motion::move_player(world, 0, 1);
-        },
-    );
+    game.on_key((carpet::KeyCode::W, carpet::KeyMods::NONE), |world| {
+        Motion::move_player(world, -1, 0);
+    });
+
+    game.on_key((carpet::KeyCode::A, carpet::KeyMods::NONE), |world| {
+        Motion::move_player(world, 0, -1);
+    });
+
+    game.on_key((carpet::KeyCode::S, carpet::KeyMods::NONE), |world| {
+        Motion::move_player(world, 1, 0);
+    });
+
+    game.on_key((carpet::KeyCode::D, carpet::KeyMods::NONE), |world| {
+        Motion::move_player(world, 0, 1);
+    });
 
     game.run_with_systems(|world| {
         Draw.run_now(&world);

+ 15 - 27
ch3/src/main.rs

@@ -151,33 +151,21 @@ fn main() -> Result<(), GameError> {
         })
         .build();
 
-    game.on_key(
-        (carpet::KeyCode::W, carpet::KeyMods::NONE),
-        |world| {
-            Motion::move_player(world, -1, 0);
-        },
-    );
-
-    game.on_key(
-        (carpet::KeyCode::A, carpet::KeyMods::NONE),
-        |world| {
-            Motion::move_player(world, 0, -1);
-        },
-    );
-
-    game.on_key(
-        (carpet::KeyCode::S, carpet::KeyMods::NONE),
-        |world| {
-            Motion::move_player(world, 1, 0);
-        },
-    );
-
-    game.on_key(
-        (carpet::KeyCode::D, carpet::KeyMods::NONE),
-        |world| {
-            Motion::move_player(world, 0, 1);
-        },
-    );
+    game.on_key((carpet::KeyCode::W, carpet::KeyMods::NONE), |world| {
+        Motion::move_player(world, -1, 0);
+    });
+
+    game.on_key((carpet::KeyCode::A, carpet::KeyMods::NONE), |world| {
+        Motion::move_player(world, 0, -1);
+    });
+
+    game.on_key((carpet::KeyCode::S, carpet::KeyMods::NONE), |world| {
+        Motion::move_player(world, 1, 0);
+    });
+
+    game.on_key((carpet::KeyCode::D, carpet::KeyMods::NONE), |world| {
+        Motion::move_player(world, 0, 1);
+    });
 
     game.run_with_systems(|world| {
         Draw.run_now(&world);

+ 1 - 1
ch5/src/systems.rs

@@ -1,4 +1,4 @@
-use crate::components::{Renderable, Motion};
+use crate::components::{Motion, Renderable};
 use crate::map::Map;
 
 system_impl! {