Qubet  1.0
The ultimate QGL addicting videogame!
 All Classes Functions Variables Pages
Signals | Public Member Functions | Protected Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
Qubet Class Reference

This class rapresents an instance of the QGLWidget Qubet. It is the game. More...

#include <qubet.h>

Inheritance diagram for Qubet:
Inheritance graph
Collaboration diagram for Qubet:
Collaboration graph

Signals

void itemClicked (QMouseEvent *event, QList< GLuint > listNames)
 Signal emitted when the user clicks on a item. More...
 
void mouseReleased (QMouseEvent *event)
 Signal emitted when the user releases the mouse button. More...
 
void mouseMoved (QMouseEvent *event, QList< GLuint > listNames)
 Signal emitted when the user moves the mouse. More...
 
void wheelScrolled (QWheelEvent *event)
 Signal emitted when the user scrolls the wheel of the mouse. More...
 
void keyPressed (QKeyEvent *event)
 Signal emitted when the user presses a key on the keyboard. More...
 
void enableAudio (bool enabled)
 Signal emitted to enable or disable the audio. More...
 
void playAmbientMusic (QString filename)
 Signal emitted to play the ambient music. More...
 
void stopAmbientMusic ()
 Signal emitted to stop the current ambient music.
 
void playEffect (QString effectName)
 Signal emitted to play an effect. More...
 

Public Member Functions

 Qubet (QWidget *parent=0)
 Create a Qubet object, which is a QGLWidget that contains the game. More...
 
 ~Qubet ()
 Destroy a Qubet object. More...
 

Protected Member Functions

GLvoid initializeGL ()
 Initialize the Qt OpenGL. More...
 
GLvoid paintGL ()
 Paint the OpenGL scene. More...
 
GLvoid resizeGL (GLint _width, GLint _height)
 Resize the OpenGL Window. More...
 
GLvoid mousePressEvent (QMouseEvent *event)
 This function is invoked when the player clicks inside the game window. More...
 
GLvoid mouseReleaseEvent (QMouseEvent *event)
 This function is invoked when the player releases the mouse click. More...
 
GLvoid mouseMoveEvent (QMouseEvent *event)
 This function is invoked when the player moves the mouse inside the game window. More...
 
GLvoid wheelEvent (QWheelEvent *event)
 This function is invoked when the player scrolls the wheel of the mouse inside the game window. More...
 
GLvoid keyPressEvent (QKeyEvent *event)
 This function is invoked when the player presses a key. More...
 

Private Slots

void draw ()
 This is a duplicated function to call paintGL, but this can be used as a slot.
 
void playStory (GLint skinId)
 This function is a slot linked to the Menu and invoked when the player chooses to play the Story Mode. More...
 
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 Mode. More...
 
void gameClosed ()
 This function is a slot linked to the Game and invoked when the player chooses to close the current Game instance.
 
void showLevelEditor (GLint _levelId)
 This function is a slot linked to the Menu and invoked when the player chooses to enter the Level Editor. More...
 
void addLevelToLevelsList (Level *_level)
 Slot invoked to add a level to the levelList. More...
 
void levelEditorClosed ()
 This function is a slot linked to the LevelEditor and invoked when the player chooses to close the current LevelEditor instance.
 
void setMouseMovementTracking (int mode)
 This slot is to set the Mouse Move Tracking sensibility. The modes are: 0 - no signal emitted. 1 - the signal mouseMoved is emitted only when the mouse is moved and one of the mouse buttons are clicked. 2 - the signal mouseMoved is emitted always when the mouse is moved. More...
 
void setSkybox (QString skyboxName)
 This slot is invoked to set the Skybox. More...
 

Private Member Functions

GLvoid initQubet ()
 It is used after the first show of the qubet window to initialize Qubet.
 
GLvoid connectInputEvents (const QObject *receiver)
 This methos connects mouse and keyboard events to the receiver object to forward user's input to the current view. More...
 
GLvoid connectAudio (const QObject *sender)
 This method connects audio signals of the sender to their slots in AudioManager. More...
 
GLvoid connectMenu ()
 This function is used to connect all the menu slots to their signals.
 
GLvoid connectLevelEditor ()
 This function is used to connect all the levelEditor slots to their signals.
 
GLvoid connectGame ()
 This function is used to connect all the game slots to their signals.
 
