Qubet  1.0
The ultimate QGL addicting videogame!
 All Classes Functions Variables Pages
cube.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 CUBE_H
20 #define CUBE_H
21 
22 #include "level.h"
23 #include "skin.h"
24 
31 class Cube : public QObject
32 {
33  Q_OBJECT
34 
35 public:
36 
45  explicit Cube(Level *_level, Skin *_skin, QObject *_parent = 0, QGLShaderProgram *_explosionShader = NULL);
46 
50  ~Cube();
51 
55  void startCube();
56 
60  void stopCube();
61 
68 
74  GLfloat getZ();
75 
81  void setPosition(Vector3f *_position);
82 
86  void jump();
87 
93  bool isMoving();
94 
98  void moveLeft();
99 
103  void moveRight();
104 
111  void draw(GLboolean simplifyForPicking = false);
112 
116  void updatePosition();
117 
118 
119 private:
120 
124  unsigned char state;
125  GLfloat speed;
126  GLfloat gravity;
129  GLfloat scaleFactor;
130  GLfloat jumpStartTime;
131  GLint jumpStep;
132  GLint movingStep;
134  GLint xCell;
136  Vector3f* anglesMatrix[4][4][4];
137  GLint startXCell;
138  bool canMove;
139  QGLShaderProgram *explosionShader;
144  void createNormalsMatrix();
145 
149  void drawExplosion();
150 
154  void explode();
155 
159  void completed();
160 
164  void resetCube();
165 
166 
167 private slots:
168 
172  void collided();
173 
179  void keyPressed(QKeyEvent *event);
180 
181 
182 signals:
183 
187  void levelCompleted();
188 
192  void suicide();
193 
197  void explosionFinished();
198 
202  void hideLevelName();
203 
209  void playEffect(QString effectName);
210 
211 };
212 
213 #endif // CUBE_H
Vector3f * anglesMatrix[4][4][4]
Definition: cube.h:136
void collided()
It is the slot invoked when the Cube collides with an Obstacle.
Definition: cube.cpp:287
QGLShaderProgram * explosionShader
Definition: cube.h:139
void draw(GLboolean simplifyForPicking=false)
Draw the Cube.
Definition: cube.cpp:125
void completed()
Actions to perform when the level is completed.
Definition: cube.cpp:269
GLint xCell
Definition: cube.h:134
GLint jumpStep
Definition: cube.h:131
QObject * parent
Definition: cube.h:122
GLint levelCellsWidth
Definition: cube.h:128
Vector3f * normalsMatrix[4][4][4]
Definition: cube.h:135
void drawExplosion()
this function is called in the draw function in case of explosion.
Definition: cube.cpp:233
GLfloat scaleFactor
Definition: cube.h:129
void jump()
Make the Cube jump.
Definition: cube.cpp:82
GLint explosionStep
Definition: cube.h:133
Skin * skin
Definition: cube.h:121
bool canMove
Definition: cube.h:138
void keyPressed(QKeyEvent *event)
Slot invoked when the user presses a key on the keyboard.
Definition: cube.cpp:296
It is the Skin Class.
Definition: skin.h:30
GLfloat gravity
Definition: cube.h:126
GLint startXCell
Definition: cube.h:137
void stopCube()
Stop the motion of the Cube.
Definition: cube.cpp:62
~Cube()
Safely destroy a Cube object.
Definition: cube.cpp:51
void explosionFinished()
Signal to inform that the explosion has finished.
void levelCompleted()
Signal emitted when the level is completed.
GLfloat speed
Definition: cube.h:125
GLint levelCellsLength
Definition: cube.h:127
void suicide()
Signal emitted when the player "suicide" the Cube.
Vector3f * position
Definition: cube.h:123
Structure that rapresents a Vector of float in a 3-D space.
Definition: vector3f.h:31
GLfloat jumpStartTime
Definition: cube.h:130
This class rapresents the player's Cube.
Definition: cube.h:31
void explode()
Make the Cube explode.
Definition: cube.cpp:264
unsigned char state
Definition: cube.h:124
void createNormalsMatrix()
Generate the normalsMatrix Matrix.
Definition: cube.cpp:211
bool isMoving()
Returns true if the Cube is moving, else false.
Definition: cube.cpp:94
void updatePosition()
Update the position of the Cube.
Definition: cube.cpp:167
void playEffect(QString effectName)
Signal emitted to play an effect.
This class rapresents a Level of Qubet, with its obstacle. It is able to draw itself simply using the...
Definition: level.h:33
void resetCube()
Reset the Level.
Definition: cube.cpp:275
void moveLeft()
Make the Cube move to the Left.
Definition: cube.cpp:99
void startCube()
Start the motion of the Cube;.
Definition: cube.cpp:57
GLint movingStep
Definition: cube.h:132
Vector3f * getPosition()
Returns the position of the Cube.
Definition: cube.cpp:67
void moveRight()
Make the Cube move to the right.
Definition: cube.cpp:112
GLfloat getZ()
Returns the Z of the Cube.
Definition: cube.cpp:72
void setPosition(Vector3f *_position)
Set the position of the Cube.
Definition: cube.cpp:77
void hideLevelName()
Signal to inform to hide the level name.
Cube(Level *_level, Skin *_skin, QObject *_parent=0, QGLShaderProgram *_explosionShader=NULL)
Create a Cube.
Definition: cube.cpp:23