Level H Engine
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CannonGame Class Reference

A State that contains and runs the Demo. More...

#include <CannonGame.h>

Inheritance diagram for CannonGame:
Inheritance graph
Collaboration diagram for CannonGame:
Collaboration graph

Public Member Functions

 CannonGame (StateManager *stateManager, SDL_Window *window)
 Constructs the State object. More...
 
 ~CannonGame ()
 Destructs the State object. More...
 
bool input ()
 Handles the State input. More...
 
void update ()
 A function to update the State. More...
 
void draw ()
 A function to draw the State to the screen. More...
 
- Public Member Functions inherited from State
 State (StateManager *stateManager, SDL_Window *window, std::string name)
 Constructs a State object. More...
 
virtual ~State ()
 A virtual destructor for the State object. More...
 
SDL_Window * getWindow ()
 Gets the window. More...
 
std::string getName ()
 Gets the name of the state. More...
 
void destroyState ()
 A function to destroy all data in a state. More...
 

Private Member Functions

Vec3 getNewTargetPos ()
 A function to generate a new postion for the target. More...
 

Private Attributes

std::string backgroundMusicID
 The background music id. More...
 
bool initialLoop
 Initital loop bool. More...
 
Vec3 cannonBallVel
 The sphere velocity. More...
 
float moveSpeed
 The movement speed. More...
 
float timeLeft
 The time left in the game. More...
 
float totalTime
 The total time. More...
 
std::shared_ptr< GameObjectcannon
 A shared pointer to the cannon. More...
 
std::shared_ptr< GameObjectcannonball
 A shared pointer to the cannonball. More...
 
std::shared_ptr< GameObjecttargetBox
 A shared pointer to the target box. More...
 
std::shared_ptr< GameObjecttargetPole
 A shared pointer to the target pole. More...
 
std::shared_ptr< GameObjectaimBalls [20]
 An array of shared pointers to the aiming balls. More...
 
TimeraimTimer
 A timer for the aim balls spawning. More...
 
TimergameTimer
 A timer for the game. More...
 
TimermissTimer
 A timer for respawning the cannonball after a miss. More...
 
bool fire
 A bool for if the cannonball is in the air. More...
 
bool newAimBall
 A bool fo if a new ball should spawn. More...
 
Vec3 targetPoleOffset
 The position offset of the target pole and target box. More...
 
Vec3 ballStartPos
 The initali ball vectors. More...
 
Vec3 ballScale
 
std::string pointSound
 The sound effects. More...
 
std::string noBallSound
 
std::string explosionSound
 
std::string gameUI
 The UI images. More...
 
std::string gameHelp
 
int score
 The player score. More...
 
unsigned int currentLastAimBallIndex
 The index of the last aim ball. More...
 
TextscoreText
 The info text. More...
 
TexttimeText
 

Additional Inherited Members

- Protected Attributes inherited from State
StateManagerstateManager
 A pointer to the state manager. More...
 
SDL_Window * window
 The window to display to. More...
 
std::string name
 The state name. More...
 
bool destroyed
 A boolean for if the state is destroyed. More...
 

Detailed Description

A State that contains and runs the Demo.

Constructor & Destructor Documentation

◆ CannonGame()

CannonGame::CannonGame ( StateManager stateManager,
SDL_Window *  window 
)

Constructs the State object.

Parameters
stateManagerA pointer to the StateManager.
windowA pointer to the window in use.
Here is the call graph for this function:

◆ ~CannonGame()

CannonGame::~CannonGame ( )

Destructs the State object.

Here is the call graph for this function:

Member Function Documentation

◆ draw()

void CannonGame::draw ( )
virtual

A function to draw the State to the screen.

Implements State.

Here is the call graph for this function:

◆ getNewTargetPos()

Vec3 CannonGame::getNewTargetPos ( )
private

A function to generate a new postion for the target.

Here is the caller graph for this function:

◆ input()

bool CannonGame::input ( )
virtual

Handles the State input.

Returns
If false then quit the State.

Implements State.

Here is the call graph for this function:

◆ update()

void CannonGame::update ( )
virtual

A function to update the State.

Implements State.

Here is the call graph for this function:

Member Data Documentation

◆ aimBalls

std::shared_ptr<GameObject> CannonGame::aimBalls[20]
private

An array of shared pointers to the aiming balls.

◆ aimTimer

Timer* CannonGame::aimTimer
private

A timer for the aim balls spawning.

◆ backgroundMusicID

std::string CannonGame::backgroundMusicID
private

The background music id.

◆ ballScale

Vec3 CannonGame::ballScale
private

◆ ballStartPos

Vec3 CannonGame::ballStartPos
private

The initali ball vectors.

◆ cannon

std::shared_ptr<GameObject> CannonGame::cannon
private

A shared pointer to the cannon.

◆ cannonball

std::shared_ptr<GameObject> CannonGame::cannonball
private

A shared pointer to the cannonball.

◆ cannonBallVel

Vec3 CannonGame::cannonBallVel
private

The sphere velocity.

◆ currentLastAimBallIndex

unsigned int CannonGame::currentLastAimBallIndex
private

The index of the last aim ball.

◆ explosionSound

std::string CannonGame::explosionSound
private

◆ fire

bool CannonGame::fire
private

A bool for if the cannonball is in the air.

◆ gameHelp

std::string CannonGame::gameHelp
private

◆ gameTimer

Timer* CannonGame::gameTimer
private

A timer for the game.

◆ gameUI

std::string CannonGame::gameUI
private

The UI images.

◆ initialLoop

bool CannonGame::initialLoop
private

Initital loop bool.

◆ missTimer

Timer* CannonGame::missTimer
private

A timer for respawning the cannonball after a miss.

◆ moveSpeed

float CannonGame::moveSpeed
private

The movement speed.

◆ newAimBall

bool CannonGame::newAimBall
private

A bool fo if a new ball should spawn.

◆ noBallSound

std::string CannonGame::noBallSound
private

◆ pointSound

std::string CannonGame::pointSound
private

The sound effects.

◆ score

int CannonGame::score
private

The player score.

◆ scoreText

Text* CannonGame::scoreText
private

The info text.

◆ targetBox

std::shared_ptr<GameObject> CannonGame::targetBox
private

A shared pointer to the target box.

◆ targetPole

std::shared_ptr<GameObject> CannonGame::targetPole
private

A shared pointer to the target pole.

◆ targetPoleOffset

Vec3 CannonGame::targetPoleOffset
private

The position offset of the target pole and target box.

◆ timeLeft

float CannonGame::timeLeft
private

The time left in the game.

◆ timeText

Text* CannonGame::timeText
private

◆ totalTime

float CannonGame::totalTime
private

The total time.


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