Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package
- {
- import flash.display.MovieClip;
- import flash.events.Event;
- import flash.ui.Keyboard;
- import flash.net.SharedObject;
- public class Ship extends MovieClip
- {
- var firstpart:Boolean = false;
- var nreleased:Boolean = false;
- var storystarted:Boolean = false;
- var storyended:Boolean = false;
- var preleased:Boolean = false;
- var mreleased:Boolean = false;
- var roundtimer:Number;
- var timeplayed:Number;
- var randomBallTimer:Number;
- var xVelocity:Number;
- var yVelocity:Number;
- var shootTimer:Number;
- var shootTimerVar:Number;
- var thrust:Number;
- var thrustVar:Number;
- var brakesVar:Number;
- var topSpeedVar:Number;
- var ShieldPower:Number;
- var turnSpeedVar:Number;
- var numberOfBulletsVar:Number;
- var invuln:Boolean = false;
- var invulnUsed:Boolean = false;
- var invulnTimer:Number;
- var isduck:Boolean = false;
- var Round:Number;
- var timesteleported:Number;
- var skipstory:Boolean = false;
- var savedData:SharedObject;
- function Ship()
- {
- Round = 0;
- invulnTimer = 0;
- randomBallTimer = 0;
- thrust = 0;
- yVelocity = 0;
- xVelocity = 5;
- shootTimer = 0;
- roundtimer = 1800;
- savedData = SharedObject.getLocal("newtest7");
- if (savedData.data.timesteleported == undefined)
- {
- trace('bananananananna');
- timesteleported = 0;
- timeplayed = 0;
- numberOfBulletsVar = 1;
- turnSpeedVar = 1;
- ShieldPower = 1;
- shootTimerVar = 1;
- topSpeedVar = 1;
- brakesVar = 1;
- thrustVar = 1;
- }
- else
- {
- timesteleported = savedData.data.timesteleported;
- timeplayed = savedData.data.timesplayed;
- numberOfBulletsVar = savedData.data.numberOfBulletsVar;
- turnSpeedVar = savedData.data.turnSpeedVar;
- ShieldPower = savedData.data.ShieldPower;
- shootTimerVar = savedData.data.shootTimerVar;
- topSpeedVar = savedData.data.topSpeedVar;
- brakesVar = savedData.data.brakesVar;
- thrustVar = savedData.data.thrustVar;
- }
- this.x = 300;
- this.y = 200;
- addEventListener("enterFrame", move);
- }
- function saveg(e:Event)
- {
- savedData.data.timesteleported = timesteleported;
- savedData.data.timeplayed = timeplayed;
- savedData.data.numberOfBulletsVar = numberOfBulletsVar;
- savedData.data.turnSpeedVar = turnSpeedVar;
- ShieldPower = savedData.data.ShieldPower;
- savedData.data.shootTimerVar = shootTimerVar;
- savedData.data.topSpeedVar = topSpeedVar;
- savedData.data.brakesVar = brakesVar;
- savedData.data.thrustVar = thrustVar;
- }
- function changemode()
- {
- if (isduck == false)
- {
- gotoAndPlay(1);
- shipinvuln.visible = false;
- }
- if (isduck == true)
- {
- if (Game.duckyach == false && shootTimerVar == 1)
- {
- Game.updateach("Achievement Unlocked: DUCKY!");
- Game.updateScore(3000);
- Game.duckyach = true;
- Game.achMenu.duck.gotoAndStop(2);
- }
- gotoAndPlay(6);
- duckinvuln.visible = false;
- }
- }
- function die()
- {
- Game.timesdied += 1;
- firstpart = false;
- this.visible = false;
- Game.gameOver();
- roundtimer = 1800;
- storystarted = false;
- storyended = false;
- Game.soundbutton.togglestyle();
- }
- function thestory()
- {
- if (storyended == true)
- {
- if (skipstory == false)
- {
- thrust = 0;
- if (Round == 1 && firstpart == false)
- {
- Game.Story.visible = false;
- roundtimer = 0;
- firstpart = true;
- }
- else
- {
- Game.Story.visible = false;
- Round += 1;
- roundtimer = 0;
- Game.soundbutton.togglestyle();
- }
- }
- else
- {
- if (Round == 1 && firstpart == false)
- {
- roundtimer = 0;
- firstpart = true;
- }
- else
- {
- Game.Story.visible = false;
- Round += 1;
- roundtimer = 0;
- Game.soundbutton.togglestyle();
- }
- }
- }
- if (storystarted == false)
- {
- if (skipstory == false)
- {
- Game.Story.visible = true;
- if (firstpart == false)
- {
- Game.Story.gotoAndStop(1);
- }
- else
- {
- Game.Story.gotoAndStop(Round*10+1);
- }
- storystarted = true;
- if (firstpart == true)
- {
- Game.soundbutton.togglestyle();
- }
- }
- else
- {
- storystarted = true;
- roundtimer = 0;
- }
- }
- }
- function move(e:Event)
- {
- trace(ShieldPower);
- if (roundtimer == 30)
- {
- storystarted = false;
- storyended = false;
- Game.soundbutton.togglestyle();
- trace("banana");
- }
- if (Key.isDown(78))
- {
- if (nreleased)
- {
- if (Game.Story.visible == true)
- {
- Game.Story.nextFrame();
- }
- }
- nreleased = false;
- }
- else
- {
- nreleased = true;
- }
- if (Game.gameOverMenu.visible == true)
- {
- Game.gameOver();
- }
- if (Key.isDown(80))
- {
- if (preleased)
- {
- Game.Paused = ! Game.Paused;
- }
- preleased = false;
- }
- else
- {
- preleased = true;
- }
- if (Game.Paused == false)
- {
- if (Game.mainMenu.visible == false)
- {
- roundtimer += 1;
- }
- if (roundtimer >= 1800 && this.visible == true)
- {
- Game.enemyShipTimer.stop();
- Game.enemyShip2Timer.stop();
- Game.enemyShip3Timer.stop();
- Game.enemyShip4Timer.stop();
- Game.enemyShip5Timer.stop();
- if (Game.list.length == 0)
- {
- thestory();
- this.x = 200;
- this.y = 300;
- rotation = 0;
- }
- }
- if (Game.enemieskilled == 1)
- {
- if (Game.asteroidkillerach == false)
- {
- Game.updateach("Achievement Unlocked: Asteroid Killer");
- Game.updateScore(500);
- Game.asteroidkillerach = true;
- Game.achMenu.akil.gotoAndStop(2);
- }
- }
- if (timesteleported == 1)
- {
- if (Game.teleported1time == false)
- {
- Game.updateach("Achievement Unlocked: OH HAI THERE!");
- Game.updateScore(500);
- Game.teleported1time = true;
- Game.achMenu.ohha.gotoAndStop(2);
- }
- }
- if (timesteleported == 100)
- {
- if (Game.teleported1time == false)
- {
- Game.updateach("Achievement Unlocked: One small step for asteroid hunters");
- Game.updateScore(3000);
- Game.teleported100time = true;
- Game.achMenu.Step.gotoAndStop(2);
- }
- }
- if (timesteleported == 1000)
- {
- if (Game.teleported1000time == false)
- {
- Game.updateach("Achievement Unlocked: One giant leap for asteroid hunters kind");
- Game.updateScore(5000);
- Game.teleported1000time = true;
- Game.achMenu.leap.gotoAndStop(2);
- }
- }
- if (Game.enemieskilled == 100)
- {
- if (Game.asteroidkiller2ach == false)
- {
- Game.updateach("Achievement Unlocked: Asteroid Hunter");
- Game.updateScore(1200);
- Game.asteroidkiller2ach = true;
- Game.achMenu.ahun.gotoAndStop(2);
- }
- }
- if (Game.enemieskilled == 1337)
- {
- if (Game.asteroidkiller3ach == false)
- {
- Game.updateach("Achievement Unlocked: 1337 asteroid Killer");
- Game.updateScore(1337);
- Game.asteroidkillerach = true;
- Game.achMenu.leet.gotoAndStop(2);
- }
- }
- if (Game.enemieskilled == 9001)
- {
- if (Game.asteroidkiller4ach == false)
- {
- Game.updateach("Achievement Unlocked: ITS OVER 9000!");
- Game.updateScore(9001);
- Game.asteroidkillerach = true;
- Game.achMenu.over.gotoAndStop(2);
- }
- }
- if (timeplayed == 1800)
- {
- if (Game.a1minuteplayed == false)
- {
- Game.updateach("Achievement Unlocked: Wading the waters");
- Game.updateScore(1000);
- Game.a1minuteplayed = true;
- Game.achMenu.wadi.gotoAndStop(2);
- }
- }
- if (timeplayed == 9000)
- {
- if (Game.a5minuteplayed == false)
- {
- Game.updateach("Achievement Unlocked: Being a player");
- Game.updateScore(3000);
- Game.a5minuteplayed = true;
- Game.achMenu.bein.gotoAndStop(2);
- }
- }
- if (timeplayed == 27000)
- {
- if (Game.a15minuteplayed == false)
- {
- Game.updateach("Achievement Unlocked: Gamer");
- Game.updateScore(5000);
- Game.a15minuteplayed = true;
- Game.achMenu.game.gotoAndStop(2);
- }
- }
- if (timeplayed == 54000)
- {
- if (Game.a30minuteplayed == false)
- {
- Game.updateach("Achievement Unlocked: Must not...");
- Game.updateScore(1000);
- Game.a30minuteplayed = true;
- Game.achMenu.must.gotoAndStop(2);
- }
- }
- if (timeplayed == 108000)
- {
- if (Game.a60minuteplayed == false)
- {
- Game.updateach("Achievement Unlocked: GO OUTSIDE!");
- Game.updateScore(15000);
- Game.a60minuteplayed = true;
- Game.achMenu.goou.gotoAndStop(2);
- }
- }
- Game.achtimer += 1;
- if (Game.achtimer > 150)
- {
- Game.updateach('');
- }
- if (Round == 1)
- {
- Game.enemyShipTimer.start();
- Game.enemyShip5Timer.stop();
- Game.enemyShip4Timer.stop();
- Game.enemyShip3Timer.stop();
- Game.enemyShip2Timer.stop();
- }
- if (Round == 2)
- {
- Game.enemyShipTimer.stop();
- Game.enemyShip2Timer.start();
- }
- if (Round == 3)
- {
- Game.enemyShipTimer.start();
- Game.enemyShip2Timer.start();
- }
- if (Round == 5)
- {
- Game.enemyShip2Timer.stop();
- Game.enemyShipTimer.start();
- Game.enemyShip3Timer.start();
- }
- if (Round == 6)
- {
- Game.enemyShipTimer.start();
- Game.enemyShip2Timer.start();
- Game.enemyShip3Timer.start();
- }
- if (Round == 7)
- {
- Game.enemyShip3Timer.stop();
- Game.enemyShip2Timer.start();
- Game.enemyShip4Timer.start();
- Game.enemyShipTimer.start();
- }
- if (Round == 8)
- {
- Game.enemyShipTimer.stop();
- Game.enemyShip2Timer.start();
- Game.enemyShip4Timer.start();
- Game.enemyShip3Timer.start();
- }
- if (Round == 10)
- {
- Game.enemyShip4Timer.stop();
- Game.enemyShip3Timer.start();
- Game.enemyShip2Timer.start();
- Game.enemyShip5Timer.start();
- }
- if (ShieldPower > 5 && Game.shrunk == false)
- {
- width = width * .7;
- height = height * .7;
- Game.shrunk = true;
- }
- if (ShieldPower > 2 && Game.grown == false)
- {
- width = width * 1.2;
- height = height * 1.2;
- Game.grown = true;
- }
- if (this.visible == true)
- {
- if (Game.Paused == false && Game.Story.visible == false)
- {
- timeplayed += 1;
- if (invulnUsed == true)
- {
- invulnTimer += 1;
- if (isduck == false)
- {
- shipinvuln.visible = true;
- }
- if (isduck == true)
- {
- duckinvuln.visible = true;
- if (Game.nduckyach == false)
- {
- Game.updateach("Achievement Unlocked: Ninja Duck");
- Game.updateScore(1000);
- Game.nduckyach = true;
- Game.achMenu.ninj.gotoAndStop(2);
- }
- }
- }
- if (invulnTimer >= 90)
- {
- if (isduck == false)
- {
- shipinvuln.visible = false;
- }
- if (isduck == true)
- {
- duckinvuln.visible = false;
- }
- invuln = false;
- }
- this.y = this.y + yVelocity;
- this.x = this.x + xVelocity;
- xVelocity = Math.cos(rotation * Math.PI / 180) * thrust;
- yVelocity = Math.sin(rotation * Math.PI / 180) * thrust;
- if (this.x >= 600)
- {
- timesteleported += 1;
- this.x = 1;
- }
- if (this.x <= 0)
- {
- timesteleported += 1;
- this.x = 599;
- }
- if (this.y <= 0)
- {
- timesteleported += 1;
- this.y = 599;
- }
- if (this.y >= 600)
- {
- timesteleported += 1;
- this.y = 1;
- }
- if (ShieldPower > 9)
- {
- randomBallTimer += 1;
- }
- shootTimer += 1;
- if (Key.isDown(Keyboard.SPACE) && randomBallTimer >= 40)
- {
- var randomball = new RandomBall();
- stage.addChild(randomball);
- randomball.rotation = this.rotation;
- randomball.x = this.x;
- randomball.y = this.y;
- randomBallTimer = 0;
- }
- if (Key.isDown(Keyboard.SPACE) && shootTimer >= 20 - shootTimerVar * 1)
- {
- var bullets = new Bullet();
- stage.addChild(bullets);
- bullets.rotation = this.rotation;
- bullets.x = this.x;
- bullets.y = this.y;
- shootTimer = 0;
- if (numberOfBulletsVar > 1)
- {
- var bullets1 = new Bullet1();
- stage.addChild(bullets1);
- bullets1.rotation = this.rotation;
- bullets1.x = this.x;
- bullets1.y = this.y;
- shootTimer = 0;
- }
- if (numberOfBulletsVar > 2)
- {
- var bullets2 = new Bullet2();
- stage.addChild(bullets2);
- bullets2.rotation = this.rotation;
- bullets2.x = this.x;
- bullets2.y = this.y;
- shootTimer = 0;
- }
- if (numberOfBulletsVar > 3)
- {
- var bullets3 = new Bullet3();
- stage.addChild(bullets3);
- bullets3.rotation = this.rotation;
- bullets3.x = this.x;
- bullets3.y = this.y;
- shootTimer = 0;
- }
- if (numberOfBulletsVar > 4)
- {
- var bullets4 = new Bullet4();
- stage.addChild(bullets4);
- bullets4.rotation = this.rotation;
- bullets4.x = this.x;
- bullets4.y = this.y;
- shootTimer = 0;
- }
- if (numberOfBulletsVar > 5)
- {
- var bullets5 = new Bullet5();
- stage.addChild(bullets5);
- bullets5.rotation = this.rotation;
- bullets5.x = this.x;
- bullets5.y = this.y;
- shootTimer = 0;
- }
- if (numberOfBulletsVar > 6)
- {
- var bullets6 = new Bullet6();
- stage.addChild(bullets6);
- bullets6.rotation = this.rotation;
- bullets6.x = this.x;
- bullets6.y = this.y;
- shootTimer = 0;
- }
- if (numberOfBulletsVar > 7)
- {
- var bullets7 = new Bullet7();
- stage.addChild(bullets7);
- bullets7.rotation = this.rotation;
- bullets7.x = this.x;
- bullets7.y = this.y;
- shootTimer = 0;
- }
- if (numberOfBulletsVar > 8)
- {
- var bullets8 = new Bullet8();
- stage.addChild(bullets8);
- bullets8.rotation = this.rotation;
- bullets8.x = this.x;
- bullets8.y = this.y;
- shootTimer = 0;
- }
- if (numberOfBulletsVar > 9)
- {
- var bullets9 = new Bullet9();
- stage.addChild(bullets9);
- bullets9.rotation = this.rotation;
- bullets9.x = this.x;
- bullets9.y = this.y;
- shootTimer = 0;
- }
- if (numberOfBulletsVar > 9)
- {
- bullets1.width = bullets1.width * 1.3;
- bullets1.height = bullets1.height * 1.3;
- bullets2.width = bullets2.width * 1.3;
- bullets2.height = bullets2.height * 1.3;
- bullets3.width = bullets3.width * 1.3;
- bullets3.height = bullets3.height * 1.3;
- bullets4.width = bullets4.width * 1.3;
- bullets4.height = bullets4.height * 1.3;
- bullets5.width = bullets5.width * 1.3;
- bullets5.height = bullets5.height * 1.3;
- bullets6.width = bullets6.width * 1.3;
- bullets6.height = bullets6.height * 1.3;
- bullets7.width = bullets7.width * 1.3;
- bullets7.height = bullets7.height * 1.3;
- bullets8.width = bullets8.width * 1.3;
- bullets8.height = bullets8.height * 1.3;
- bullets9.width = bullets9.width * 1.3;
- bullets9.height = bullets9.height * 1.3;
- }
- }
- if (Key.isDown(Keyboard.RIGHT))
- {
- this.rotation += turnSpeedVar * 0.5 + 1.5;
- }
- if (Key.isDown(Keyboard.LEFT))
- {
- this.rotation -= turnSpeedVar * 0.5 + 1.5;
- }
- if (Key.isDown(68))
- {
- this.rotation += turnSpeedVar * 0.5 + 1.5;
- }
- if (Key.isDown(65))
- {
- this.rotation -= turnSpeedVar * 0.5 + 1.5;
- }
- if (Key.isDown(191) && invulnUsed == false && ShieldPower > 10)
- {
- invuln = true;
- invulnUsed = true;
- }
- if (Key.isDown(81) && invulnUsed == false && ShieldPower > 10)
- {
- invuln = true;
- invulnUsed = true;
- }
- if (Key.isDown(87))
- {
- if (thrust <= topSpeedVar * 1.5 + 1)
- {
- thrust += thrustVar / 50 + .1;
- }
- }
- if (Key.isDown(Keyboard.UP))
- {
- if (thrust <= topSpeedVar * 1.5 + 1)
- {
- thrust += thrustVar / 50 + .1;
- }
- }
- if (Key.isDown(83))
- {
- if (thrust >= 0)
- {
- thrust -= brakesVar / 40 + .1;
- }
- if (thrust <= 0)
- {
- thrust = 0;
- }
- }
- if (Key.isDown(Keyboard.DOWN))
- {
- if (thrust >= 0)
- {
- thrust -= brakesVar / 40 + .1;
- }
- if (thrust <= 0)
- {
- thrust = 0;
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement