Terminus
eventhandler.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Qt>
4 
5 namespace terminus
6 {
7 
8 class Game;
9 
15 {
16 
17  enum InteractionType
18  {
19  MOUSE_MOVEMENT = 1,
20  GYRO_MOVEMENT = 2,
21  NEXT_WAGON_BUTTON = 3,
22  PREV_WAGON_BUTTON = 4,
23  ACTION_BUTTON = 5,
24  LEFT_MOUSE_BUTTON = 6
25  };
26 
27 public:
28  EventHandler(Game *game = nullptr);
29 
33  void buttonInput(int type);
34 
38  void keyInput(Qt::Key key);
39 
43  void moveInput(int type, qreal x, qreal y);
44 
48  void touchInput(qreal oldx, qreal oldy, qreal x, qreal y);
49 
50 protected:
51  void keyPressEvent(Qt::Key key);
52  void mouseMoveEvent(qreal x, qreal y);
53  void gyroMoveEvent(qreal x, qreal y);
54  void switchToNextWagon();
55  void switchToPreviousWagon();
56  void touchChargeFire();
57  void touchFire();
58 
59 protected:
61 };
62 
63 }
EventHandler(Game *game=nullptr)
Definition: eventhandler.cpp:21
void switchToPreviousWagon()
Definition: eventhandler.cpp:161
void mouseMoveEvent(qreal x, qreal y)
Definition: eventhandler.cpp:124
The Game class is the main entry point. It subclasses QQuickItem and handles all communication betwee...
Definition: game.h:36
The EventHandler class receives events (touch, key, mouse, gyroscope, etc.) and triggers actions...
Definition: eventhandler.h:14
void keyPressEvent(Qt::Key key)
Definition: eventhandler.cpp:72
void gyroMoveEvent(qreal x, qreal y)
Definition: eventhandler.cpp:146
void touchFire()
Definition: eventhandler.cpp:166
void keyInput(Qt::Key key)
Handles a key event.
Definition: eventhandler.cpp:43
Definition: eventhandler.cpp:18
void touchInput(qreal oldx, qreal oldy, qreal x, qreal y)
Handles touch input.
Definition: eventhandler.cpp:60
Game * m_game
Definition: eventhandler.h:60
void moveInput(int type, qreal x, qreal y)
Handles mouse and gyroscope movements.
Definition: eventhandler.cpp:48
void switchToNextWagon()
Definition: eventhandler.cpp:156
void buttonInput(int type)
Handles a click on a QML UI button.
Definition: eventhandler.cpp:27