home *** CD-ROM | disk | FTP | other *** search
Wrap
function rotateInner() { mcInnerHolder.circle1._rotation += oGunPos.directionOuter * oGunPos.speedOuter; mcInnerHolder.circle2._rotation += oGunPos.directionOuter * oGunPos.speedOuter; mcInnerHolder.smallCircle1._rotation += oGunPos.directionInner * oGunPos.speedInner; mcInnerHolder.smallCircle2._rotation += oGunPos.directionInner * oGunPos.speedInner; mcInnerHolder.mcScoreHolder.tScore.text = "Score: " + oGunPos.score; mcInnerHolder.mcScoreHolder.tScore.border = true; mcInnerHolder.mcTimeHolder.tTime.text = Math.ceil(oGunPos.timer); var _loc2_ = new TextFormat(); _loc2_.bold = true; _loc2_.color = 0; _loc2_.size = 20; mcInnerHolder.mcScoreHolder.tScore.setTextFormat(_loc2_); var _loc1_ = new TextFormat(); _loc1_.bold = true; _loc1_.color = 102; _loc1_.size = 20; mcInnerHolder.mcTimeHolder.tTime.setTextFormat(_loc1_); oGunPos.timer -= 0.02; if(oGunPos.timer < 0) { clearInterval(nSendShot); summary(); } updateAfterEvent(); } function moveGun() { if(Key.isDown(37)) { mcInnerHolder.gun._rotation -= 1.5; oGunPos.x = Math.cos(mcInnerHolder.gun._rotation / 180 * 3.141592653589793); oGunPos.y = Math.sin(mcInnerHolder.gun._rotation / 180 * 3.141592653589793); } if(Key.isDown(39)) { mcInnerHolder.gun._rotation += 1.5; oGunPos.x = Math.cos(mcInnerHolder.gun._rotation / 180 * 3.141592653589793); oGunPos.y = Math.sin(mcInnerHolder.gun._rotation / 180 * 3.141592653589793); } if(Key.isDown(32)) { if(oGunPos.oneShot) { oGunPos.oneShot = false; oGunPos.x = Math.cos(mcInnerHolder.gun._rotation / 180 * 3.141592653589793); oGunPos.y = Math.sin(mcInnerHolder.gun._rotation / 180 * 3.141592653589793); mcShotHolder.shot._x = oGunPos.x * 225 + Stage.width / 2; mcShotHolder.shot._y = oGunPos.y * 225 + Stage.height / 2; mcShotHolder.shot._visible = true; nSendShot = setInterval(sendShot,10,oGunPos.x,oGunPos.y); } } updateAfterEvent(); } function sendShot(x, y) { mcShotHolder.shot._x += (- x) * oGunPos.speedShot; mcShotHolder.shot._y += (- y) * oGunPos.speedShot; if(mcInnerHolder.circle1.hitTest(mcShotHolder.shot._x,mcShotHolder.shot._y,true) || mcInnerHolder.circle2.hitTest(mcShotHolder.shot._x,mcShotHolder.shot._y,true) || mcInnerHolder.smallCircle1.hitTest(mcShotHolder.shot._x,mcShotHolder.shot._y,true) || mcInnerHolder.smallCircle2.hitTest(mcShotHolder.shot._x,mcShotHolder.shot._y,true)) { clearInterval(nSendShot); youLose(); } if(Math.abs(mcShotHolder.shot._x - Stage.width / 2) < 40 && Math.abs(mcShotHolder.shot._y - Stage.height / 2) < 40) { clearInterval(nSendShot); youWin(); } updateAfterEvent(); } function youWin() { oGunPos.score = oGunPos.score + 1; _root.mcShotHolder.removeMovieClip(); _root.mcInnerHolder.removeMovieClip(); newLevel(); } function youLose() { oGunPos.timer -= 10; if(oGunPos.timer < 0) { summary(); } _root.mcShotHolder.removeMovieClip(); _root.mcInnerHolder.removeMovieClip(); newLevel(); } function summary() { clearInterval(nRotInr); clearInterval(nSendShot); removeMovieClip(mcShotHolder); removeMovieClip(mcInnerHolder); _root.createEmptyMovieClip("mcSummaryHolder",_root.getNextHighestDepth()); mcSummaryHolder.attachMovie("SummarySymbol","summary",2,{_x:Stage.width / 2,_y:Stage.height / 2 + 70}); mcSummaryHolder.summary._visible = true; mcSummaryHolder.summary.onPress = function() { _root.intro(); }; var _loc2_ = SharedObject.getLocal("topScores"); if(isNaN(_loc2_.data.normal)) { _loc2_.data.normal = 0; } if(isNaN(_loc2_.data.difficult)) { _loc2_.data.difficult = 0; } if(oGunPos.choice == 1) { _loc2_.data.normal = Math.max(oGunPos.score,_loc2_.data.normal); } else { _loc2_.data.difficult = Math.max(oGunPos.score,_loc2_.data.difficult); } mcSummaryHolder.createTextField("tSummary",mcIntro.getNextHighestDepth(),Stage.width / 2 - 230,Stage.height / 2 - 90,460,180); mcSummaryHolder.tSummary.border = false; mcSummaryHolder.tSummary.wordWrap = true; if(oGunPos.choice == 1) { mcSummaryHolder.tSummary.text = "Your score was: " + oGunPos.score + "\nHighest NORMAL score on this computer: " + _loc2_.data.normal; } else { mcSummaryHolder.tSummary.text = "Your score was: " + oGunPos.score + "\nHighest DIFFICULT score on this computer: " + _loc2_.data.difficult; } var _loc3_ = new TextFormat(); _loc3_.align = "center"; _loc3_.font = "_sans"; _loc3_.color = 0; _loc3_.size = 20; mcSummaryHolder.tSummary.setTextFormat(_loc3_); } function newLevel() { removeMovieClip(mcIntro); clearInterval(nRotInr); this.createEmptyMovieClip("mcInnerHolder",this.getNextHighestDepth()); mcInnerHolder.attachMovie("circle1Symbol","circle1",mcInnerHolder.getNextHighestDepth(),{_x:Stage.width / 2,_y:Stage.height / 2}); mcInnerHolder.attachMovie("circle2Symbol","circle2",mcInnerHolder.getNextHighestDepth(),{_x:Stage.width / 2,_y:Stage.height / 2}); mcInnerHolder.attachMovie("SmallCircle1Symbol","smallCircle1",mcInnerHolder.getNextHighestDepth(),{_x:Stage.width / 2,_y:Stage.height / 2}); mcInnerHolder.attachMovie("SmallCircle2Symbol","smallCircle2",mcInnerHolder.getNextHighestDepth(),{_x:Stage.width / 2,_y:Stage.height / 2}); mcInnerHolder.attachMovie("gunSymbol","gun",mcInnerHolder.getNextHighestDepth(),{_x:Stage.width / 2,_y:Stage.height / 2}); this.createEmptyMovieClip("mcShotHolder",this.getNextHighestDepth()); mcShotHolder.attachMovie("shotSymbol","shot",mcShotHolder.getNextHighestDepth()); mcShotHolder.shot._visible = false; mcInnerHolder.createEmptyMovieClip("mcTimeHolder",mcInnerHolder.getNextHighestDepth()); mcInnerHolder.mcTimeHolder.createTextField("tTime",mcInnerHolder.mcTimeHolder.getNextHighestDepth(),Stage.width / 2 - 15,Stage.height / 2 - 10,35,30); mcInnerHolder.createEmptyMovieClip("mcScoreHolder",mcInnerHolder.getNextHighestDepth()); mcInnerHolder.mcScoreHolder.createTextField("tScore",mcInnerHolder.mcScoreHolder.getNextHighestDepth(),Stage.width - 170,50,130,30); oGunPos.oneShot = true; nRotInr = setInterval(rotateInner,10); mcInnerHolder.circle2._rotation = Math.random() * 360; mcInnerHolder.circle1._rotation = mcInnerHolder.circle2._rotation + Math.random() * (55 - oGunPos.difficultRot1) + (30 - oGunPos.difficultRot1); mcInnerHolder.smallCircle2._rotation = Math.random() * 360; mcInnerHolder.smallCircle1._rotation = mcInnerHolder.smallCircle2._rotation + Math.random() * (55 - oGunPos.difficultRot2) + (30 - oGunPos.difficultRot2); oGunPos.speedInner = Math.random() + 0.8 + oGunPos.difficultSpeed; oGunPos.directionInner = Math.random() <= 0.5 ? 1 : -1; oGunPos.speedOuter = Math.random() + 1.3 + oGunPos.difficultSpeed; oGunPos.directionOuter = oGunPos.directionInner * -1; oGunPos.speedShot = 9; } function intro() { removeMovieClip(mcSummaryHolder); removeMovieClip(mcShotHolder); removeMovieClip(mcInnerHolder); clearInterval(nRotInr); oGunPos.score = 0; oGunPos.timer = 100; _root.createEmptyMovieClip("mcIntro",_root.getNextHighestDepth()); mcIntro.createTextField("tIntro",mcIntro.getNextHighestDepth(),Stage.width / 2 - 200,Stage.height / 2 - 120,400,220); mcIntro.tIntro.border = false; mcIntro.tIntro.wordWrap = true; mcIntro.tIntro.text = "You have 100 seconds to get as many shots as you can into the center of the spinning circles. Move the spaceship around with LEFT or RIGHT arrow keys, shoot using the SPACEBAR. Every time you hit the walls you lose 10 seconds."; var _loc2_ = new TextFormat(); _loc2_.align = "center"; _loc2_.font = "_sans"; _loc2_.size = 18; mcIntro.tIntro.setTextFormat(_loc2_); mcIntro.attachMovie("NormalSymbol","mcNormal",mcIntro.getNextHighestDepth(),{_x:Stage.width / 2 - 70,_y:Stage.height / 2 + 40}); mcIntro.attachMovie("DifficultSymbol","mcDifficult",mcIntro.getNextHighestDepth(),{_x:Stage.width / 2 + 70,_y:Stage.height / 2 + 40}); mcIntro.mcNormal._xscale = 80; mcIntro.mcDifficult._xscale = 80; mcIntro.mcNormal._yscale = 80; mcIntro.mcDifficult._yscale = 80; mcIntro.mcNormal.onPress = function() { oGunPos.difficultSpeed = 0; oGunPos.difficultRot1 = 0; oGunPos.difficultRot2 = 0; oGunPos.choice = 1; _root.newLevel(); }; mcIntro.mcDifficult.onPress = function() { oGunPos.difficultSpeed = 0.3; oGunPos.difficultRot1 = 10; oGunPos.difficultRot2 = 15; oGunPos.choice = 2; _root.newLevel(); }; oGunPos.score = 0; oGunPos.timer = 100; } var oKeyListener = new Object(); oKeyListener.onKeyDown = function() { if(nKeyID == null) { nKeyID = setInterval(moveGun,10); } }; oKeyListener.onKeyUp = function() { if(nKeyID != null) { clearInterval(nKeyID); delete nKeyID; } }; var oGunPos = new Object(); Key.addListener(oKeyListener); intro();