Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var rate = Math.round(World.frameRate * 0.01) + 120
- Enem = ["AlienP","AlienY","AlienT","AlienG","AlienB"]
- EnemSize = ["0.5","0.6","0.7","0.8","0.9","1"]
- spawnarea = ["-30","30"]
- dontallow = 1
- var Background = createSprite(200,200)
- var Ghost = createSprite(200,200);
- var Score = createSprite(65,65)
- var PowerTitle = createSprite(250,390)
- PowerTitle.setAnimation("PowerTitle")
- PowerTitle.scale = 0.7
- var Power = createSprite(330,370)
- var Shield = createSprite(0,-70,150,150)
- Shield.visible = 0
- b = 0
- r = 0
- Score.scale = 0.8
- Score.setAnimation("Lives3")
- z = 0
- y = 0
- Ghost.setAnimation("ghostNeutral")
- Fdir = "N"
- var invis = "false"
- var Shot = "false"
- var ShotT = "False"
- Run()
- draw()
- function draw(){
- World.frameRate = rate
- if (e > 4)
- {var vel12 = "8"}
- else if (e > 6)
- {var vel12 = "10"}
- else if (e > 8)
- {var vel12 = "12"}
- else
- {var vel12 = "5"}
- if (e > 15)
- {var vel12N = "-3"}
- else if (e > 23)
- {var vel12N = "-4"}
- else if (e > 26)
- {var vel12N = "-5"}
- else
- {var vel12N = "-4"
- var vel12 = "6"}
- GX = Ghost.x;
- GY = Ghost.y;
- EnemPick = randomNumber(0,4)
- SizePick = randomNumber(0,5)
- VelPicked = randomNumber(2,vel12)
- SizePicked = EnemSize[SizePick]
- EnemPicked = Enem[EnemPick]
- EnemLoc = randomNumber(0,400)
- EnemPick1 = randomNumber(0,4)
- SizePick1 = randomNumber(0,5)
- SizePicked1 = EnemSize[SizePick1]
- EnemPicked1 = Enem[EnemPick1]
- EnemLoc1 = randomNumber(0,400)
- VelPicked1 = randomNumber(2,vel12)
- EnemPick2 = randomNumber(0,4)
- SizePick2 = randomNumber(0,5)
- SizePicked2 = EnemSize[SizePick2]
- EnemPicked2 = Enem[EnemPick2]
- EnemLoc2 = randomNumber(0,400)
- VelPicked2 = randomNumber(2,vel12)
- EnemPick3 = randomNumber(0,4)
- SizePick3 = randomNumber(0,5)
- SizePicked3 = EnemSize[SizePick3]
- EnemPicked3 = Enem[EnemPick3]
- EnemLoc3 = randomNumber(0,400)
- VelPicked3 = randomNumber(-3,vel12N)
- EnemPick4 = randomNumber(0,4)
- SizePick4 = randomNumber(0,5)
- SizePicked4 = EnemSize[SizePick4]
- EnemPicked4 = Enem[EnemPick4]
- EnemLoc4 = randomNumber(0,400)
- VelPicked4 = randomNumber(-3,vel12N)
- EnemPick5 = randomNumber(0,4)
- SizePick5 = randomNumber(0,5)
- SizePicked5 = EnemSize[SizePick5]
- EnemPicked5 = Enem[EnemPick5]
- EnemLoc5 = randomNumber(0,400)
- VelPicked5 = randomNumber(-3,vel12N)
- if (GX > 375) { Ghost.velocityX = 0; Ghost.x = GX - 1.5}
- if (GY > 370) { Ghost.velocityY = 0; Ghost.y = GY - 1.5}
- if (GX < 25 ) { Ghost.velocityX = 0; Ghost.x = GX + 1.5}
- if (GY < 30 ) { Ghost.velocityY = 0; Ghost.y = GY + 1.5}
- drawSprites()
- Background.setAnimation("Background")
- Background.scale = 0.53
- if (keyWentDown("W")){var Direction = "Wdown"} else if (keyWentUp("W")){var Direction = "Wup"}
- if (keyWentDown("S")){var Direction = "Sdown"} else if (keyWentUp("S")){var Direction = "Sup"}
- if (keyWentDown("A")){var Direction = "Adown"} else if (keyWentUp("A")){var Direction = "Aup"}
- if (keyWentDown("D")){var Direction = "Ddown"} else if (keyWentUp("D")){var Direction = "Dup"}
- if (keyWentDown("space")){var ShotN = "true"} else {ShotN = "false"}
- if (keyWentDown("up")){ ShotD = "up"; ShotT = "True"}
- if (keyWentDown("down")){ ShotD = "down"; ShotT = "True"}
- if (keyWentDown("left")){ ShotD = "left"; ShotT = "True"}
- if (keyWentDown("right")){ ShotD = "right"; ShotT = "True"}
- if (keyDown("q")){ Invis = "true"} else {Invis = "false"}
- switch(Direction){ case "undefined": Fdir = "N"}
- switch(Direction){ case "Wdown": Ghost.velocityY = -4.5; var Fdir = "U"}
- switch(Direction){ case "Wup": Ghost.velocityY = 0; Fdir = "N"}
- switch(Direction){ case "Sdown": Ghost.velocityY = 4.5; var Fdir = "D" }
- switch(Direction){ case "Sup": Ghost.velocityY = 0; Fdir = "N"}
- switch(Direction){ case "Adown": Ghost.velocityX = -4.5; var Fdir = "L"}
- switch(Direction){ case "Aup": Ghost.velocityX = 0; Fdir = "N"}
- switch(Direction){ case "Ddown": Ghost.velocityX = 4.5; var Fdir = "R"}
- switch(Direction){ case "Dup": Ghost.velocityX = 0; Fdir = "N"}
- switch(Fdir){case "L": Ghost.setAnimation("ghostLeft") }
- switch(Fdir){case "R": Ghost.setAnimation("ghostRight") }
- switch(Fdir){case "U": Ghost.setAnimation("ghostUp") }
- switch(Fdir){case "D": Ghost.setAnimation("ghostDown") }
- switch(Fdir){case "N": Ghost.setAnimation("ghostNeutral") }
- switch(ShotT) {
- case "True":
- if (ShotN == "true"){
- if (ShotD == "up"){ShootUp(); }
- if (ShotD == "down"){ShootDown();}
- if (ShotD == "left"){ShootLeft();}
- if (ShotD == "right"){ShootRight();}
- }
- break;
- case "False":
- }
- if (g == 0) {
- Power.setAnimation("Power0")
- }
- if (g == 1) {
- Power.setAnimation("Power1")
- }
- if (g == 2) {
- Power.setAnimation("Power2")
- }
- if (g == 3) {
- Power.setAnimation("Power3")
- }
- if (g == 4) {
- Power.setAnimation("Power4")
- }
- if (g == 5) {
- Power.setAnimation("Power5")
- }
- if (g < 5) {} else {
- if (Invis == "false") {
- }else {
- Ghost.tint = "Cyan"
- Shield.visible = 1
- Shield.scale = 1.8
- Shield.setAnimation("Shield")
- setInterval(locUp,0)
- function locUp(){
- Shield.x = Ghost.x
- Shield.y = Ghost.y
- Shield.rotationSpeed = 5
- }
- setTimeout(function(){Ghost.tint = "none"; Setnow(); Shield.scale = 0.01},3000)
- }
- }
- }
- ShootUp();
- Shot1.destroy()
- ShootDown();
- Shot2.destroy()
- ShootLeft();
- Shot3.destroy()
- ShootRight();
- Shot4.destroy()
- function ShootUp(){
- Shot1 = createSprite(GX,GY)
- Shot1.setAnimation("Shot")
- Shot1.velocityY = -6
- Shot1.scale = 0.4
- Shot1.rotationSpeed = 10
- drawSprites()
- }
- function ShootDown(){
- Shot2 = createSprite(GX,GY)
- Shot2.setAnimation("Shot")
- Shot2.velocityY = 5
- Shot2.scale = 0.4
- Shot2.rotationSpeed = 10
- drawSprites()
- }
- function ShootLeft(){
- Shot3 = createSprite(GX,GY)
- Shot3.setAnimation("Shot")
- Shot3.velocityX = -5
- Shot3.scale = 0.4
- Shot3.rotationSpeed = 10
- drawSprites()
- }
- function ShootRight(){
- Shot4 = createSprite(GX,GY)
- Shot4.setAnimation("Shot")
- Shot4.velocityX = 5
- Shot4.scale = 0.4
- Shot4.rotationSpeed = 10
- drawSprites()
- }
- var TimeSpawn = "5000"
- setInterval(spawn,TimeSpawn)
- spawn()
- Run()
- function spawn(){
- if (e > 1){
- var life = 300
- } else {
- var life = 0}
- if (e > 3) {
- var life1 = 300
- } else {
- var life1 = 0
- }
- if (e > 13) {
- var life2 = 300
- } else {
- life2 = 0
- }
- if (e > 16) {
- var life3 = 300
- } else {
- var life3 = 0
- }
- if (e > 20){
- var life4 = 300
- }else {
- var life4 = 0
- }
- Enemy1 = createSprite(-30,EnemLoc)
- Enemy1.setAnimation(EnemPicked);
- Enemy1.velocityX = VelPicked;
- Enemy1.scale = SizePicked;
- Enemy1.lifetime = 300;
- Enemy2 = createSprite(-30,EnemLoc1);
- Enemy2.setAnimation(EnemPicked1);
- Enemy2.velocityX = VelPicked1;
- Enemy2.scale = SizePicked1;
- Enemy2.lifetime = life;
- Enemy3 = createSprite(-30,EnemLoc1);
- Enemy3.setAnimation(EnemPicked1);
- Enemy3.velocityX = VelPicked1;
- Enemy3.scale = SizePicked1;
- Enemy3.lifetime = life1;
- Enemy4 = createSprite(430,EnemLoc3);
- Enemy4.setAnimation(EnemPicked3);
- Enemy4.velocityX = VelPicked3;
- Enemy4.scale = SizePicked3;
- Enemy4.lifetime = life2;
- Enemy5 = createSprite(430,EnemLoc4);
- Enemy5.setAnimation(EnemPicked4);
- Enemy5.velocityX = VelPicked4;
- Enemy5.scale = SizePicked4;
- Enemy5.lifetime = life3;
- Enemy6 = createSprite(430,EnemLoc5);
- Enemy6.setAnimation(EnemPicked5);
- Enemy6.velocityX = VelPicked5;
- Enemy6.scale = SizePicked5;
- Enemy6.lifetime = life4;
- }
- setInterval(function(){
- if ( Shield.isTouching(Enemy1)){
- Enemy1.destroy()}
- if ( Shield.isTouching(Enemy2)){
- Enemy2.destroy()}
- if ( Shield.isTouching(Enemy3)){
- Enemy3.destroy()}
- if ( Shield.isTouching(Enemy4)){
- Enemy4.destroy()}
- if ( Shield.isTouching(Enemy5)){
- Enemy5.destroy()}
- if ( Shield.isTouching(Enemy6)){
- Enemy6.destroy()}
- if (Enemy1.isTouching(Ghost) || Enemy2.isTouching(Ghost) || Enemy3.isTouching(Ghost) || Enemy4.isTouching(Ghost) || Enemy5.isTouching(Ghost) || Enemy6.isTouching(Ghost)){
- if (Enemy1.isTouching(Ghost)){Enemy1.destroy()}
- if (Enemy2.isTouching(Ghost)){Enemy2.destroy()}
- if (Enemy3.isTouching(Ghost)){Enemy3.destroy()}
- if (Enemy4.isTouching(Ghost)){Enemy4.destroy()}
- if (Enemy5.isTouching(Ghost)){Enemy5.destroy()}
- if (Enemy6.isTouching(Ghost)){Enemy6.destroy()}
- l = z++
- if (l == 0) {
- Score.setAnimation("Lives2");
- }
- if (l == 1){
- Score.setAnimation("Lives1");
- }
- if (l == 2){
- Score.setAnimation("Lives0");
- gameover()
- }
- function gameover(){
- var gameover = createSprite(200,200);
- gameover.scale = 1.5;
- gameover.setAnimation("Gameover")
- Ghost.destroy();
- setInterval(function(){Enemy1.destroy(); Enemy1.destroy(); Enemy1.destroy(); Enemy1.velocityX = 0; Enemy1.lifetime = 0; Enemy1.scale = 0.01; Ghost.velocityX = 0; Ghost.velocityY = 0;},0)
- setInterval(function(){Enemy2.destroy(); Enemy2.destroy(); Enemy2.destroy(); Enemy2.velocityX = 0; Enemy2.lifetime = 0; Enemy2.scale = 0.01; Ghost.velocityX = 0; Ghost.velocityY = 0;},0)
- setInterval(function(){Enemy3.destroy(); Enemy3.destroy(); Enemy3.destroy(); Enemy3.velocityX = 0; Enemy3.lifetime = 0; Enemy3.scale = 0.01; Ghost.velocityX = 0; Ghost.velocityY = 0;},0)
- setInterval(function(){Enemy4.destroy(); Enemy4.destroy(); Enemy4.destroy(); Enemy4.velocityX = 0; Enemy4.lifetime = 0; Enemy4.scale = 0.01; Ghost.velocityX = 0; Ghost.velocityY = 0;},0)
- setInterval(function(){Enemy5.destroy(); Enemy5.destroy(); Enemy5.destroy(); Enemy5.velocityX = 0; Enemy5.lifetime = 0; Enemy5.scale = 0.01; Ghost.velocityX = 0; Ghost.velocityY = 0;},0)
- setInterval(function(){Enemy6.destroy(); Enemy6.destroy(); Enemy6.destroy(); Enemy6.velocityX = 0; Enemy6.lifetime = 0; Enemy6.scale = 0.01; Ghost.velocityX = 0; Ghost.velocityY = 0;},0)
- }}},0)
- setInterval(function(){
- if(Shot3.x < 5 ){
- Shot3.destroy()
- } else if (Shot4.x > 400){
- Shot4.destroy()
- }
- if(Enemy1.isTouching(Shot1) || Enemy1.isTouching(Shot2) || Enemy1.isTouching(Shot3) || Enemy3.isTouching(Shot4) ){Shot1.destroy(); Shot2.destroy(); Shot3.destroy(); Shot4.destroy(); Enemy1.velocityX = "0"; Enemy1.tint = "red"; setTimeout(function() {Enemy1.destroy(); PointAdd() },320); }
- if(Enemy2.isTouching(Shot1) || Enemy2.isTouching(Shot2) || Enemy2.isTouching(Shot3) || Enemy2.isTouching(Shot4) ){Shot1.destroy(); Shot2.destroy(); Shot3.destroy(); Shot4.destroy(); Enemy2.velocityX = "0"; Enemy2.tint = "red"; setTimeout(function() {Enemy2.destroy(); PointAdd() },320); }
- if(Enemy3.isTouching(Shot1) || Enemy3.isTouching(Shot2) || Enemy3.isTouching(Shot3) || Enemy3.isTouching(Shot4) ){Shot1.destroy(); Shot2.destroy(); Shot3.destroy(); Shot4.destroy(); Enemy3.velocityX = "0"; Enemy3.tint = "red"; setTimeout(function() {Enemy3.destroy(); PointAdd() },320); }
- if(Enemy4.isTouching(Shot1) || Enemy4.isTouching(Shot2) || Enemy4.isTouching(Shot3) || Enemy4.isTouching(Shot4) ){Shot1.destroy(); Shot2.destroy(); Shot3.destroy(); Shot4.destroy(); Enemy4.velocityX = "0"; Enemy4.tint = "red"; setTimeout(function() {Enemy4.destroy(); PointAdd() },320); }
- if(Enemy5.isTouching(Shot1) || Enemy5.isTouching(Shot2) || Enemy5.isTouching(Shot3) || Enemy5.isTouching(Shot4) ){Shot1.destroy(); Shot2.destroy(); Shot3.destroy(); Shot4.destroy(); Enemy5.velocityX = "0"; Enemy5.tint = "red"; setTimeout(function() {Enemy5.destroy(); PointAdd() },320); }
- if(Enemy6.isTouching(Shot1) || Enemy6.isTouching(Shot2) || Enemy6.isTouching(Shot3) || Enemy6.isTouching(Shot4) ){Shot1.destroy(); Shot2.destroy(); Shot3.destroy(); Shot4.destroy(); Enemy6.velocityX = "0"; Enemy6.tint = "red"; setTimeout(function() {Enemy6.destroy(); PointAdd() },320); }
- },0)
- var Score1 = ["","Points1","Points2","Points3","Points4","Points5","Points6","Points7","Points8","Points9"];
- var score = createSprite(250,45);
- var score1 = createSprite(300,40);
- var score2 = createSprite(280,40);
- score.setAnimation("Score")
- score.scale = 0.4
- score1.scale = 0.5
- score2.scale = 0.5
- PointAdd()
- function PointAdd(){
- var h = y++;
- if (h == 0) {score1.setAnimation("Points0"); score2.setAnimation("Points0")}
- if (h == 1) {score1.setAnimation("Points1"); score2.setAnimation("Points0")}
- if (h == 2) {score1.setAnimation("Points2"); score2.setAnimation("Points0")}
- if (h == 3) {score1.setAnimation("Points3"); score2.setAnimation("Points0")}
- if (h == 4) {score1.setAnimation("Points4"); score2.setAnimation("Points0")}
- if (h == 5) {score1.setAnimation("Points5"); score2.setAnimation("Points0")}
- if (h == 6) {score1.setAnimation("Points6"); score2.setAnimation("Points0")}
- if (h == 7) {score1.setAnimation("Points7"); score2.setAnimation("Points0")}
- if (h == 8) {score1.setAnimation("Points8"); score2.setAnimation("Points0")}
- if (h == 9) {score1.setAnimation("Points9"); score2.setAnimation("Points0")}
- if (h == 10) {score1.setAnimation("Points0"); score2.setAnimation("Points1")}
- if (h == 11) {score1.setAnimation("Points1"); score2.setAnimation("Points1")}
- if (h == 12) {score1.setAnimation("Points2"); score2.setAnimation("Points1")}
- if (h == 13) {score1.setAnimation("Points3"); score2.setAnimation("Points1")}
- if (h == 14) {score1.setAnimation("Points4"); score2.setAnimation("Points1")}
- if (h == 15) {score1.setAnimation("Points5"); score2.setAnimation("Points1")}
- if (h == 16) {score1.setAnimation("Points6"); score2.setAnimation("Points1")}
- if (h == 17) {score1.setAnimation("Points7"); score2.setAnimation("Points1")}
- if (h == 18) {score1.setAnimation("Points8"); score2.setAnimation("Points1")}
- if (h == 19) {score1.setAnimation("Points9"); score2.setAnimation("Points1")}
- if (h == 20) {score1.setAnimation("Points0"); score2.setAnimation("Points2")}
- if (h == 21) {score1.setAnimation("Points1"); score2.setAnimation("Points2")}
- if (h == 22) {score1.setAnimation("Points2"); score2.setAnimation("Points2")}
- if (h == 23) {score1.setAnimation("Points3"); score2.setAnimation("Points2")}
- if (h == 24) {score1.setAnimation("Points4"); score2.setAnimation("Points2")}
- if (h == 25) {score1.setAnimation("Points5"); score2.setAnimation("Points2")}
- if (h == 26) {score1.setAnimation("Points6"); score2.setAnimation("Points2")}
- if (h == 27) {score1.setAnimation("Points7"); score2.setAnimation("Points2")}
- if (h == 28) {score1.setAnimation("Points8"); score2.setAnimation("Points2")}
- if (h == 29) {score1.setAnimation("Points9"); score2.setAnimation("Points2")}
- if (h == 30) {score1.setAnimation("Points0"); score2.setAnimation("Points3")}
- if (h == 31) {score1.setAnimation("Points1"); score2.setAnimation("Points3")}
- if (h == 32) {score1.setAnimation("Points2"); score2.setAnimation("Points3")}
- if(h++){
- Run()
- }
- }
- Setnow()
- function Setnow(){
- g = 0
- b = 1
- }
- function Run(){
- e = r++
- g = b++
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement