-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fruit.h
53 lines (40 loc) · 1.15 KB
/
Fruit.h
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*----------------------------------------------------------------------------------------------*/
/* Represents a Fruit in the game
* Inherits from GameObject
*/
#pragma once
#include "GameObject.h"
#include "Const.h"
#include "utils.h"
#include <time.h>
#include "Board.h"
class Fruit : public GameObject
{
private:
int value;
char direction;
int steps;
bool alive;
public:
Fruit(int x, int y, bool _alive = DEAD, char dir = STAY, int _steps = Max_Fruit_Steps) : GameObject(x, y) {
/* initialize random seed: */
srand(time(NULL));
value = rand() % 5 + 5; // Generate a number between 5 to 9
direction = dir;
steps = _steps;
alive = _alive;
}
void move(char board[terminal_Size_Y][terminal_Size_X]);
bool checkLegalMove(char direction, char board[terminal_Size_Y][terminal_Size_X]);
void draw();
void Delete(char board[terminal_Size_Y][terminal_Size_X], bool silentMode = false);
// GETTERS:
int getValue() const;
char getDirection() const;
int getSteps() const;
bool getAlive() const;
// SETTERS:
void setValue();
void setSteps(int newSteps);
void setAlive(bool newState, char board[][terminal_Size_X], bool silentMode = false);
};