|
@@ -6,6 +6,7 @@
|
|
|
*
|
|
|
* Created by Manoël Trapier on 09/02/2021.
|
|
|
*/
|
|
|
+
|
|
|
#include <SDL.h>
|
|
|
#include <SDL_image.h>
|
|
|
#include <glm/glm.hpp>
|
|
@@ -29,6 +30,7 @@
|
|
|
#include <Systems/Animation.h>
|
|
|
#include <Systems/Collision.h>
|
|
|
#include <Systems/Damage.h>
|
|
|
+#include <Systems/KeyboardMovement.h>
|
|
|
|
|
|
Game::Game()
|
|
|
{
|
|
@@ -115,6 +117,7 @@ void Game::LoadLevel(int level)
|
|
|
this->registry->addSystem<AnimationSystem>();
|
|
|
this->registry->addSystem<CollisionSystem>();
|
|
|
this->registry->addSystem<DamageSystem>();
|
|
|
+ this->registry->addSystem<KeyboardMovementSystem>();
|
|
|
|
|
|
this->assetStore->addTexture(this->renderer, "tank-image", "assets/images/tank-panther-right.png");
|
|
|
this->assetStore->addTexture(this->renderer, "truck-image", "assets/images/truck-ford-right.png");
|
|
@@ -197,6 +200,7 @@ void Game::Update()
|
|
|
eventBus->reset();
|
|
|
|
|
|
registry->getSystem<DamageSystem>().subscriptToEvents(eventBus);
|
|
|
+ registry->getSystem<KeyboardMovementSystem>().subscriptToEvents(eventBus);
|
|
|
|
|
|
registry->getSystem<MovementSystem>().update(deltaTime);
|
|
|
registry->getSystem<AnimationSystem>().update();
|
|
@@ -222,10 +226,14 @@ void Game::ProcessInput()
|
|
|
{
|
|
|
this->isRunning = false;
|
|
|
}
|
|
|
- if (event.key.keysym.sym == SDLK_d)
|
|
|
+ else if (event.key.keysym.sym == SDLK_d)
|
|
|
{
|
|
|
this->isDebug = !this->isDebug;
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ this->eventBus->emitEvent<KeyPressedEvent>(event.key.keysym.sym);
|
|
|
+ }
|
|
|
break;
|
|
|
|
|
|
|