Snoke
Game Class Reference

Main game class. More...

#include <game.h>

Collaboration diagram for Game:

Public Member Functions

bool init (int size=20, int sp=100, int loops=-1)
 Initializes game. More...
 
int run ()
 Main game loop. More...
 

Private Member Functions

void setSpeed (int sp)
 The method to change the game speed without giving the direct access and some error handling. More...
 
void setLoops (int loops)
 sets loops with some error holding More...
 
bool initSnake (Point begin, short dir, int length)
 Snake initialization with labyrinth updating. More...
 

Private Attributes

int speed
 
int loops
 
Snake snake
 
SnakesnakeEnemies
 
Labyrinth labyrinth
 

Detailed Description

Main game class.

Parameters
speed- game refresh rate(in milliseconds)
snake- the local player controlled snake
snakeEnemies- the remotely controlled snake entities
labyrinth- object containing labyrinth, displaying it, etc

Definition at line 30 of file game.h.

Member Function Documentation

bool Game::init ( int  size = 20,
int  speed = 100,
int  loops = -1 
)

Initializes game.

Parameters
size- size of the game field(size - 2 columns, size/2 - 2 rows)
speed- speed of the game(1 / refresh rate) in milliseconds
loops- for how many loops the game should run
Returns
- mark of successful initialization

Definition at line 38 of file game.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool Game::initSnake ( Point  begin,
short  dir,
int  length 
)
private

Snake initialization with labyrinth updating.

Parameters
begin- starting Point of a snake(where the tail segment will be situated)
dir- direction of snake's 'growth' as well as it's starting direction
length- the length of a 'new born' snake
Returns
- mark of whether the snake is successfully initialized

Definition at line 171 of file game.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int Game::run ( )

Main game loop.

Returns
- the exit code

Definition at line 68 of file game.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Game::setLoops ( int  loops)
private

sets loops with some error holding

Parameters
loops- amount of loops game will run (-1 for unlimmited)

Definition at line 57 of file game.cpp.

Here is the caller graph for this function:

void Game::setSpeed ( int  speed)
private

The method to change the game speed without giving the direct access and some error handling.

Parameters
speed- speed of the game(1 / refresh rate) in milliseconds

Definition at line 183 of file game.cpp.

Here is the caller graph for this function:

Member Data Documentation

Labyrinth Game::labyrinth
private

Definition at line 37 of file game.h.

int Game::loops
private

Definition at line 34 of file game.h.

Snake Game::snake
private

Definition at line 35 of file game.h.

Snake* Game::snakeEnemies
private

Definition at line 36 of file game.h.

int Game::speed
private

Definition at line 33 of file game.h.


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