Combined Code
frame 1 {
ifFrameLoaded (10) {
gotoAndPlay(3);
}
}
movieClip 4 {
}
movieClip 5 {
}
frame 2 {
gotoAndPlay(1);
}
frame 3 {
stop();
}
button 14 {
on (release) {
gotoAndPlay(4);
}
}
frame 4 {
mleft = 1;
mright = 0;
mup = 0;
mdown = 0;
food = 0;
tails = 2;
eaten = 0;
points = 0;
time = 0;
}
frame 5 {
dead = 0;
if (!food) {
randomy = 16 * random(25);
randomx = 16 * random(25);
/food._x = randomx + 8;
/food._y = randomy + 8;
food = 1;
tellTarget ('/food') {
gotoAndStop(2);
}
}
if (mleft) {
if (/worm._x != 8) {
lastx = /worm._x;
lasty = /worm._y;
/worm._x = /worm._x - 16;
/worm._rotation = 0;
} else {
dead = 1;
}
} else {
if (mright) {
if (/worm._x != 392) {
lastx = /worm._x;
lasty = /worm._y;
/worm._x = /worm._x + 16;
/worm._rotation = 180;
} else {
dead = 1;
}
} else {
if (mup) {
if (/worm._y != 8) {
lastx = /worm._x;
lasty = /worm._y;
/worm._y = /worm._y - 16;
/worm._rotation = 90;
} else {
dead = 1;
}
} else {
if (mdown) {
if (/worm._y != 392) {
lastx = /worm._x;
lasty = /worm._y;
/worm._y = /worm._y + 16;
/worm._rotation = 270;
} else {
dead = 1;
}
}
}
}
}
currenttail = 1;
while (tails >= currenttail) {
usex = lastx;
usey = lasty;
lastx = (eval('/tail' add currenttail))._x;
lasty = (eval('/tail' add currenttail))._y;
eval('/tail' add currenttail)._x = usex;
eval('/tail' add currenttail)._y = usey;
++currenttail;
}
fcurrentx = /food._x;
fcurrenty = /food._y;
wcurrentx = /worm._x;
wcurrenty = /worm._y;
if (wcurrentx == fcurrentx && wcurrenty == fcurrenty) {
food = 0;
tellTarget ('/food') {
gotoAndStop(1);
}
eaten += 1;
points += 64;
if (eaten % 2 == 0) {
_root.tail1.duplicateMovieClip('tail' + (tails + 1), tails + 1);
eval('/tail' add tails)._x = usex;
eval('/tail' add tails)._y = usey;
tails += 1;
}
}
if (!dead) {
currenttail = 1;
while (tails >= currenttail) {
if (/worm._x == (eval('/tail' add currenttail))._x) {
if (/worm._y == (eval('/tail' add currenttail))._y) {
dead = 1;
break;
}
}
++currenttail;
}
}
if (dead) {
gotoAndPlay(8);
}
}
movieClip 28 {
}
instance worm of movieClip 28 {
onClipEvent (keyDown) {
if (Key.isDown(Key.LEFT)) {
if (!../:mright) {
../:mleft = 1;
../:mright = 0;
../:mup = 0;
../:mdown = 0;
}
}
if (Key.isDown(Key.RIGHT)) {
if (!../:mleft) {
../:mleft = 0;
../:mright = 1;
../:mup = 0;
../:mdown = 0;
}
}
if (Key.isDown(Key.UP)) {
if (!../:mdown) {
../:mleft = 0;
../:mright = 0;
../:mup = 1;
../:mdown = 0;
}
}
if (Key.isDown(Key.DOWN)) {
if (!../:mup) {
../:mleft = 0;
../:mright = 0;
../:mup = 0;
../:mdown = 1;
}
}
}
}
movieClip 29 {
frame 1 {
stop();
}
}
movieClip 31 {
}
movieClip 32 {
}
frame 6 {
gotoAndPlay(5);
}
frame 8 {
currenttail = 3;
while (tails >= currenttail) {
eval('/tail' add currenttail)._visible = false;
++currenttail;
}
}
frame 9 {
stop();
}