-
Notifications
You must be signed in to change notification settings - Fork 0
/
MagicSeg.cpp
61 lines (54 loc) · 1.83 KB
/
MagicSeg.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* MagicSeg.cpp
*
* Created on: Apr 29, 2019
* Author: zohair
*/
#include "MagicSeg.h"
int MagicSeg::counter=0;
MagicSeg::MagicSeg():Segment(),randBlink(GetRandInRange(10,100)){
direction='l';
this->objectPosition.setObjX(50);
this->objectPosition.setObjY(39);
}
MagicSeg::MagicSeg(int X, int Y):Segment(),randBlink(GetRandInRange(10,100)){
direction='l';
this->objectPosition.setObjX(X);
this->objectPosition.setObjY(Y);
}
void MagicSeg::draw(){
counter++;
if(counter<randBlink){
DrawLine( objectPosition.getObjX()*20+8 , objectPosition.getObjY()*20-9 , objectPosition.getObjX()*20+8 , objectPosition.getObjY()*20+9 , 4 , colors[WHITE] );
DrawLine( objectPosition.getObjX()*20+8 , objectPosition.getObjY()*20-9 , objectPosition.getObjX()*20+8 , objectPosition.getObjY()*20-25 , 4 , colors[WHITE] );
DrawCircle(objectPosition.getObjX()*20+8,objectPosition.getObjY()*20-9,9,colors[LIME]);
}
else if(counter<randBlink+200){
if(counter%20==0){
DrawLine( objectPosition.getObjX()*20+8 , objectPosition.getObjY()*20-9 , objectPosition.getObjX()*20+8 , objectPosition.getObjY()*20+9 , 4 , colors[WHITE] );
DrawLine( objectPosition.getObjX()*20+8 , objectPosition.getObjY()*20-9 , objectPosition.getObjX()*20+8 , objectPosition.getObjY()*20-25 , 4 , colors[WHITE] );
DrawCircle(objectPosition.getObjX()*20+8,objectPosition.getObjY()*20-9,9,colors[LIME]);
}
}
else
counter=0;
move();
}
void MagicSeg::move(){
changeDirection();
if(direction=='l'){
this->objectPosition.setObjX(objectPosition.getObjX()-1);
}
else if(direction=='r'){
this->objectPosition.setObjX(objectPosition.getObjX()+1);
}
}
int MagicSeg::getObjectPositionX(){
return this->objectPosition.getObjX();
}
int MagicSeg::getObjectPositionY(){
return this->objectPosition.getObjY();
}
MagicSeg::~MagicSeg() {
// TODO Auto-generated destructor stub
}