-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlea.cpp
More file actions
62 lines (55 loc) · 1.25 KB
/
Flea.cpp
File metadata and controls
62 lines (55 loc) · 1.25 KB
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
54
55
56
57
58
59
60
61
/*
* Flea.cpp
*
* Created on: Apr 29, 2019
* Author: zohair
*/
#include "Flea.h"
int Flea::count=0;
Flea::Flea():fleaCrossed(false),randTime(GetRandInRange(1,3000)){
srand(time(NULL));
size=GetRandInRange(0,10);
trail=new int[size];
for(int i=0;i<size;i++)
trail[i]=GetRandInRange(6,35);
this->direction='d';
this->objectPosition.setObjY(39);
this->objectPosition.setObjX(GetRandInRange(1,51));
}
void Flea::draw(){
count++;
cout<<randTime<<endl;
if(count>=randTime){
if(objectPosition.getObjY()>1){
DrawCircle(this->objectPosition.getObjX()*20,this->objectPosition.getObjY()*20,10,colors[YELLOW]);
DrawCircle(this->objectPosition.getObjX()*20+10,this->objectPosition.getObjY()*20,5,colors[GetRandInRange(10,15)]);
move();
}
else
fleaCrossed=true;
}
}
int* Flea::getTrail(){
return trail;
}
int Flea::getSize(){
return size;
}
//bool Flea::shouldLeaveTrail(){
// if(leaveTrail==0 && numOfTrail>0){
// return 1;
// }
// return 0;
//}
void Flea::move(){
this->objectPosition.setObjY(this->objectPosition.getObjY()-1);
}
int Flea::getObjectPositionX(){
return this->objectPosition.getObjX();
}
int Flea::getObjectPositionY(){
return this->objectPosition.getObjY();
}
Flea::~Flea() {
// TODO Auto-generated destructor stub
}