Moderator: Moderators
void DrawDragonCurve (int grade)
{
float eps = 1e-4;
ARLevel level;
level.Init ();
level.loadLevel ("blank.lvl");
// blank is empty level
int i,j;
int turns;
int rotation;
float x, y;
float length;
int link_type;
turns = (1 << grade) - 1;
// 0 - up
// 1 - right
// 2 - down
// 3 - left
rotation = 0;
x = 0;
y = 0;
length = 1;
link_type = LINK_TYPE_BAR;
level.addPoint (x, y, POINT_TYPE_ANCHOR);
level.addPoint (x, y+length, POINT_TYPE_ANCHOR);
level.addLink (&level.points[0], &level.points[1], link_type);
y += length;
bool turn, found;
int i1,i2;
i1 = 1;
for (i=1; i<=turns; i++)
{
turn = (((i & -i) << 1) & i) != 0;
if (turn)
rotation++;
else
rotation--;
if (rotation < 0)
rotation += 4;
if (rotation > 3)
rotation -= 4;
switch (rotation)
{
case 0:
y += length;
break;
case 1:
x += length;
break;
case 2:
y -= length;
break;
case 3:
x -= length;
break;
}
found = false;
j = 0;
while ((j < level.points_num) && !found)
{
if ((fabs(level.points[j].x - x) < eps) && (fabs(level.points[j].y - y) < eps))
found = true;
else
j++;
}
if (found)
i2 = j;
else
{
level.addPoint (x, y, POINT_TYPE_ANCHOR);
i2 = level.points_num-1;
}
level.addLink (&level.points[i1], &level.points[i2], link_type);
i1 = i2;
}
level.saveLevel ("DragonCurve.lvl");
}
twifosp wrote:Greetings all!
I just found this forum and I'm glad to know this game doesn't end with the built in levels. A contest a week is awesome! Especially with cool levels like this. I hope I can compete on the same level as some of you!
First go 2110+
Someone posted 2700+ D... does that mean dark as in using force paddles?
Users browsing this forum: No registered users and 17 guests