Frame 1
posx = new Array();
posy = new Array();
snakelength = 10;
x = 210;
t = 0;
while (t < snakelength) {
posx[t] = x;
posy[t] = 190;
x = x + 10;
t++;
}
init = 1;
foods = 0;
score = 0;
Frame 2
if (init == 1) {
t = 0;
while (t < snakelength) {
nn = "body" add t;
duplicateMovieClip ("body", nn, t);
t++;
}
init = 0;
}
if (head.up == 1) {
by = head._y;
bx = head._x;
head._y = head._y - 10;
}
if (head.up == -1) {
by = head._y;
bx = head._x;
head._y = head._y + 10;
}
if (head.left == 1) {
by = head._y;
bx = head._x;
head._x = head._x - 10;
}
if (head.left == -1) {
by = head._y;
bx = head._x;
head._x = head._x + 10;
}
t = snakelength - 1;
while (0 < t) {
posx[t] = posx[t - 1];
posy[t] = posy[t - 1];
t--;
}
posx[0] = bx;
posy[0] = by;
t = 0;
while (t < snakelength) {
nn = "body" add t;
setProperty(nn, _x , posx[t]);
setProperty(nn, _y , posy[t]);
t++;
}
if ((((head._x < 10) || (380 < head._x)) || (head._y < 50)) || (380 < head._y)) {
crash._x = head._x;
crash._y = head._y;
head._visible = false;
crash.gotoAndPlay(1);
gotoAndStop (4);
}
t = 2;
while (t < snakelength) {
if ((head._x == posx[t]) and (head._y == posy[t])) {
crash._x = head._x;
crash._y = head._y;
head._visible = false;
crash.gotoAndPlay(1);
gotoAndStop (4);
}
t++;
}
if ((food._x == head._x) && (head._y == food._y)) {
foods = 0;
score = Number(score) + 9;
duplicateMovieClip ("body", "body" add snakelength, snakelength);
snakelength = snakelength + 1;
posx[snakelength - 2] = posx[snakelength - 3];
posy[snakelength - 2] = posy[snakelength - 3];
}
if (foods != 1) {
x = random(360) + 10;
y = random(320) + 50;
x = x / 10;
y = y / 10;
x = int(x);
y = int(y);
x = x * 10;
y = y * 10;
food._x = x;
food._y = y;
foods = 1;
}
Frame 3
gotoAndPlay (2);
Symbol 7 Button
on (keyPress "<Up>") {
if (up == 0) {
up = 1;
if (left == 1) {
headinhead._rotation = 90;
} else {
headinhead._rotation = -90;
}
left = 0;
}
}
on (keyPress "<Down>") {
if (up == 0) {
up = -1;
left = 0;
}
}
on (keyPress "<Left>") {
if (left == 0) {
up = 0;
left = 1;
}
}
on (keyPress "<Right>") {
if (left == 0) {
up = 0;
left = -1;
}
}
Symbol 8 MovieClip Frame 1
stop();
up = 0;
left = 1;
Symbol 29 MovieClip Frame 14
stop();
Symbol 38 Button
on (release, keyPress "<Enter>") {
t = 0;
while (t < snakelength) {
nn = "body" add t;
removeMovieClip(nn);
t++;
}
gotoAndPlay (1);
}