]> code.bitgloo.com Git - clyne/gamedev2.git/commitdiff
Added jumping support to the player
authorAndy Belle-Isle <drumsetmonkey@gmail.com>
Sat, 7 Sep 2019 05:14:36 +0000 (01:14 -0400)
committerAndy Belle-Isle <drumsetmonkey@gmail.com>
Sat, 7 Sep 2019 05:14:36 +0000 (01:14 -0400)
src/player.cpp

index 5346a242ad815ed51f4c99c33b03a9cc535ebfa2..b9146722e42e841b5daeb22cba9ef309950cf204 100644 (file)
@@ -67,6 +67,13 @@ void PlayerSystem::receive(const KeyDownEvent& kue)
                     el.tryListener("MoveRightPressed",
                                    e.component<Scripted>()->caller);
             });
+        } else if (kue.sym == SDLK_SPACE) {
+            entities.each<EventListener>([&]([[maybe_unused]] entityx::Entity e,
+                                             EventListener& el)
+            {
+                    el.tryListener("JumpKeyPressed",
+                                   e.component<Scripted>()->caller);
+            });
         }
     }
 }
@@ -88,6 +95,13 @@ void PlayerSystem::receive(const KeyUpEvent& kue)
                     el.tryListener("MoveRightReleased",
                                    e.component<Scripted>()->caller);
             });
+        } else if (kue.sym == SDLK_SPACE) {
+            entities.each<EventListener>([&]([[maybe_unused]] entityx::Entity e,
+                                             EventListener& el)
+            {
+                    el.tryListener("JumpKeyReleased",
+                                   e.component<Scripted>()->caller);
+            });
         }
     }
 }