Snoke
Labyrinth Class Reference

class for containing and displaying the game field More...

#include <labyrinth.h>

Collaboration diagram for Labyrinth:

Public Member Functions

bool setLabyrinth (Point dimensions)
 Sets the default values fro the variables as well as generating the labyritnh array with borders. More...
 
bool addSnake (Snake *snake)
 Adding snake to the laburinth and getting the host snake(firest added snake) More...
 
bool addPoint (Point p)
 Adding Point to the labyrinth with the check of correction. More...
 
bool rmPoint (Point p)
 Remove Point from the labyrinth. More...
 
void displayHandler (int displayMethod=-1)
 A method which decides what dispaly method will be used in each situation. More...
 
bool initBall ()
 Ball initialization with labyrinth updating. More...
 
bool generateBall ()
 Generate the Ball. More...
 
short isFree (Point p)
 Mark of if the asked Point is free. More...
 
bool save (char name[MAXLINE])
 Method to save labyritnh(borders and obstacles, defined in reserved string) to the file. More...
 
bool load (char name[MAXLINE])
 Mehod to load labyrinth from the file. More...
 

Public Attributes

Change change
 
Ball ball
 

Private Member Functions

void updateLabyrinth ()
 Updating the labyrinth(changing the values of some Points) More...
 
void sizeHandler ()
 A method, which sets start and end values depending on the position of local_player's snake head and current console size. More...
 

Private Attributes

char ** labyrinth
 
std::string reserved = "!"
 
Snakesnake = NULL
 
Point start
 
Point end
 
Point prevStart
 
Point prevEnd
 
Point gameFieldSize
 
DisplayHandler dispHandler
 

Friends

class DisplayHandler
 

Detailed Description

class for containing and displaying the game field

Parameters
labyrinth- game field, consisting of chars
reserved- array of reserved chars for inside usage
prevDisplayMethod- value, containing the makr of which display method was previously called(is used in displaying)
snake- pointer to a local_player's snake
start- top left corner from which the drawing of the current cycle starts
end- bottom right corner at which the drawing of the current cycle ends
prevStart- previous value of start
prevEnd- previous value of end

Definition at line 66 of file labyrinth.h.

Member Function Documentation

bool Labyrinth::addPoint ( Point  p)

Adding Point to the labyrinth with the check of correction.

Parameters
p- point to add to the labyrinth
Returns
- mark of whether the Point was added

Definition at line 271 of file labyrinth.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool Labyrinth::addSnake ( Snake aSnake)

Adding snake to the laburinth and getting the host snake(firest added snake)

Parameters
aSnake- a snake to add
Returns
- mark of succesful addition

Definition at line 110 of file labyrinth.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Labyrinth::displayHandler ( int  displayMethod = -1)

A method which decides what dispaly method will be used in each situation.

Parameters
displayMethod- force it to use a certain display method

Definition at line 152 of file labyrinth.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool Labyrinth::generateBall ( )

Generate the Ball.

Parameters
labyrinth- the current state of the labyrinth object for intersection checking
Returns
- mark of whether the ball was successfully generated

Definition at line 83 of file labyrinth.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool Labyrinth::initBall ( )

Ball initialization with labyrinth updating.

Returns
- mark of succesful initialization

Definition at line 71 of file labyrinth.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

short Labyrinth::isFree ( Point  p)

Mark of if the asked Point is free.

Parameters
p- Point to check in the labyrinth
Returns
- mark of whether the Point is free

Definition at line 254 of file labyrinth.cpp.

Here is the caller graph for this function:

bool Labyrinth::load ( char  name[MAXLINE])

Mehod to load labyrinth from the file.

Parameters
name- name of the file to read from
Returns
- mark os successful loading

Definition at line 339 of file labyrinth.cpp.

Here is the caller graph for this function:

bool Labyrinth::rmPoint ( Point  p)

Remove Point from the labyrinth.

Parameters
p- point to remove from the labyrinth
Returns
- mark of whether the Point was removed

Definition at line 286 of file labyrinth.cpp.

Here is the caller graph for this function:

bool Labyrinth::save ( char  name[MAXLINE])

Method to save labyritnh(borders and obstacles, defined in reserved string) to the file.

Parameters
name- name of the file, where to sace the labyrinth
Returns
- mark of whether the labyrinth was successfully saved

Definition at line 297 of file labyrinth.cpp.

Here is the caller graph for this function:

bool Labyrinth::setLabyrinth ( Point  fieldSize)

Sets the default values fro the variables as well as generating the labyritnh array with borders.

Parameters
gameFieldSize- a size of the labyrinth
Returns
- mark of succesful initialization

Definition at line 17 of file labyrinth.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Labyrinth::sizeHandler ( )
private

A method, which sets start and end values depending on the position of local_player's snake head and current console size.

Definition at line 171 of file labyrinth.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Labyrinth::updateLabyrinth ( )
private

Updating the labyrinth(changing the values of some Points)

Definition at line 232 of file labyrinth.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class DisplayHandler
friend

Definition at line 77 of file labyrinth.h.

Member Data Documentation

Ball Labyrinth::ball

Definition at line 83 of file labyrinth.h.

Change Labyrinth::change

Definition at line 82 of file labyrinth.h.

DisplayHandler Labyrinth::dispHandler
private

Definition at line 78 of file labyrinth.h.

Point Labyrinth::end
private

Definition at line 73 of file labyrinth.h.

Point Labyrinth::gameFieldSize
private

Definition at line 76 of file labyrinth.h.

char** Labyrinth::labyrinth
private

Definition at line 69 of file labyrinth.h.

Point Labyrinth::prevEnd
private

Definition at line 75 of file labyrinth.h.

Point Labyrinth::prevStart
private

Definition at line 74 of file labyrinth.h.

std::string Labyrinth::reserved = "!"
private

Definition at line 70 of file labyrinth.h.

Snake* Labyrinth::snake = NULL
private

Definition at line 71 of file labyrinth.h.

Point Labyrinth::start
private

Definition at line 72 of file labyrinth.h.


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