Frame 1
this.createEmptyMovieClip("snake", 0);
snake.attachMovie("lib_head", "box0", 0);
snake.box0.theSpin = 0;
snake.box0.theOut = 10;
snake.box0._xscale = 70;
snake.box0._yscale = 70;
snake.box0._y = 250;
spin = 0;
out = 50;
frameCount = 0;
xPos = Math.random() * Stage.width;
yPos = Math.random() * Stage.height;
apple._x = xPos;
apple._y = yPos;
score = 0;
turn = 0;
turnChase = 0;
moveSpeed = 10;
moveChase = moveSpeed;
speed = 60;
legsSpeed = 0;
snake.box0.onEnterFrame = function () {
legsSpeed = legsSpeed - ((legsSpeed - moveSpeed) / 4);
moveSpeed = moveSpeed - ((moveSpeed - moveChase) / 30);
turn = turn - ((turn - turnChase) / speed);
textBox.text = score;
frameCount = frameCount + 1;
if (frameCount > 100) {
frameCount = 0;
xPos = Math.random() * Stage.width;
yPos = Math.random() * Stage.height;
score = score - 0.5;
}
apple._x = apple._x - ((apple._x - xPos) / 10);
apple._y = apple._y - ((apple._y - yPos) / 10);
if (this.hitTest(apple) == true) {
frameCount = 0;
xPos = Math.random() * Stage.width;
yPos = Math.random() * Stage.height;
apple._x = xPos;
apple._y = yPos;
score = score + 1;
}
spin = spin + 10;
this.jaw._rotation = (Math.sin((Math.PI/180) * spin) * out) / 2;
this.theSpin = turn + 90;
this._x = this._x + (Math.sin((Math.PI/180) * this.theSpin) * moveSpeed);
this._y = this._y + (Math.cos((Math.PI/180) * this.theSpin) * moveSpeed);
this._rotation = (-this.theSpin) + 80;
if (this._x < 0) {
this._x = this._x + Stage.width;
}
if (this._x > Stage.width) {
this._x = this._x - Stage.width;
}
if (this._y < 0) {
this._y = this._y + Stage.height;
}
if (this._y > Stage.height) {
this._y = this._y - Stage.height;
}
};
i = 1;
while (i < 25) {
snake.attachMovie("lib_shape", "box" + i, i);
snake["box" + i].theSpin = 0;
snake["box" + i].theOut = 10;
snake["box" + i].itsI = i - 1;
snake["box" + i]._xscale = (i * 3) - 100;
snake["box" + i]._yscale = (i * 3) - 100;
snake["box" + i].onEnterFrame = function () {
this.theSpin = this.theSpin - ((this.theSpin - snake["box" + this.itsI].theSpin) / 2);
this._x = (Math.sin((Math.PI/180) * (this.theSpin - 180)) * this.theOut) + snake["box" + this.itsI]._x;
this._y = (Math.cos((Math.PI/180) * (this.theSpin - 180)) * this.theOut) + snake["box" + this.itsI]._y;
this._rotation = -this.theSpin;
};
i++;
}
this.createEmptyMovieClip("line", 3);
tailR = 0;
tailR2 = 0;
onEnterFrame = function () {
arms._x = snake.box3._x;
arms._y = snake.box3._y;
arms._rotation = snake.box3._rotation;
arms.arm1._rotation = (snake.box3._y / 5) + 100;
arms.arm1.elbow._rotation = (snake.box3._y / 5) - 90;
arms.arm2._rotation = moveSpeed + 50;
arms.arm2.elbow._rotation = (snake.box3._y / 2) - 90;
legs._x = snake.box12._x;
legs._y = snake.box12._y;
legs._rotation = snake.box12._rotation;
legs.arm1._rotation = 140 + (legsSpeed * 7);
legs.arm1.elbow._rotation = (-legsSpeed) + 40;
legs.arm2._rotation = 180 + (legsSpeed * 5);
legs.arm2.elbow._rotation = (-legsSpeed) + 40;
tail._x = snake.box24._x;
tail._y = snake.box24._y;
tailDX = tailX - snake.box24._x;
tailDY = tailY - snake.box24._y;
tail._rotation = tailR;
tailR = (Math.atan2(tailDY, tailDX) * 57.2957795130823) + 90;
tailR2 = tailR2 - ((tailR2 - tailR) / 5);
tailX = snake.box24._x;
tailY = snake.box24._y;
line.clear();
line.moveTo(snake.box0._x, snake.box0._y);
line.lineStyle(25, 0, 100);
i = 1;
while (i < 25) {
if ((((snake["box" + i]._x > 30) && (snake["box" + i]._x < (Stage.width - 30))) && (snake["box" + i]._y > 30)) && (snake["box" + i]._y < (Stage.height - 30))) {
line.lineTo(snake["box" + i]._x, snake["box" + i]._y);
line.lineStyle((-i) + 25, 0, 100);
} else {
line.lineStyle((-i) + 25, 0, 0);
}
i++;
}
};
var keyListener_obj = new Object();
resetKeys = function () {
keyListener_obj.onKeyDown = function () {
if (Key.getCode() == 38) {
}
if (Key.getCode() == 40) {
}
if (Key.getCode() == 37) {
speed = 6;
moveSpeed = 15;
moveChase = 0;
turnChase = turnChase + 80;
}
if (Key.getCode() == 39) {
speed = 6;
moveSpeed = 15;
moveChase = 0;
turnChase = turnChase + -80;
}
if (Key.getCode() == 32) {
}
delete keyListener_obj.onKeyDown;
};
};
resetKeys();
keyListener_obj.onKeyUp = function () {
if (Key.getCode() == 38) {
}
if (Key.getCode() == 40) {
}
if (Key.getCode() == 37) {
}
if (Key.getCode() == 39) {
}
if (Key.getCode() == 32) {
}
speed = 3;
moveChase = 0;
resetKeys();
};
Key.addListener(keyListener_obj);
onMouseDown = function () {
text._visible = false;
};