nsnake
Classic snake game for the terminal
Loading...
Searching...
No Matches
Game Class Reference
Collaboration diagram for Game:

Public Member Functions

void start (std::string levelName="")
 Starts game, optionally loading a level.
 
void handleInput ()
 
void update ()
 
void draw ()
 
bool isOver ()
 
bool willQuit ()
 If we'll quit the game right away.
 
bool willReturnToMenu ()
 If we'll return to the main menu.
 
int getDelay (int speed)
 Returns how much time (millisseconds) we need to wait for a specific #speed.
 
void pause (bool option)
 

Public Attributes

ScoreFilescores
 All the current level's score.
 
ScoreEntrycurrentScore
 Current score for this level.
 

Protected Attributes

LayoutGamelayout
 
bool gameOver
 If the game is over (board is full of blocks).
 
bool userAskedToQuit
 
bool userAskedToGoToMenu
 
Timer timerSnake
 Timer that tells when to move the player, based on the current speed).
 
Timer timerBoard
 Timer that tells when to scroll the board, if this game setting is activated.
 
Timer timer
 
bool isPaused
 If the game is paused.
 
bool showPauseMenu
 If it's showing the pause menu.
 
bool showHelp
 If it's showing the help screen.
 
MenupauseMenu
 Menu that's shown only when the user presses Pause.
 
Playerplayer
 
Boardboard
 
FruitManagerfruits
 

Friends

class LayoutGame
 

Detailed Description

Definition at line 16 of file Game.hpp.

Constructor & Destructor Documentation

◆ Game()

Game::Game ( )

Definition at line 16 of file Game.cpp.

◆ ~Game()

Game::~Game ( )
virtual

Definition at line 29 of file Game.cpp.

Member Function Documentation

◆ draw()

void Game::draw ( )

Definition at line 311 of file Game.cpp.

◆ getDelay()

int Game::getDelay ( int speed)

Returns how much time (millisseconds) we need to wait for a specific #speed.

Definition at line 327 of file Game.cpp.

◆ handleInput()

void Game::handleInput ( )

Definition at line 146 of file Game.cpp.

◆ isOver()

bool Game::isOver ( )

Definition at line 315 of file Game.cpp.

◆ pause()

void Game::pause ( bool option)

Definition at line 347 of file Game.cpp.

◆ start()

void Game::start ( std::string levelName = "")

Starts game, optionally loading a level.

Note
This is not the path to the level file! It's merely a level name.
See also
BoardParser::load
Note
If no level name is specified, will default to an empty box.

Definition at line 39 of file Game.cpp.

◆ update()

void Game::update ( )

Definition at line 220 of file Game.cpp.

◆ willQuit()

bool Game::willQuit ( )

If we'll quit the game right away.

Definition at line 319 of file Game.cpp.

◆ willReturnToMenu()

bool Game::willReturnToMenu ( )

If we'll return to the main menu.

Definition at line 323 of file Game.cpp.

Friends And Related Symbol Documentation

◆ LayoutGame

friend class LayoutGame
friend

Definition at line 18 of file Game.hpp.

Member Data Documentation

◆ board

Board* Game::board
protected

Definition at line 104 of file Game.hpp.

◆ currentScore

ScoreEntry* Game::currentScore

Current score for this level.

It shall get increased with time and in the end we'll test to see if it can enter this level's high score list.

Definition at line 66 of file Game.hpp.

◆ fruits

FruitManager* Game::fruits
protected

Definition at line 105 of file Game.hpp.

◆ gameOver

bool Game::gameOver
protected

If the game is over (board is full of blocks).

Definition at line 72 of file Game.hpp.

◆ isPaused

bool Game::isPaused
protected

If the game is paused.

May show other Windows while paused.

Definition at line 90 of file Game.hpp.

◆ layout

LayoutGame* Game::layout
protected

Definition at line 69 of file Game.hpp.

◆ pauseMenu

Menu* Game::pauseMenu
protected

Menu that's shown only when the user presses Pause.

Definition at line 101 of file Game.hpp.

◆ player

Player* Game::player
protected

Definition at line 103 of file Game.hpp.

◆ scores

ScoreFile* Game::scores

All the current level's score.

It allows to read all the scores on this level, independent of game settings.

Definition at line 59 of file Game.hpp.

◆ showHelp

bool Game::showHelp
protected

If it's showing the help screen.

Goes together with isPaused.

Definition at line 98 of file Game.hpp.

◆ showPauseMenu

bool Game::showPauseMenu
protected

If it's showing the pause menu.

Goes together with isPaused.

Definition at line 94 of file Game.hpp.

◆ timer

Timer Game::timer
protected

Definition at line 86 of file Game.hpp.

◆ timerBoard

Timer Game::timerBoard
protected

Timer that tells when to scroll the board, if this game setting is activated.

Definition at line 83 of file Game.hpp.

◆ timerSnake

Timer Game::timerSnake
protected

Timer that tells when to move the player, based on the current speed).

Definition at line 79 of file Game.hpp.

◆ userAskedToGoToMenu

bool Game::userAskedToGoToMenu
protected

Definition at line 75 of file Game.hpp.

◆ userAskedToQuit

bool Game::userAskedToQuit
protected

Definition at line 74 of file Game.hpp.


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