-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCFood.cpp
46 lines (41 loc) · 796 Bytes
/
CFood.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
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* Developed By : Lorenzo T.Leonardo
* Date : March 23, 2022
* Email : [email protected]
*/
#include "CFood.h"
#include <stdlib.h>
#include <ctime>
CFood::CFood()
{
srand((unsigned int)time(NULL));
m_bIsBonus = false;
m_pos = {2,2};
m_previousPos = {2,2};
m_screenSize = {0,0};
}
CFood::CFood(COORD screenSize)
{
srand((unsigned int)time(NULL));
m_bIsBonus = false;
m_pos = {2,2};
m_previousPos = {2,2};
m_screenSize = screenSize;
}
CFood::~CFood()
{
}
void CFood::createFood()
{
m_previousPos = m_pos;
if (rand() % 5 == 1)
m_bIsBonus = true;
else
m_bIsBonus = false;
m_pos.X = (rand() % (m_screenSize.X - 2)) + 2;
m_pos.Y = (rand() % (m_screenSize.Y - 2)) + 2;
}
bool CFood::isBonusFood()
{
return m_bIsBonus;
}