Ben Evans / Mbed 2 deprecated Defender_Game

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

PlayEngine Class Reference

PlayEngine Class Reference

PlayEngine Class. More...

#include <PlayEngine.h>

Inherited by GameEngine [private].

Public Member Functions

void read_joystick_direction ()
 Gets joystick direction from gamepad and stores it in d_.
void read_accelerometer_direction (float roll, float pitch)
 Gets the pitch and roll of the gamepad and calculates d_.
void spaceship_lives_leds ()
 Turns on specific leds depending on how many lives left.
void create_weapons_bullets ()
 Creates weapons object if button A is pressed and stores in vector.
void create_weapons_smart_bomb ()
 Creates smart bomb if button B is pressed.
void draw_bullets ()
 Draws each bullet object and deleted object after set movement distance.
void spawn_aliens ()
 Spawns aliens in random position of the screen.
void create_alien ()
 Creates alien object and stores in vector.
void check_alien_people_collision (int i)
 Checks for alien people collision and sets abduction movements.
void alliens_fire_bullets (int i)
 Gets alien to fire bullets randomly towards spaceship.
void delete_aliens (int i)
 Deletes bullet and alien if collision detected and draws explosion.
void draw_aliens ()
 Draws each alien object and deletes both objects if collision detected.
void create_explosion (Vector2D destroyed_position)
 Creates bullet object if button A is pressed and stores in vector.
void draw_explosions ()
 Draws each explosion object if collision detected.
void spawn_people ()
 Spawns people in random places at bottom of screen.
void create_people ()
 Spawns people in random position at bottom of the screen.
void draw_people ()
 Draws each people object.
void reset_map_timer ()
 Resets map after set time so spaceship explosion animation shows.
void reset_map ()
 Resets the map after spaceship death and timer has ended.

Data Fields

int points_
 Define points.
Direction d_
 Define direction d of joystick.
bool spaceship_destroyed_
 Flag for if spaceship is destroyed.
int spaceship_lives_
 Number of spaceship lives remaining.
int smart_bomb_timer_
 Counter for smart bomb timer.
int bullet_timer_
 Counter for bullet timer.
int smart_bomb_counter_
 Counter for how smart bombs left.
int spawn_alien_counter_
 Counter for spawning aliens.
int alien_number_
 Number of aliens on the screen at a time.
int spawn_time_multipler_
 Multiplier to increase number of alien as time goes on.
int reset_map_counter_
 Counter to reset map after set amount of frames.
SoundParts sound_fx_
 Hold on or off depending if sound fx are set on or off.
std::vector< Weaponsbullet_vector
 Vector to store each new bullet object.
std::vector< Weaponsalien_bullet_vector
 Vector to store each alien bullet object.
std::vector< Alienalien_vector
 Vector to store each new alien object.
std::vector< Explosionexplosion_vector
 Vector to store each new explosion object.
std::vector< Peoplepeople_vector
 Vector to store each new people object.
Gamepad pad
 Define Gamepad object.
N5110 lcd
 Define LCD object.
Spaceship spaceship
 Define Spaceship object.
Map map
 Define Map object.
Weapons weapons
 Define Weapons object.

Detailed Description

PlayEngine Class.

Runs the interactions between the different classes in the playable part of the game. Also to break down the size of game engine class. Means I can define the functions publicly to test them then inherit them privately.

Author:
Benjamin Evans, University of Leeds
Date:
May 2020

Definition at line 21 of file PlayEngine.h.


Member Function Documentation

void alliens_fire_bullets ( int  i )

Gets alien to fire bullets randomly towards spaceship.

Parameters:
iiterator from draw_alien for loop

Definition at line 210 of file PlayEngine.cpp.

void check_alien_people_collision ( int  i )

Checks for alien people collision and sets abduction movements.

Parameters:
iiterator from draw_alien for loop

Definition at line 188 of file PlayEngine.cpp.

void create_alien (  )

Creates alien object and stores in vector.

Definition at line 170 of file PlayEngine.cpp.

void create_explosion ( Vector2D  destroyed_position )

Creates bullet object if button A is pressed and stores in vector.

