Tower Defence 2
|
#include <engine.h>
Public Member Functions | |
GameEngine (double time, double timestep, int score, GameLevel &game_level, GameMap &game_map) | |
double | time () const |
const double | timestep () const |
int | score () const |
int | money () const |
int | lives () const |
void | change_game_speed (GameSpeed new_speed) |
Change the game speed to fast or normal. | |
void | increment_time () |
Increments the game time by one timestep. | |
void | add_score (int amount) |
Change player's score. Game score can't go below zero. | |
bool | add_money (int amount) |
void | reduce_life () |
void | upgrade_tower (int x, int y, int index) |
Upgrade existing tower into new one. | |
void | change_targeting (TargetingPolicy new_policy) |
Change targeting policy of all towers. | |
void | add_enemy (Enemy *enemy) |
Add new enemy to game map. | |
void | advance_game_level () |
void | enemy_movement () |
Enemy * | find_targets (Tower *tower, Enemies &enemies) |
void | towers_attack (graphicsEngine &gE) |
GameState | update (graphicsEngine &gE) |
GameMap | game_map () |
Getter for game map. | |
Friends | |
bool | update_high_score (const std::string &filename, GameEngine engine) |
Game class contains the game map, enemies, towers and game stats. This class is also responsible for the implementation of the main game loop which modifies the properties of the objects by using the rules of the game logic.
bool GameEngine::add_money | ( | int | amount | ) |
Change player's money.
void GameEngine::advance_game_level | ( | ) |
Handles level specific tasks such as spawning new enemies according to the game level description.
void GameEngine::enemy_movement | ( | ) |
Move enemies along the path.
Other combat objects that this object can target.
void GameEngine::reduce_life | ( | ) |
Reduce one life from the player. Player dies if lives reach zero.
void GameEngine::towers_attack | ( | graphicsEngine & | gE | ) |
Towers attack enemies. Increase score and money if enemies die and remove dead enemies from the game.
GameState GameEngine::update | ( | graphicsEngine & | gE | ) |
Updates the game loop. In practice this method will be called by the main graphics loop.
|
friend |
Updates high score if needed, takes the name of the file where high scores are kept Returns true if high scores were changed High scores are visible on the menu screen