PGE Engine
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
controller.h
1 /*
2  * Platformer Game Engine by Wohlstand, a free platform for game making
3  * Copyright (c) 2015 Vitaly Novichkov <admin@wohlnet.ru>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef CONTROLLER_H
20 #define CONTROLLER_H
21 
22 #include <QVector>
23 #include "control_keys.h"
24 #include "controllable_object.h"
25 #include "controller_key_map.h"
26 
33 {
34 public:
38  Controller();
42  virtual ~Controller();
43 
47  enum commands
48  {
49  key_start=0,
50  key_left,
51  key_right,
52  key_up,
53  key_down,
54  key_run,
55  key_jump,
56  key_altrun,
57  key_altjump,
58  key_drop
59  };
60 
65  static controller_keys noKeys();
66 
71  virtual void setKeyMap(KeyMap map);
72 
76  void resetControls();
77 
81  void sendControls();
82 
87  virtual void update();
88 
94 
100 
103 
104 protected:
107 
108 private:
110  QVector<ControllableObject* > m_objects;
111 };
112 
113 #endif // CONTROLLER_H
void resetControls()
Sends "unpressed" control key states map to every registered controllable object. ...
Definition: controller.cpp:40
static controller_keys noKeys()
Initializes a control key states map with unpressed key states.
Definition: controller.cpp:30
Control key map structure. Contains a "is pressed" states of all available control keys...
Definition: control_keys.h:25
KeyMap kmap
Current control keys map.
Definition: controller.h:106
Controller()
Constructor.
Definition: controller.cpp:22
commands
Control key command codes.
Definition: controller.h:47
virtual void update()
Updates controllable object: read key states from controllable device and apply gotten key states to ...
Definition: controller.cpp:51
Provides controller input interface for a physical objects (for example, playable characters) ...
Definition: controllable_object.h:30
void registerInControl(ControllableObject *obj)
Register controllable object to this controller.
Definition: controller.cpp:53
controller_keys keys
Current state of control keys.
Definition: controller.h:102
virtual ~Controller()
Desctructor.
Definition: controller.cpp:27
The Controller class provides proxy interface between controllable objects array and physical control...
Definition: controller.h:32
void removeFromControl(ControllableObject *obj)
Remove controllable object from this controller.
Definition: controller.cpp:59
Definition: controller_key_map.h:17
virtual void setKeyMap(KeyMap map)
Accepts control keys map which will associates physical keys of control device and command code...
Definition: controller.cpp:35
void sendControls()
Sends current control key states map to every registered controllable object.
Definition: controller.cpp:45