Definition at line 272 of file PlayEngine.cpp.

void create_people (  )

Spawns people in random position at bottom of the screen.

Definition at line 314 of file PlayEngine.cpp.

void create_weapons_bullets (  )

Creates weapons object if button A is pressed and stores in vector.

Definition at line 69 of file PlayEngine.cpp.

void create_weapons_smart_bomb (  )

Creates smart bomb if button B is pressed.

Definition at line 85 of file PlayEngine.cpp.

void delete_aliens ( int  i )

Deletes bullet and alien if collision detected and draws explosion.

Parameters:
iiterator from draw_alien for loop

Definition at line 230 of file PlayEngine.cpp.

void draw_aliens (  )

Draws each alien object and deletes both objects if collision detected.

Definition at line 248 of file PlayEngine.cpp.

void draw_bullets (  )

Draws each bullet object and deleted object after set movement distance.

Definition at line 115 of file PlayEngine.cpp.

void draw_explosions (  )

Draws each explosion object if collision detected.

Definition at line 289 of file PlayEngine.cpp.

void draw_people (  )

Draws each people object.

Definition at line 324 of file PlayEngine.cpp.

void read_accelerometer_direction ( float  roll,
float  pitch 
)

Gets the pitch and roll of the gamepad and calculates d_.

Definition at line 9 of file PlayEngine.cpp.

void read_joystick_direction (  )

Gets joystick direction from gamepad and stores it in d_.

Definition at line 5 of file PlayEngine.cpp.

void reset_map (  )

Resets the map after spaceship death and timer has ended.

Definition at line 365 of file PlayEngine.cpp.

void reset_map_timer (  )

Resets map after set time so spaceship explosion animation shows.

Definition at line 351 of file PlayEngine.cpp.

void spaceship_lives_leds (  )

Turns on specific leds depending on how many lives left.

Definition at line 42 of file PlayEngine.cpp.

void spawn_aliens (  )

Spawns aliens in random position of the screen.

Definition at line 152 of file PlayEngine.cpp.

void spawn_people (  )

Spawns people in random places at bottom of screen.

Definition at line 307 of file PlayEngine.cpp.


Field Documentation

Vector to store each alien bullet object.

Definition at line 148 of file PlayEngine.h.

Number of aliens on the screen at a time.

Definition at line 129 of file PlayEngine.h.

std::vector<Alien> alien_vector

Vector to store each new alien object.

Definition at line 151 of file PlayEngine.h.

Counter for bullet timer.

Definition at line 119 of file PlayEngine.h.

std::vector<Weapons> bullet_vector

Vector to store each new bullet object.

Definition at line 145 of file PlayEngine.h.

Direction d_

Define direction d of joystick.

Definition at line 106 of file PlayEngine.h.

Vector to store each new explosion object.

Definition at line 154 of file PlayEngine.h.

Define LCD object.

Definition at line 165 of file PlayEngine.h.

Define Map object.

Definition at line 171 of file PlayEngine.h.

Define Gamepad object.

Definition at line 162 of file PlayEngine.h.

std::vector<People> people_vector

Vector to store each new people object.

Definition at line 157 of file PlayEngine.h.

int points_

Define points.

Definition at line 103 of file PlayEngine.h.

Counter to reset map after set amount of frames.

Definition at line 136 of file PlayEngine.h.

Counter for how smart bombs left.

Definition at line 122 of file PlayEngine.h.

Counter for smart bomb timer.

Definition at line 116 of file PlayEngine.h.

SoundParts sound_fx_

Hold on or off depending if sound fx are set on or off.

Definition at line 140 of file PlayEngine.h.

Define Spaceship object.

Definition at line 168 of file PlayEngine.h.

Flag for if spaceship is destroyed.

Definition at line 109 of file PlayEngine.h.

Number of spaceship lives remaining.

Definition at line 112 of file PlayEngine.h.

Counter for spawning aliens.

Definition at line 126 of file PlayEngine.h.

Multiplier to increase number of alien as time goes on.

Definition at line 132 of file PlayEngine.h.

Define Weapons object.

Definition at line 174 of file PlayEngine.h.