QList< GLuint > getPickedName (GLint mouseX, GLint mouseY)
 This method returns a list of the names of the foreground item at mouse coordinates (mouseX, mouseY). More...
 
GLvoid loadingCompleted ()
 This function has to be invoked when the loading is finished. More...
 
GLvoid errorLoading ()
 This function has to be invoked when something in the loading process goes wrong.
 
GLvoid showMenu (bool showIntro=true)
 This function is used to states the paintGL function to show the Menu. More...
 
GLvoid closeMenu ()
 This function is invoked when the player chooses an option from the Menu, so this is no more necessary and will be destroyed. More...
 
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 then do the swap of the buffers. You can use this function either to draw the scene in the background buffer or to draw the scene to use the picking and then not to swap buffers. More...
 
GLboolean load ()
 Load skins, levels and obstacles in Qubet. More...
 
GLboolean loadSkins ()
 Load the skins from the resource file. More...
 
GLboolean loadLevels ()
 Load the levels from the resource file. More...
 
GLboolean loadAlphabet ()
 Load the alphabet. More...
 
GLboolean loadIcons ()
 Load the icons. More...
 
GLboolean loadSkyboxes ()
 Load the skyboxes. More...
 
GLboolean loadShader ()
 Load the Shader. More...
 

Private Attributes

GLint currentView
 
QString currentText
 
QMap< GLint, Skin * > skinsList
 
QMap< GLint, Level * > levelsList
 
QMap< GLint, GLuint > iconsList
 
QMap< QString, Skybox * > skyboxesList
 
QTimer * drawTimer
 
Menumenu
 
Gamegame
 
LevelEditorlevelEditor
 
AudioManageraudioManager
 
Alphabetalphabet
 
Skyboxskybox
 
GLfloat skyboxAngle
 
QGLShaderProgram * explosionShader
 
SkinasphaltSkin
 
GLint width
 
GLint height
 
GLint mouseMovedMode
 
bool loadDone
 
GLint currentNewLevelNumber
 

Detailed Description

This class rapresents an instance of the QGLWidget Qubet. It is the game.

Version
1.0
Author
#34

Constructor & Destructor Documentation

Qubet::Qubet ( QWidget *  parent = 0)
explicit

Create a Qubet object, which is a QGLWidget that contains the game.

Postcondition
It also start the loading of game variables and initializes the objects used in the game. To start a new instance of Qubet Game you have only to create this object, it does all for you.
Parameters
parentis a callback variable to the parent of the widget.
Qubet::~Qubet ( )

Destroy a Qubet object.

It will stop rendering, stop the game, safely stop threads and waits for them, so when this function returns you have safely deletes the Qubet instance. This is a syncronous function in order to return only when all operations for the Qubet Widget closure has been terminated.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Function Documentation

void Qubet::addLevelToLevelsList ( Level _level)
privateslot

Slot invoked to add a level to the levelList.

Parameters
_levelis the Level to add.

Here is the caller graph for this function:

GLvoid Qubet::closeMenu ( )
private

This function is invoked when the player chooses an option from the Menu, so this is no more necessary and will be destroyed.

Precondition
Keep in mind that you have to show something else to show on the screen using the currentView variable before to delete the current Menu instance.

Here is the call graph for this function:

Here is the caller graph for this function:

GLvoid Qubet::connectAudio ( const QObject sender)
private

This method connects audio signals of the sender to their slots in AudioManager.

Parameters
senderis the sender const QObject*.

Here is the caller graph for this function:

GLvoid Qubet::connectInputEvents ( const QObject receiver)
private

This methos connects mouse and keyboard events to the receiver object to forward user's input to the current view.

Precondition
You have to create the receiver and the receiver have to reimplement mouse and keyboard slots.
Parameters
receiveris the receiver const QObject*.

Here is the caller graph for this function:

GLvoid Qubet::drawScene ( GLboolean  simplifyForPicking = false)
private

This function is used to draw the scene on the QGLWidget. It is used by PaintGL that calls this and then do the swap of the buffers. You can use this function either to draw the scene in the background buffer or to draw the scene to use the picking and then not to swap buffers.

Parameters
simplifyForPicking[default = false] is used to draw a simplified scene used for the picking function.

Here is the call graph for this function:

Here is the caller graph for this function:

void Qubet::enableAudio ( bool  enabled)
signal

