19 if(fieldSize.
x > 4 && fieldSize.
y > 4)
26 for(
int i = 0; i < fieldSize.
y; i++)
29 for(
int j = 0; j < fieldSize.
x; j++)
34 for(
int i = 0; i < fieldSize.
x; i++)
39 for(
int i = 0; i < fieldSize.
y; i++)
53 this->
start = leftTop;
113 std::list<Point> currBody;
115 auto it = currBody.begin();
116 for(; it != currBody.end(); ++it)
131 for(; it != currBody.begin(); --it)
141 if(this->
snake == NULL){
142 this->
snake = aSnake;
181 start.
y = head.
y - currentSize.
y / 2;
182 end.
y = head.
y + currentSize.
y / 2 + currentSize.
y % 2;
186 end.
y = currentSize.
y;
207 start.
x = head.
x - currentSize.
x / 2;
208 end.
x = head.
x + currentSize.
x / 2 + currentSize.
x % 2;
212 end.
x = currentSize.
x;
234 std::deque<Point> cpChange;
237 for(
auto it = cpChange.begin(); it != cpChange.end(); ++it)
240 mvaddch((*it).y, (*it).x,
'F');
243 for(
auto it = cpChange.begin(); it != cpChange.end(); ++it)
301 file = fopen(name,
"w");
322 snprintf(strout,
sizeof(strout),
"Succesfully saved to %s", name);
329 snprintf(strout,
sizeof(strout),
"Couldn't save to %s", name);
344 file = fopen(name,
"r");
350 fscanf(file,
"%hd %hd", &scannedSize.
x, &scannedSize.
y);
351 char tmpLab[scannedSize.
y][scannedSize.
x];
352 for(
int i = 0; i < scannedSize.
x; i++)
354 for(
int j = 0; j < scannedSize.
y; j++)
363 for(
int j = 0; j < scannedSize.
y; j++)
365 fgets(tmpLab[j], scannedSize.
x, file);
377 if(
reserved.find(tmpLab[j][i]) != std::string::npos)
386 snprintf(strout,
sizeof(strout),
"Succesfully loaded from %s", name);
393 snprintf(strout,
sizeof(strout),
"Couldn't load from %s", name);
DisplayHandler dispHandler
void getRmQueue(std::deque< Point > *cpChange)
method to get a copy of removal array
bool addPoint(Point p)
adds Point to addition array if it fits the criteria
void initQueue()
Initializes change array, by resetting it.
Definitions and prototypes for Labyrinth class.
bool initBall()
Ball initialization with labyrinth updating.
bool rmPoint(Point p)
adds Point to removal array if it fits the criteria
std::mt19937 * getRandomEngine()
void updateLabyrinth()
Updating the labyrinth(changing the values of some Points)
void getCoords(std::list< Point > *currBody)
The method to get the snake whole body coordinates(x ,y) without giving the direct access...
bool generateBall()
Generate the Ball.
void sizeHandler()
A method, which sets start and end values depending on the position of local_player's snake head and ...
bool setLabyrinth(Point dimensions)
Sets the default values fro the variables as well as generating the labyritnh array with borders...
void getAddQueue(std::deque< Point > *cpChange)
method to get a copy of addition array
const int DISPPART
the whole labyrinth doesn't fit, so we are displaying it partialy
Point getCoords()
Get the ball coords without giving the direct access.
bool inAddQueue(Point p)
Check if Points is in the addition queue.
bool save(char name[MAXLINE])
Method to save labyritnh(borders and obstacles, defined in reserved string) to the file...
bool load(char name[MAXLINE])
Mehod to load labyrinth from the file.
bool init(Point dim)
Initialization.
Point getConsoleSize()
Gets size of current console screen in symdols.
std::uniform_int_distribution< int > distributionX
bool inRmQueue(Point p)
Check if the Point is in the remove queue.
bool setCoords(Point p)
Sets coordinates of the ball to given if they are correct.
bool rmPoint(Point p)
Remove Point from the labyrinth.
Point getHeadCoords()
The method to get the coordinates(x, y) of the snake's head without giving the direct access...
Describes the Snake entity of the game.
bool addPoint(Point p)
Adding Point to the labyrinth with the check of correction.
bool addSnake(Snake *snake)
Adding snake to the laburinth and getting the host snake(firest added snake)
std::uniform_int_distribution< int > distributionY
void displayHandler(int displayMethod)
handler for choosing the approriate display method in the current environment
void displayHandler(int displayMethod=-1)
A method which decides what dispaly method will be used in each situation.
Coordinates and style of the cell in console window.
short isFree(Point p)
Mark of if the asked Point is free.