ArnieBoids  1.0.0
JOINT AI PROJECT
Game Class Reference

Game class. Updates and draws all ships and bullets. Culls dead bullets and ships. More...

#include <Game.hpp>

Collaboration diagram for Game:

Public Member Functions

 Game (sf::RenderWindow &window, unsigned int timePerTick=16U)
 
 ~Game ()
 
int run ()
 Implements the main game loop. While window_ is open: Calls handleEvents(), Implements a fixed timestep and calls update() and draw() inside it. More...
 

Private Member Functions

void wrap (sf::ConvexShape *cs)
 Wraps a passed convexShape to the opposite side of game bounds. More...
 
void playerDeath ()
 Resets behaviours dependant on player existing. More...
 
void clearLists ()
 Clears the game of entities. More...
 
void reset ()
 Resets the game. More...
 
void addBoidSwarm (sf::Vector2f const &pos, float amount, float radius)
 Adds a swarm of [amount] boids in circle around [pos] with [radius]. More...
 
void handleEvents ()
 Polls the RenderWindow for events and handles these events accordingly. More...
 
void update ()
 Calls Update on all bullets and ships. More...
 
void draw ()
 Draws all bullets and ships. Also draws the backdrop_ of stars. More...
 

Private Attributes

sf::RenderWindow & window_
 Window that everything will be drawn to. More...
 
sf::FloatRect gameBounds_
 Game bounds. More...
 
std::list< Ship * > ships_
 All ships in the game. More...
 
Shipcontrolled_
 Ship affected by input. More...
 
std::list< Bullet * > bullets_
 All bullets in the game. More...
 
std::list< Pickup * > pickups_
 All pickups in the game. More...
 
KeyInput keyboard_
 For keyboard input. More...
 
XController controller_
 For taking input from an Xbox controller. More...
 
Camera camera_
 Camera that follows ships and has a HUD. More...
 
TiledBackdrop backdrop_
 Background of stars. More...
 
CollisionSystem collisionSystem_
 Used to check for collision between shapes. More...
 
thor::ParticleSystem particleSystem_
 Manages all particles. More...
 
sf::Texture particleTexture_
 Texture for all particles. More...
 
std::function< void(Bullet *)> fireBulletCallback_
 Adds a bullet to the bulletList_. Given to ships so that they can fire bullets. More...
 
std::function< void(Ship *)> spawnShipCallback_
 Adds a ship to the shipList_. Given to Motherships so that they can spawn other ships. More...
 
std::chrono::steady_clock tickClock_
 
std::chrono::milliseconds timePerTick_
 Milliseconds per update/draw tick. More...
 
std::chrono::time_point< std::chrono::system_clock > timeOfLastTick_
 Time at which the last update/draw tick occurred. More...
 
sf::SoundBuffer erasedSBuffer_
 Buffers for the sounds in the game. More...
 
sf::SoundBuffer mineSBuffer_
 
sf::SoundBuffer planSBuffer_
 
sf::SoundBuffer backSBuffer_
 
sf::Sound erasedSound_
 Sounds that the game will play. More...
 
sf::Sound mineSound_
 
sf::Sound planSound_
 
sf::Sound backSound_
 
sf::Music bgMusic_
 The background music forthe game. More...
 

Detailed Description

Game class. Updates and draws all ships and bullets. Culls dead bullets and ships.

Remarks
Chrono members are used for fixed timestep

Constructor & Destructor Documentation

Game::Game ( sf::RenderWindow &  window,
unsigned int  timePerTick = 16U 
)

Here is the call graph for this function:

Game::~Game ( )

Member Function Documentation

void Game::addBoidSwarm ( sf::Vector2f const &  pos,
float  amount,
float  radius 
)
private

Adds a swarm of [amount] boids in circle around [pos] with [radius].

Here is the call graph for this function:

Here is the caller graph for this function:

void Game::clearLists ( )
private

Clears the game of entities.

Here is the caller graph for this function:

void Game::draw ( )
private

Draws all bullets and ships. Also draws the backdrop_ of stars.

Here is the call graph for this function:

Here is the caller graph for this function:

void Game::handleEvents ( )
private

Polls the RenderWindow for events and handles these events accordingly.

Here is the call graph for this function:

Here is the caller graph for this function:

void Game::playerDeath ( )
private

Resets behaviours dependant on player existing.

Here is the call graph for this function:

Here is the caller graph for this function:

void Game::reset ( )
private

Resets the game.

Game setup variables

Here is the call graph for this function:

Here is the caller graph for this function:

int Game::run ( )

Implements the main game loop. While window_ is open: Calls handleEvents(), Implements a fixed timestep and calls update() and draw() inside it.

Here is the call graph for this function:

Here is the caller graph for this function:

void Game::update ( )
private

Calls Update on all bullets and ships.

Here is the call graph for this function:

Here is the caller graph for this function:

void Game::wrap ( sf::ConvexShape *  cs)
private

Wraps a passed convexShape to the opposite side of game bounds.

Here is the caller graph for this function:

Member Data Documentation

TiledBackdrop Game::backdrop_
private

Background of stars.

sf::SoundBuffer Game::backSBuffer_
private
sf::Sound Game::backSound_
private
sf::Music Game::bgMusic_
private

The background music forthe game.

std::list<Bullet*> Game::bullets_
private

All bullets in the game.

Camera Game::camera_
private

Camera that follows ships and has a HUD.

CollisionSystem Game::collisionSystem_
private

Used to check for collision between shapes.

Ship* Game::controlled_
private

Ship affected by input.

XController Game::controller_
private

For taking input from an Xbox controller.

sf::SoundBuffer Game::erasedSBuffer_
private

Buffers for the sounds in the game.

sf::Sound Game::erasedSound_
private

Sounds that the game will play.

std::function<void(Bullet*)> Game::fireBulletCallback_
private

Adds a bullet to the bulletList_. Given to ships so that they can fire bullets.

sf::FloatRect Game::gameBounds_
private

Game bounds.

KeyInput Game::keyboard_
private

For keyboard input.

sf::SoundBuffer Game::mineSBuffer_
private
sf::Sound Game::mineSound_
private
thor::ParticleSystem Game::particleSystem_
private

Manages all particles.

sf::Texture Game::particleTexture_
private

Texture for all particles.

std::list<Pickup*> Game::pickups_
private

All pickups in the game.

sf::SoundBuffer Game::planSBuffer_
private
sf::Sound Game::planSound_
private
std::list<Ship*> Game::ships_
private

All ships in the game.

std::function<void(Ship*)> Game::spawnShipCallback_
private

Adds a ship to the shipList_. Given to Motherships so that they can spawn other ships.

std::chrono::steady_clock Game::tickClock_
private
std::chrono::time_point<std::chrono::system_clock> Game::timeOfLastTick_
private

Time at which the last update/draw tick occurred.

std::chrono::milliseconds Game::timePerTick_
private

Milliseconds per update/draw tick.

sf::RenderWindow& Game::window_
private

Window that everything will be drawn to.


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