-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathturtle.h
215 lines (208 loc) · 4.47 KB
/
turtle.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#ifndef TURTLE_WORLD_H
#define TURTLE_WORLD_H 1
#include <ege.h>
#ifndef BOOL
typedef int BOOL;
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef PIMAGE
using ege::PIMAGE;
using ege::ALICEBLUE;
using ege::ANTIQUEWHITE;
using ege::AQUA;
using ege::AQUAMARINE;
using ege::AZURE;
using ege::BEIGE;
using ege::BISQUE;
using ege::BLACK;
using ege::BLANCHEDALMOND;
using ege::BLUE;
using ege::BLUEVIOLET;
using ege::BROWN;
using ege::BURLYWOOD;
using ege::CADETBLUE;
using ege::CHARTREUSE;
using ege::CHOCOLATE;
using ege::CORAL;
using ege::CORNFLOWERBLUE;
using ege::CORNSILK;
using ege::CRIMSON;
using ege::CYAN;
using ege::DARKBLUE;
using ege::DARKCYAN;
using ege::DARKGOLDENROD;
using ege::DARKGRAY;
using ege::DARKGREEN;
using ege::DARKKHAKI;
using ege::DARKMAGENTA;
using ege::DARKOLIVEGREEN;
using ege::DARKORANGE;
using ege::DARKORCHID;
using ege::DARKRED;
using ege::DARKSALMON;
using ege::DARKSEAGREEN;
using ege::DARKSLATEBLUE;
using ege::DARKSLATEGRAY;
using ege::DARKTURQUOISE;
using ege::DARKVIOLET;
using ege::DEEPPINK;
using ege::DEEPSKYBLUE;
using ege::DIMGRAY;
using ege::DODGERBLUE;
using ege::FIREBRICK;
using ege::FLORALWHITE;
using ege::FORESTGREEN;
using ege::FUCHSIA;
using ege::GAINSBORO;
using ege::GHOSTWHITE;
using ege::GOLD;
using ege::GOLDENROD;
using ege::GRAY;
using ege::GREEN;
using ege::GREENYELLOW;
using ege::HONEYDEW;
using ege::HOTPINK;
using ege::INDIANRED;
using ege::INDIGO;
using ege::IVORY;
using ege::KHAKI;
using ege::LAVENDER;
using ege::LAVENDERBLUSH;
using ege::LAWNGREEN;
using ege::LEMONCHIFFON;
using ege::LIGHTBLUE;
using ege::LIGHTCORAL;
using ege::LIGHTCYAN;
using ege::LIGHTGOLDENRODYELLOW;
using ege::LIGHTGRAY;
using ege::LIGHTGREEN;
using ege::LIGHTPINK;
using ege::LIGHTSALMON;
using ege::LIGHTSEAGREEN;
using ege::LIGHTSKYBLUE;
using ege::LIGHTSLATEGRAY;
using ege::LIGHTSTEELBLUE;
using ege::LIGHTYELLOW;
using ege::LIGHTRED;
using ege::LIGHTMAGENTA;
using ege::LIME;
using ege::LIMEGREEN;
using ege::LINEN;
using ege::MAGENTA;
using ege::MAROON;
using ege::MEDIUMAQUAMARINE;
using ege::MEDIUMBLUE;
using ege::MEDIUMORCHID;
using ege::MEDIUMPURPLE;
using ege::MEDIUMSEAGREEN;
using ege::MEDIUMSLATEBLUE;
using ege::MEDIUMSPRINGGREEN;
using ege::MEDIUMTURQUOISE;
using ege::MEDIUMVIOLETRED;
using ege::MIDNIGHTBLUE;
using ege::MINTCREAM;
using ege::MISTYROSE;
using ege::MOCCASIN;
using ege::NAVAJOWHITE;
using ege::NAVY;
using ege::OLDLACE;
using ege::OLIVE;
using ege::OLIVEDRAB;
using ege::ORANGE;
using ege::ORANGERED;
using ege::ORCHID;
using ege::PALEGOLDENROD;
using ege::PALEGREEN;
using ege::PALETURQUOISE;
using ege::PALEVIOLETRED;
using ege::PAPAYAWHIP;
using ege::PEACHPUFF;
using ege::PERU;
using ege::PINK;
using ege::PLUM;
using ege::POWDERBLUE;
using ege::PURPLE;
using ege::RED;
using ege::ROSYBROWN;
using ege::ROYALBLUE;
using ege::SADDLEBROWN;
using ege::SALMON;
using ege::SANDYBROWN;
using ege::SEAGREEN;
using ege::SEASHELL;
using ege::SIENNA;
using ege::SILVER;
using ege::SKYBLUE;
using ege::SLATEBLUE;
using ege::SLATEGRAY;
using ege::SNOW;
using ege::SPRINGGREEN;
using ege::STEELBLUE;
using ege::TAN;
using ege::TEAL;
using ege::THISTLE;
using ege::TOMATO;
using ege::TURQUOISE;
using ege::VIOLET;
using ege::WHEAT;
using ege::WHITE;
using ege::WHITESMOKE;
using ege::YELLOW;
using ege::YELLOWGREEN;
using ege::color_t;
#endif
typedef struct
{
double x;
double y;
double angle;
} TurtleState;
void initWorld(int width,int height, double scale=1.0);
void fd(double step);
void forward(double step);
void bk(double step);
void backward(double step);
void lt(double degree);
void leftTurn(double degree);
void rt(double degree);
void rightTurn(double degree);
void pd();
void penDown();
void penUp();
void pu();
void cs();
void clear();
void clearScreen();
void home();
void setPenSize(int size);
void setPenColor(ege::color_t color);
void setSpeed(int speed);
void setRewind(int isRewind);
void setImmediate(int isImmediate);
void pause();
void hide();
void show();
void setXY(double x, double y);
void setAngle(double angle);
void turnTo(double angle);
void gotoXY(double x, double y);
double getX();
double getY();
double getAngle();
TurtleState getState();
void setState(TurtleState state);
void faceXY(double x,double y);
double randBetween(double start,double end);
void setOrigin(int x, int y);
void setCaption(const char* title);
void setBackgroundImage(PIMAGE backImg);
int setBackgroundImage(const char* filename);
int setBackgroundImage(const wchar_t* filename);
void setBackgroundColor(ege::color_t color);
void fill();
#endif