stop();
playBtn.onRelease = function (){
gotoAndStop ("play");
}
rulesBtn.onRelease = function (){
gotoAndStop ("rules");
}
timerSpider.play();
init();
function init() {
// init spider DY
spider1.dy = 2;
spider2.dy = 4;
spider3.dy = 3;
// init scoreKeeping
hands.score = 0;
hands.lives = 5;
//sound Files
sndGotcha = new Sound();
sndGotcha.attachSound("gotcha.wav");
}
//end init
hands.onEnterFrame = function() {
// start moving hands
movehands();
//start keys are not needed for this game
//checkKeys();
// start spider movement
move(spider1);
move(spider2);
move(spider3);
// start collision detection
collision();
//checking for Boundaries
checkBoundaries();
};
//end hands
function movehands() {
hands._x = _root._xmouse;
Mouse.hide();
}
//end movehands
function checkKeys() {
if (Key.isDown(key.SPACE)) {
missle._x = hands._x;
missle._y = hands._y;
missle.dy = -40;
}
//end IF
}
//end CheckKeys
/* Missle command not used for this game
missle.onEnterFrame = function() {
missle._y += missle.dy;
};
//end Missle */
function move(sprite) {
sprite._y += sprite.dy*5;
sprite._y += Math.random();
}
//end moveSprite
function reset(sprite) {
sprite._x = Math.random()*Stage.width;
sprite._y += -500;
}
//end resetSprite
function resetMissle() {
missle._x = -200;
missle._y = 200;
}
//end resetMissle
function checkBoundaries() {
// check spider stage boundaries
if (spider1._y>Stage.height+50) {
reset(spider1);
trace("spider 1 reset");
hands.lives --;
if (hands.lives<=0) {
_root.gotoAndPlay("gameOver");
}
}
//end IF
if (spider2._y>Stage.height+50) {
reset(spider2);
trace("spider 2 reset");
hands.lives --;
if (hands.lives<=0) {
_root.gotoAndPlay("gameOver");
}
}
//end IF
if (spider3._y>Stage.height+50) {
reset(spider3);
trace("spider 3 reset");
hands.lives --;
if (hands.lives<=0) {
_root.gotoAndPlay("gameOver");
}
}
//end IF
/*check missle boundaries NOTUSED
if (missle._y<-30) {
resetMissle();
trace("Missle reset");
}
end IF */
}
//end CHECKBOUNDARIES
function collision() {
// hands hitTest
if (hands.hitTest(spider1)) {
reset(spider1);
sndGotcha.start();
//trace("you got hit by 1");
_root.hands.score += 100;
if (hands.score>=10000) {
_root.gotoAndPlay("gameWin");
}
//end IF
}
//end IF
if (hands.hitTest(spider2)) {
reset(spider2);
//trace("you got hit by 2");
_root.hands.score += 100;
if (hands.score>=10000) {
_root.gotoAndPlay("gameWin");
}
//end IF
}
//end IF
if (hands.hitTest(spider3)) {
//trace("you got hit by 3");
reset(spider3);
_root.hands.score += 100;
if (hands.score>=10000) {
_root.gotoAndPlay("gameWin");
}
//end IF
}
//end IF
}
// end COLLISION
Mouse.show();
playBtn.onRelease = function (){
_root.gotoAndStop("play");
}
stop();
Mouse.show();
playBtn.onRelease = function() {
_root.gotoAndStop("play");
};
stop();
init();
function init() {
spider1.dy = 1;
}
playBtn.onRelease = function() {
_root.gotoAndStop("play");
};
hands.onEnterFrame = function() {
// start moving hands
movehands();
move(spider1);
checkBoundaries();
//checkKeys();
};
function movehands() {
hands._x = _root._xmouse;
}
function move(sprite) {
sprite._y += sprite.dy*5;
sprite._y += Math.random();
}
//end moveSprite
function reset(sprite) {
sprite._x = Math.random()*Stage.width;
sprite._y += -500;
}
function checkBoundaries() {
// check spider stage boundaries
if (spider1._y>Stage.height+50) {
reset(spider1);
trace("spider 1 reset");
}
if (hands.hitTest(spider1)) {
reset(spider1);
//trace("you got hit by 1");
}
}
Also here is a link to the source file.