Signal emitted to enable or disable the audio.

Parameters
enabledis the variable that states if the audio is to enable or not.

Here is the caller graph for this function:

QList< GLuint > Qubet::getPickedName ( GLint  mouseX,
GLint  mouseY 
)
private

This method returns a list of the names of the foreground item at mouse coordinates (mouseX, mouseY).

Parameters
mouseXis the mouse coordinate of x.
mouseYis the mouse coordinate of y.
Returns
a list of the names of the item on (mouseX, mouseY).

Here is the call graph for this function:

Here is the caller graph for this function:

GLvoid Qubet::initializeGL ( )
protected

Initialize the Qt OpenGL.

It is used to manage the OpenGL instance.

void Qubet::itemClicked ( QMouseEvent *  event,
QList< GLuint >  listNames 
)
signal

Signal emitted when the user clicks on a item.

Parameters
eventis the QMouseEvent.
listNamesis the QList<GLuint> of item's names.

Here is the caller graph for this function:

void Qubet::keyPressed ( QKeyEvent *  event)
signal

Signal emitted when the user presses a key on the keyboard.

Parameters
eventis the QKeyEvent*.

Here is the caller graph for this function:

GLvoid Qubet::keyPressEvent ( QKeyEvent *  event)
protected

This function is invoked when the player presses a key.

Parameters
eventis the QKeyEvent*.
GLboolean Qubet::load ( )
private

Load skins, levels and obstacles in Qubet.

Returns
true if the load is successful, else false.

Here is the call graph for this function:

Here is the caller graph for this function:

GLboolean Qubet::loadAlphabet ( )
private

Load the alphabet.

Returns
true if load is successful, else false.

Here is the call graph for this function:

Here is the caller graph for this function:

GLboolean Qubet::loadIcons ( )
private

Load the icons.

Returns
true if load is successful, else false.

Here is the caller graph for this function:

GLvoid Qubet::loadingCompleted ( )
private

This function has to be invoked when the loading is finished.

Postcondition
It will show the menu.

Here is the call graph for this function:

Here is the caller graph for this function:

GLboolean Qubet::loadLevels ( )
private

Load the levels from the resource file.

Returns
true if load is successful, else false.

Here is the call graph for this function:

Here is the caller graph for this function:

GLboolean Qubet::loadShader ( )
private

Load the Shader.

Returns
true if load is successful, else false.

Here is the caller graph for this function:

GLboolean Qubet::loadSkins ( )
private

Load the skins from the resource file.

Returns
true if load is successful, else false.

Here is the call graph for this function:

Here is the caller graph for this function:

GLboolean Qubet::loadSkyboxes ( )
private

Load the skyboxes.

Returns
true if load is successful, else false.

Here is the call graph for this function:

Here is the caller graph for this function:

void Qubet::mouseMoved ( QMouseEvent *  event,
QList< GLuint >  listNames 
)
signal

Signal emitted when the user moves the mouse.

Parameters
eventis the QMouseEvent*.
listNamesis the QList<GLuint> of item's names.

Here is the caller graph for this function:

GLvoid Qubet::mouseMoveEvent ( QMouseEvent *  event)
protected

This function is invoked when the player moves the mouse inside the game window.

Parameters
eventis the QMouseEvent*.

Here is the call graph for this function:

GLvoid Qubet::mousePressEvent ( QMouseEvent *  event)
protected

This function is invoked when the player clicks inside the game window.

Parameters
eventis the QMouseEvent*.

Here is the call graph for this function:

void Qubet::mouseReleased ( QMouseEvent *  event)
signal

Signal emitted when the user releases the mouse button.

Parameters
eventis the QMouseEvent*.

Here is the caller graph for this function:

GLvoid Qubet::mouseReleaseEvent ( QMouseEvent *  event)
protected

This function is invoked when the player releases the mouse click.

Parameters
eventis the QMouseEvent*.
GLvoid Qubet::paintGL ( )
protected

Paint the OpenGL scene.

This is the most important function since it draws on the screen the game.

Here is the call graph for this function:

Here is the caller graph for this function:

void Qubet::playAmbientMusic ( QString  filename)
signal

Signal emitted to play the ambient music.

Parameters
filenameis the filename to play.

Here is the caller graph for this function:

void Qubet::playArcade ( GLint  skinId,
GLint  levelId 
)
privateslot

