KeyboardMovement.h 934 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * 2D Game Engine
  3. * KeyboardMovement.h:
  4. * Based on pikuma.com 2D game engine in C++ and Lua course
  5. * Copyright (c) 2021 986-Studio. All rights reserved.
  6. *
  7. * Created by Manoël Trapier on 16/02/2021.
  8. */
  9. #ifndef GAMEENGINE_SOURCE_INCLUDE_SYSTEMS_KEYBOARDMOVEMENT_H
  10. #define GAMEENGINE_SOURCE_INCLUDE_SYSTEMS_KEYBOARDMOVEMENT_H
  11. #include <ECS.h>
  12. #include <Events/KeyPressed.h>
  13. class KeyboardMovementSystem : public System
  14. {
  15. public:
  16. KeyboardMovementSystem()
  17. {
  18. /* No component to register */
  19. }
  20. void subscriptToEvents(std::unique_ptr<EventBus> &eventBus)
  21. {
  22. eventBus->subscribeToEvent<KeyPressedEvent>(this, &KeyboardMovementSystem::onKeyPressed);
  23. }
  24. void onKeyPressed(KeyPressedEvent &event)
  25. {
  26. Logger::Debug("Keyboard: the key '%c' was pressed", event.keyCode);
  27. }
  28. void Update()
  29. {
  30. }
  31. };
  32. #endif /* GAMEENGINE_SOURCE_INCLUDE_SYSTEMS_KEYBOARDMOVEMENT_H */