Qubet  1.0
The ultimate QGL addicting videogame!
 All Classes Functions Variables Pages
positioncontroller.h
1 // Qubet - Copyright (C) 2011
2 // Enrico Bacis
3 // Daniele Ciriello
4 
5 // Qubet 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 // (at your option) 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 POSITIONCONTROLLER_H
20 #define POSITIONCONTROLLER_H
21 
22 #include "cube.h"
23 
31 {
32  Q_OBJECT
33 
34 public:
35 
43  explicit PositionController(Cube *_cube, Level *_level, QObject *_parent = 0);
44 
49 
53  void startChecking();
54 
58  void stopChecking();
59 
60 
61 private:
62 
66  GLint levelLength;
67  GLint levelWidth;
69  QVector<QVector<QVector<bool> > > obstacleCells;
78  Vector3f *positionToCell(Vector3f *position);
79 
83  GLvoid createObstacleCells();
84 
88  void run();
89 
96  bool isInteger(float f);
97 
98 private slots:
99 
103  void checkCollision();
104 
105 signals:
106 
110  void collision();
111 
112 };
113 
114 #endif // POSITIONCONTROLLER_H
QObject * parent
Definition: positioncontroller.h:63
GLint levelWidth
Definition: positioncontroller.h:67
PositionController Class check if the cube has a collision with obstacles.
Definition: positioncontroller.h:30
Vector3f * positionToCell(Vector3f *position)
Returns the cell coordinates from absolute position.
Definition: positioncontroller.cpp:103
~PositionController()
Destroy a PositionController Object.
Definition: positioncontroller.cpp:40
void stopChecking()
Stop checking for collisions.
Definition: positioncontroller.cpp:54
void startChecking()
Start checking for collision.
Definition: positioncontroller.cpp:49
QTimer * checkPositionTimer
Definition: positioncontroller.h:68
QVector< QVector< QVector< bool > > > obstacleCells
Definition: positioncontroller.h:69
void checkCollision()
Check if the cube has a collision with an obstacle.
Definition: positioncontroller.cpp:59
GLint levelLength
Definition: positioncontroller.h:66
void collision()
Signal emitted when the cube has a collision with an obstacle.
Level * level
Definition: positioncontroller.h:65
Structure that rapresents a Vector of float in a 3-D space.
Definition: vector3f.h:31
This class rapresents the player's Cube.
Definition: cube.h:31
GLvoid createObstacleCells()
Create the 3D Matrix of ObstacleCells.
Definition: positioncontroller.cpp:123
void run()
Reimplementation of the run() function of the QThread class.
Definition: positioncontroller.cpp:114
PositionController(Cube *_cube, Level *_level, QObject *_parent=0)
Create a PositionController Objects.
Definition: positioncontroller.cpp:22
This class rapresents a Level of Qubet, with its obstacle. It is able to draw itself simply using the...
Definition: level.h:33
bool isInteger(float f)
Check if a float is an integer.
Definition: positioncontroller.cpp:117
Cube * cube
Definition: positioncontroller.h:64