-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathturtle.cpp
More file actions
39 lines (34 loc) · 777 Bytes
/
Copy pathturtle.cpp
File metadata and controls
39 lines (34 loc) · 777 Bytes
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
#include "turtle.h"
#include "draw.h"
Turtle::Turtle(double x0,double y0,double deg) {
this->x = x0;
this->y = y0;
this->deg = deg;
//draw::setcolor(Color());
this->d = true;
}
void Turtle::setColor(Color c) {
this->c.red = c.red;
this->c.green = c.green;
this->c.blue = c.blue;
//draw::setcolor(c);
}
void Turtle::move(double dist) {
double x,y;
x = this->x; y = this->y;
this->x += dist*cos((this->deg*M_PI)/180 );
this->y += dist*sin((this->deg*M_PI)/180 );
if(this->d) {
draw::setcolor(c);
draw::line(x,y,this->x,this->y);
}
}
void Turtle::turn(double degree) {
this->deg += degree;
}
void Turtle::on() {
this->d = true;
}
void Turtle::off() {
this->d = false;
}