Level H Engine
CannonGame.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include "../State.h"
5 #include "../StateManager.h"
6 #include "../../Maths/Vec3.h"
7 #include "../../Core/GameObject.h"
8 #include "../../Core/Timer.h"
9 #include "../../ResourceManagement/Text.h"
10 
14 class CannonGame : public State
15 {
16 public:
23 
27  ~CannonGame();
28 
33  bool input();
34 
38  void update();
39 
43  void draw();
44 
45 private:
47  std::string backgroundMusicID;
53  float moveSpeed;
55  float timeLeft;
57  float totalTime;
58 
60  std::shared_ptr<GameObject> cannon;
62  std::shared_ptr<GameObject> cannonball;
64  std::shared_ptr<GameObject> targetBox;
66  std::shared_ptr<GameObject> targetPole;
68  std::shared_ptr<GameObject> aimBalls[20];
69 
77  bool fire;
79  bool newAimBall;
85  std::string pointSound;
86  std::string noBallSound;
87  std::string explosionSound;
89  std::string gameUI;
90  std::string gameHelp;
92  int score;
98 
103 };
Creates a Text sprite for use with using the Text formating.
Definition: Text.h:12
int score
The player score.
Definition: CannonGame.h:92
bool initialLoop
Initital loop bool.
Definition: CannonGame.h:49
bool newAimBall
A bool fo if a new ball should spawn.
Definition: CannonGame.h:79
Handles timer functions.
Definition: Timer.h:6
std::string backgroundMusicID
The background music id.
Definition: CannonGame.h:47
Creates a State object to be inherited.
Definition: State.h:13
float timeLeft
The time left in the game.
Definition: CannonGame.h:55
void draw()
A function to draw the State to the screen.
Definition: CannonGame.cpp:410
unsigned int currentLastAimBallIndex
The index of the last aim ball.
Definition: CannonGame.h:94
Timer * aimTimer
A timer for the aim balls spawning.
Definition: CannonGame.h:71
Vec3 targetPoleOffset
The position offset of the target pole and target box.
Definition: CannonGame.h:81
Creates a StateManager object.
Definition: StateManager.h:9
Timer * missTimer
A timer for respawning the cannonball after a miss.
Definition: CannonGame.h:75
std::string gameHelp
Definition: CannonGame.h:90
StateManager * stateManager
A pointer to the state manager.
Definition: State.h:64
void update()
A function to update the State.
Definition: CannonGame.cpp:268
std::shared_ptr< GameObject > targetPole
A shared pointer to the target pole.
Definition: CannonGame.h:66
Text * timeText
Definition: CannonGame.h:97
SDL_Window * window
The window to display to.
Definition: State.h:66
CannonGame(StateManager *stateManager, SDL_Window *window)
Constructs the State object.
Definition: CannonGame.cpp:27
Text * scoreText
The info text.
Definition: CannonGame.h:96
bool fire
A bool for if the cannonball is in the air.
Definition: CannonGame.h:77
Contains the Vec3 structure with functions and overloaded operators.
Definition: Vec3.h:8
Vec3 ballScale
Definition: CannonGame.h:83
std::shared_ptr< GameObject > aimBalls[20]
An array of shared pointers to the aiming balls.
Definition: CannonGame.h:68
std::string gameUI
The UI images.
Definition: CannonGame.h:89
Vec3 ballStartPos
The initali ball vectors.
Definition: CannonGame.h:83
bool input()
Handles the State input.
Definition: CannonGame.cpp:213
Vec3 getNewTargetPos()
A function to generate a new postion for the target.
Definition: CannonGame.cpp:424
std::shared_ptr< GameObject > cannonball
A shared pointer to the cannonball.
Definition: CannonGame.h:62
std::string pointSound
The sound effects.
Definition: CannonGame.h:85
std::string noBallSound
Definition: CannonGame.h:86
A State that contains and runs the Demo.
Definition: CannonGame.h:14
float moveSpeed
The movement speed.
Definition: CannonGame.h:53
std::string explosionSound
Definition: CannonGame.h:87
~CannonGame()
Destructs the State object.
Definition: CannonGame.cpp:200
std::shared_ptr< GameObject > cannon
A shared pointer to the cannon.
Definition: CannonGame.h:60
Vec3 cannonBallVel
The sphere velocity.
Definition: CannonGame.h:51
float totalTime
The total time.
Definition: CannonGame.h:57
std::shared_ptr< GameObject > targetBox
A shared pointer to the target box.
Definition: CannonGame.h:64
Timer * gameTimer
A timer for the game.
Definition: CannonGame.h:73