]> git.seodisparate.com - LudumDare47_StuckInALoop/commitdiff
Minor changes
authorStephen Seo <seo.disparate@gmail.com>
Sat, 3 Oct 2020 04:03:10 +0000 (13:03 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Sat, 3 Oct 2020 04:03:10 +0000 (13:03 +0900)
src/game.rs
src/scenes/mod.rs

index 188e1096c32c3f05b6fbc64c6b3e93942f642c08..6ff4d41587e0513d237dd5b4f92c774d88b0fce7 100644 (file)
@@ -14,21 +14,21 @@ pub struct Game {
 
 enum GameState {
     GameStart,
-    Opening,
+    MainState,
 }
 
 impl GameState {
     fn get_scene(&self, ctx: &mut Context) -> Box<dyn Scene> {
         match self {
             GameState::GameStart => GameStartScene::new_boxed(ctx),
-            GameState::Opening => GameStartScene::new_boxed(ctx),
+            GameState::MainState => GameStartScene::new_boxed(ctx),
         }
     }
 
     fn get_next_state(&self) -> GameState {
         match self {
-            GameState::GameStart => GameState::Opening,
-            GameState::Opening => GameState::GameStart,
+            GameState::GameStart => GameState::MainState,
+            GameState::MainState => GameState::GameStart,
         }
     }
 }
@@ -64,19 +64,21 @@ impl EventHandler for Game {
 
     fn mouse_button_down_event(
         &mut self,
-        _ctx: &mut Context,
-        _button: MouseButton,
-        _x: f32,
-        _y: f32,
+        ctx: &mut Context,
+        button: MouseButton,
+        x: f32,
+        y: f32,
     ) {
+        self.current_scene.mouse_button_down_event(ctx, button, x, y);
     }
 
     fn key_down_event(
         &mut self,
-        _ctx: &mut Context,
-        _keycode: KeyCode,
-        _keymods: KeyMods,
-        _repeat: bool,
+        ctx: &mut Context,
+        keycode: KeyCode,
+        keymods: KeyMods,
+        repeat: bool,
     ) {
+        self.current_scene.key_down_event(ctx, keycode, keymods, repeat);
     }
 }
index 805b0124f54cad3ca3a9e382923c14b231bae202..378381e2cbe6a6c5b2ab433c48489e6b87a01453 100644 (file)
@@ -5,7 +5,3 @@ use ggez::event::EventHandler;
 pub trait Scene: EventHandler {
     fn finished(&self) -> bool;
 }
-
-pub trait SubEventHandler: Scene {
-    fn next(&mut self);
-}