Qubet  1.0
The ultimate QGL addicting videogame!
 All Classes Functions Variables Pages
qubet.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 
67 #ifndef QUBET_H
68 #define QUBET_H
69 
70 #include "menu.h"
71 #include "game.h"
72 #include "audiomanager.h"
73 #include "leveleditor.h"
74 #include <GL/glu.h>
75 
83 class Qubet : public QGLWidget
84 {
85  Q_OBJECT
86 
87 public:
88  // Object Management
89 
99  explicit Qubet(QWidget *parent = 0);
100 
109  ~Qubet();
110 
111 
112 protected:
113  // OpenGL Management
114 
120  GLvoid initializeGL();
121 
127  GLvoid paintGL();
128 
135  GLvoid resizeGL(GLint _width, GLint _height);
136 
142  GLvoid mousePressEvent(QMouseEvent *event);
143 
149  GLvoid mouseReleaseEvent(QMouseEvent *event);
150 
156  GLvoid mouseMoveEvent(QMouseEvent *event);
157 
163  GLvoid wheelEvent(QWheelEvent *event);
164 
170  GLvoid keyPressEvent(QKeyEvent *event);
171 
172 
173 private:
174 
175  // Variables
176 
177  GLint currentView;
178  QString currentText;
179  QMap<GLint,Skin*> skinsList;
180  QMap<GLint,Level*> levelsList;
181  QMap<GLint,GLuint> iconsList;
182  QMap<QString,Skybox*> skyboxesList;
183  QTimer *drawTimer;
190  GLfloat skyboxAngle;
191  QGLShaderProgram *explosionShader;
194  GLint width;
195  GLint height;
197  bool loadDone;
201  // Initialization
202 
206  GLvoid initQubet();
207 
208  // Signal <-> Slot Management
209 
220  GLvoid connectInputEvents(const QObject *receiver);
221 
228  GLvoid connectAudio(const QObject *sender);
229 
233  GLvoid connectMenu();
234 
238  GLvoid connectLevelEditor();
239 
243  GLvoid connectGame();
244 
245 
246  // Picking Management
247 
257  QList<GLuint> getPickedName(GLint mouseX, GLint mouseY);
258 
259 
260  // General Purpose Management
261 
267  GLvoid loadingCompleted();
268 
273  GLvoid errorLoading();
274 
280  GLvoid showMenu(bool showIntro = true);
281 
289  GLvoid closeMenu();
290 
301  GLvoid drawScene(GLboolean simplifyForPicking = false);
302 
303 
304  // Loading Functions
305 
311  GLboolean load();
312 
318  GLboolean loadSkins();
319 
325  GLboolean loadLevels();
326 
332  GLboolean loadAlphabet();
333 
339  GLboolean loadIcons();
340 
346  GLboolean loadSkyboxes();
347 
353  GLboolean loadShader();
354 
355 
356 private slots:
357  // Link to Objects
358 
363  void draw();
364 
371  void playStory(GLint skinId);
372 
380  void playArcade(GLint skinId, GLint levelId);
381 
386  void gameClosed();
387 
394  void showLevelEditor(GLint _levelId);
395 
401  void addLevelToLevelsList(Level *_level);
402 
407  void levelEditorClosed();
408 
420  void setMouseMovementTracking(int mode);
421 
427  void setSkybox(QString skyboxName);
428 
429 
430 signals:
431 
438  void itemClicked(QMouseEvent *event, QList<GLuint> listNames);
439 
445  void mouseReleased(QMouseEvent *event);
446 
453  void mouseMoved(QMouseEvent *event, QList<GLuint> listNames);
454 
460  void wheelScrolled(QWheelEvent *event);
461 
467  void keyPressed(QKeyEvent *event);
468 
474  void enableAudio(bool enabled);
475 
481  void playAmbientMusic(QString filename);
482 
486  void stopAmbientMusic();
487 
493  void playEffect(QString effectName);
494 
495 };
496 
497 #endif // QUBET_H
It is a semi-thread class to manage the audio of Qubet. It can manage an ambientMusic and different e...
Definition: audiomanager.h:37
Alphabet * alphabet
Definition: qubet.h:188
GLboolean loadAlphabet()
Load the alphabet.
Definition: qubet.cpp:541
GLvoid mouseMoveEvent(QMouseEvent *event)
This function is invoked when the player moves the mouse inside the game window.
Definition: qubet.cpp:174
QMap< GLint, Level * > levelsList
Definition: qubet.h:180
Menu class used to show and manage the game menu.
Definition: menu.h:33
void enableAudio(bool enabled)
Signal emitted to enable or disable the audio.
void setSkybox(QString skyboxName)
This slot is invoked to set the Skybox.
Definition: qubet.cpp:748
void mouseMoved(QMouseEvent *event, QList< GLuint > listNames)
Signal emitted when the user moves the mouse.
void playStory(GLint skinId)
This function is a slot linked to the Menu and invoked when the player chooses to play the Story Mode...
Definition: qubet.cpp:649
void wheelScrolled(QWheelEvent *event)
Signal emitted when the user scrolls the wheel of the mouse.
GLvoid mousePressEvent(QMouseEvent *event)
This function is invoked when the player clicks inside the game window.
Definition: qubet.cpp:164
QMap< GLint, Skin * > skinsList
Definition: qubet.h:179
QTimer * drawTimer
Definition: qubet.h:183
void showLevelEditor(GLint _levelId)
This function is a slot linked to the Menu and invoked when the player chooses to enter the Level Edi...
Definition: qubet.cpp:692
This class rapresents an instance of the QGLWidget Qubet. It is the game.
Definition: qubet.h:83
It is the Skybox Class.
Definition: skybox.h:30
Skin * asphaltSkin
Definition: qubet.h:192
void addLevelToLevelsList(Level *_level)
Slot invoked to add a level to the levelList.
Definition: qubet.cpp:713
void stopAmbientMusic()
Signal emitted to stop the current ambient music.
LevelEditor * levelEditor
Definition: qubet.h:186
QMap< QString, Skybox * > skyboxesList
Definition: qubet.h:182
GLfloat skyboxAngle
Definition: qubet.h:190
It is the Skin Class.
Definition: skin.h:30
GLint width
Definition: qubet.h:194
void draw()
This is a duplicated function to call paintGL, but this can be used as a slot.
Definition: qubet.cpp:644
GLint currentNewLevelNumber
Definition: qubet.h:198
GLvoid connectGame()
This function is used to connect all the game slots to their signals.
Definition: qubet.cpp:330
GLboolean loadShader()
Load the Shader.
Definition: qubet.cpp:636
GLvoid paintGL()
Paint the OpenGL scene.
Definition: qubet.cpp:141
void itemClicked(QMouseEvent *event, QList< GLuint > listNames)
Signal emitted when the user clicks on a item.
Game * game
Definition: qubet.h:185
GLvoid connectAudio(const QObject *sender)
This method connects audio signals of the sender to their slots in AudioManager.
Definition: qubet.cpp:301
GLvoid connectInputEvents(const QObject *receiver)
This methos connects mouse and keyboard events to the receiver object to forward user's input to the ...
Definition: qubet.cpp:209
GLvoid resizeGL(GLint _width, GLint _height)
Resize the OpenGL Window.
Definition: qubet.cpp:151
GLvoid initQubet()
It is used after the first show of the qubet window to initialize Qubet.
Definition: qubet.cpp:192
void playEffect(QString effectName)
Signal emitted to play an effect.
GLvoid initializeGL()
Initialize the Qt OpenGL.
Definition: qubet.cpp:99
This the LevelEditor Class.
Definition: leveleditor.h:31
Qubet(QWidget *parent=0)
Create a Qubet object, which is a QGLWidget that contains the game.
Definition: qubet.cpp:23
void playAmbientMusic(QString filename)
Signal emitted to play the ambient music.
Menu * menu
Definition: qubet.h:184
void setMouseMovementTracking(int mode)
This slot is to set the Mouse Move Tracking sensibility. The modes are: 0 - no signal emitted...
Definition: qubet.cpp:731
bool loadDone
Definition: qubet.h:197
GLvoid mouseReleaseEvent(QMouseEvent *event)
This function is invoked when the player releases the mouse click.
Definition: qubet.cpp:169
GLvoid closeMenu()
This function is invoked when the player chooses an option from the Menu, so this is no more necessar...
Definition: qubet.cpp:350
GLboolean loadIcons()
Load the icons.
Definition: qubet.cpp:567
GLvoid keyPressEvent(QKeyEvent *event)
This function is invoked when the player presses a key.
Definition: qubet.cpp:185
QList< GLuint > getPickedName(GLint mouseX, GLint mouseY)
This method returns a list of the names of the foreground item at mouse coordinates (mouseX...
Definition: qubet.cpp:218
GLvoid connectMenu()
This function is used to connect all the menu slots to their signals.
Definition: qubet.cpp:309
void mouseReleased(QMouseEvent *event)
Signal emitted when the user releases the mouse button.
GLint height
Definition: qubet.h:195
QMap< GLint, GLuint > iconsList
Definition: qubet.h:181
void gameClosed()
This function is a slot linked to the Game and invoked when the player chooses to close the current G...
Definition: qubet.cpp:679
GLboolean load()
Load skins, levels and obstacles in Qubet.
Definition: qubet.cpp:403
It is the Game Class.
Definition: game.h:32
void keyPressed(QKeyEvent *event)
Signal emitted when the user presses a key on the keyboard.
This class rapresents a Level of Qubet, with its obstacle. It is able to draw itself simply using the...
Definition: level.h:33
Skybox * skybox
Definition: qubet.h:189
void playArcade(GLint skinId, GLint levelId)
This function is a slot linked to the Menu and invoked when the player chooses to play the Arcade Mod...
Definition: qubet.cpp:664
GLvoid wheelEvent(QWheelEvent *event)
This function is invoked when the player scrolls the wheel of the mouse inside the game window...
Definition: qubet.cpp:180
GLvoid connectLevelEditor()
This function is used to connect all the levelEditor slots to their signals.
Definition: qubet.cpp:320
GLboolean loadSkyboxes()
Load the skyboxes.
Definition: qubet.cpp:600
QGLShaderProgram * explosionShader
Definition: qubet.h:191
GLboolean loadLevels()
Load the levels from the resource file.
Definition: qubet.cpp:490
This class is used to keep a list of Letter (from this the name Alphabet) It provide access to Letter...
Definition: alphabet.h:33
AudioManager * audioManager
Definition: qubet.h:187
GLvoid showMenu(bool showIntro=true)
This function is used to states the paintGL function to show the Menu.
Definition: qubet.cpp:339
GLvoid errorLoading()
This function has to be invoked when something in the loading process goes wrong. ...
Definition: qubet.cpp:296
GLvoid loadingCompleted()
This function has to be invoked when the loading is finished.
Definition: qubet.cpp:290
GLint currentView
Definition: qubet.h:177
~Qubet()
Destroy a Qubet object.
Definition: qubet.cpp:47
void levelEditorClosed()
This function is a slot linked to the LevelEditor and invoked when the player chooses to close the cu...
Definition: qubet.cpp:718
QString currentText
Definition: qubet.h:178
GLint mouseMovedMode
Definition: qubet.h:196
GLvoid drawScene(GLboolean simplifyForPicking=false)
This function is used to draw the scene on the QGLWidget. It is used by PaintGL that calls this and t...
Definition: qubet.cpp:359
GLboolean loadSkins()
Load the skins from the resource file.
Definition: qubet.cpp:430