-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFruit.cpp
33 lines (31 loc) · 980 Bytes
/
Fruit.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "Fruit.h"
//-----------------------------------------------------------------------------------------------//
void Fruit::move(const Board& board, const Point& nextStep)
{
if (board.isValidMove(nextStep) && stepsCounter % 3 == 0) //move the fruit every 3 steps
{
Creature::move(nextStep);
}
stepsCounter++;
}
//-----------------------------------------------------------------------------------------------//
void Fruit::init(char value, const Point& initP)
{
stepsCounter = 0;
appearOnBoard = true;
waitCounter = 0;
start = false;
erase = false;
setInitPoint(initP);
setRepresentiveCh(value);
Creature::init(true);
}
//-----------------------------------------------------------------------------------------------//
void Fruit::eraseFromBoard()
{
stepsCounter = 0;
erase = true;
appearOnBoard = false;
start = true;
}
//-----------------------------------------------------------------------------------------------//