This function is a slot linked to the Menu and invoked when the player chooses to play the Arcade Mode.

Parameters
skinIdIt is the id of the selected skin.
levelIdIt is the id of the selected level.

Here is the call graph for this function:

Here is the caller graph for this function:

void Qubet::playEffect ( QString  effectName)
signal

Signal emitted to play an effect.

Parameters
effectNameis the name of the effect to play.

Here is the caller graph for this function:

void Qubet::playStory ( GLint  skinId)
privateslot

This function is a slot linked to the Menu and invoked when the player chooses to play the Story Mode.

Parameters
skinIdIt is the id of the selected skin.

Here is the call graph for this function:

Here is the caller graph for this function:

GLvoid Qubet::resizeGL ( GLint  _width,
GLint  _height 
)
protected

Resize the OpenGL Window.

Parameters
_widthis the new width of the window.
_heightis the new height of the window.
void Qubet::setMouseMovementTracking ( int  mode)
privateslot

This slot is to set the Mouse Move Tracking sensibility. The modes are: 0 - no signal emitted. 1 - the signal mouseMoved is emitted only when the mouse is moved and one of the mouse buttons are clicked. 2 - the signal mouseMoved is emitted always when the mouse is moved.

Parameters
modeIt is the selected mode.

Here is the caller graph for this function:

void Qubet::setSkybox ( QString  skyboxName)
privateslot

This slot is invoked to set the Skybox.

Parameters
skyboxNameis the name of the Skybox to apply.
void Qubet::showLevelEditor ( GLint  _levelId)
privateslot

This function is a slot linked to the Menu and invoked when the player chooses to enter the Level Editor.

Parameters
_levelIdis the levelId you want to edit.

Here is the call graph for this function:

Here is the caller graph for this function:

GLvoid Qubet::showMenu ( bool  showIntro = true)
private

This function is used to states the paintGL function to show the Menu.

Parameters
showIntrois the variable that states if thw intro has to been showed. [default = true]

Here is the call graph for this function:

Here is the caller graph for this function:

GLvoid Qubet::wheelEvent ( QWheelEvent *  event)
protected

This function is invoked when the player scrolls the wheel of the mouse inside the game window.

Parameters
eventis the QWheelEvent*.
void Qubet::wheelScrolled ( QWheelEvent *  event)
signal

Signal emitted when the user scrolls the wheel of the mouse.

Parameters
eventis the QWheelEvent*.

Here is the caller graph for this function:

Member Data Documentation

Alphabet* Qubet::alphabet
private

It is the current Alphabet.

Skin* Qubet::asphaltSkin
private

It is the asphalt Skin.

AudioManager* Qubet::audioManager
private

It is the AudioManager pointer.

GLint Qubet::currentNewLevelNumber
private

It is the current level value.

QString Qubet::currentText
private

It is the current string showed on the screen.

GLint Qubet::currentView
private

It is used to keep track of the current view (menu, game, leveleditor).

QTimer* Qubet::drawTimer
private

It is the QTimer to re-draw the scene.

QGLShaderProgram* Qubet::explosionShader
private

It is the current explosion Shader.

Game* Qubet::game
private

It is the Game pointer.

GLint Qubet::height
private

It is the current widget height.

QMap<GLint,GLuint> Qubet::iconsList
private

It is the QMap that contains ids of the icons' texture.

LevelEditor* Qubet::levelEditor
private

It is the LevelEditor pointer.

QMap<GLint,Level*> Qubet::levelsList
private

It is the QMap that contains ids and the names of level files.

bool Qubet::loadDone
private

It is the variable that states if the load has already be done.

Menu* Qubet::menu
private

It is the Menu pointer.

GLint Qubet::mouseMovedMode
private

It is the variable that states which mouse mode is enabled. See the documentation of setMouseMovementTracking(int mode) for the available modes.

QMap<GLint,Skin*> Qubet::skinsList
private

It is the QMap that contains ids and skin images.

Skybox* Qubet::skybox
private

It is the current Skybox.

GLfloat Qubet::skyboxAngle
private

It is the Skybox rotation angle.

QMap<QString,Skybox*> Qubet::skyboxesList
private

It is the Qmap that contains the available skyboxes.

GLint Qubet::width
private

It is the current widget width.


The documentation for this class was generated from the following files: