'************************************ '* * '* FIREBALL * '* BY * '* ANTHONY CLARKE * '* * '************************************ Mode 4 'start gfx mode 3 Cls LoadBMP "title2.bmp" 'display title screen Do While KeyDown <> 32 'wait for space button to be pressed Loop cls loadbmp "intro.bmp" do while keydown <> 32 loop PlayMOD STOP Mode 4 'start gfx mode 4 Cls Sprite Load "ship.spr" 'load ship sprite shipExist=0 shots = 10 'setting shots variable score=0 'setting score variable highScore=0 'Setting up high score variable laserExist=0 lasTimer=0 'Setting up laser refill powerup timer variable lasFillExist=0 'Setting up laser refill powerup existence variable lasFillX=0 'Setting up laser fill powerup x position variable lasFillY=0 'Setting up laser fill powerup y position variable 'Setting up all position variables px=120 py=100 lx=0 ly=0 fbtotal = 0 fb1x = 0 fb1y = -16 fb2x = 0 fb2y = -16 fb3x = 0 fb3y = -16 fb4x = 0 fb4y = -16 fb5x = 0 fb5y = -16 fb6x = 0 fb6y = -16 fb7x = 0 fb7y = -16 fb8x = 0 fb8y = -16 fb9x = 0 fb9y = -16 fb10x = 0 fb10y = -16 fb11x = 0 fb11y = -16 fb12x = 0 fb12y = -16 fb13x = 0 fb13y = -16 fb14x = 0 fb14y = -16 fb15x = 0 fb15y = -16 fb16x = 0 fb16y = -16 fb17x = 0 fb17y = -16 fb18x = 0 fb18y = -16 fb19x = 0 fb19y = -16 fb20x = 0 fb20y = -16 'setting up all existence variables fb1_exist = 3 fb2_exist = 3 fb3_exist = 3 fb4_exist = 3 fb5_exist = 3 fb6_exist = 3 fb7_exist = 3 fb8_exist = 3 fb9_exist = 3 fb10_exist = 3 fb11_exist = 3 fb12_exist = 3 fb13_exist = 3 fb14_exist = 3 fb15_exist = 3 fb16_exist = 3 fb17_exist = 3 fb18_exist = 3 fb19_exist = 3 fb20_exist = 3 'setting up speed variables fb_speed = 4 las_speed = 6 ship_speed = 2 Start: Sprite on 1,px,py 'draw ship sprite shipExist = 1 'set ship to exist spawntime = 1000 'set spawn time to 1 second Timer = 0 'set timer to 0 gameSpeed = 0 'overall speed variable for game Main: 'Main loop GoSub ShipControl 'run ShipControl subroutine GoSub EdgeDetect 'run edgedetect subroutine GoSub FireballControl GoSub LaserControl gosub HUD gosub powerUp GOSUB antiOverlap Pause gameSpeed 'set speed for game as determined by gameSpeed variable GoTo Main 'End of main loop FireballControl: fb1y=fb1y+fb_speed 'increment fireball's y position fb2y=fb2y+fb_speed fb3y=fb3y+fb_speed fb4y=fb4y+fb_speed fb5y=fb5y+fb_speed fb6y=fb6y+fb_speed fb7y=fb7y+fb_speed fb8y=fb8y+fb_speed fb9y=fb9y+fb_speed fb10y=fb10y+fb_speed fb11y=fb11y+fb_speed fb12y=fb12y+fb_speed fb13y=fb13y+fb_speed fb14y=fb14y+fb_speed fb15y=fb15y+fb_speed fb16y=fb16y+fb_speed fb17y=fb17y+fb_speed fb18y=fb18y+fb_speed fb19y=fb19y+fb_speed fb20y=fb20y+fb_speed If Timer > spawntime Then 'Check timer to see if spawntime has elapsed Timer = 0 lasTimer=lasTimer+1 'laser powerup timer incremented score = score+10 'add 10 to score If fb1_exist = 3 Then 'If fireballs are despawned then put them fb1_exist = 0 'in the spawn cue ElseIf fb2_exist = 3 Then fb2_exist = 0 ElseIf fb3_exist = 3 Then fb3_exist = 0 ElseIf fb4_exist = 3 Then fb4_exist = 0 ElseIf fb5_exist = 3 Then fb5_exist = 0 ElseIf fb6_exist = 3 Then fb6_exist = 0 ElseIf fb7_exist = 3 Then fb7_exist = 0 ElseIf fb8_exist = 3 Then fb8_exist = 0 ElseIf fb9_exist = 3 Then fb9_exist = 0 ElseIf fb10_exist = 3 Then fb10_exist = 0 ElseIf fb11_exist = 3 Then fb11_exist = 0 ElseIf fb12_exist = 3 Then fb12_exist = 0 ElseIf fb13_exist = 3 Then fb13_exist = 0 ElseIf fb14_exist = 3 Then fb14_exist = 0 ElseIf fb15_exist = 3 Then fb15_exist = 0 ElseIf fb16_exist = 3 Then fb16_exist = 0 ElseIf fb17_exist = 3 Then fb17_exist = 0 ElseIf fb18_exist = 3 Then fb18_exist = 0 ElseIf fb19_exist = 3 Then fb19_exist = 0 ElseIf fb20_exist = 3 Then fb20_exist = 0 EndIf EndIf If fb1_exist=0 Then 'If fireball 1 hasn't spawned then fb1x = Int(Rnd*224) 'reset fireball 1 x position to random fb1y = -16 'reset y position to -16 Sprite on 2,fb1x,fb1y,Black 'spawn fireball 1 fb1_exist=1 'mark fireball 1 as existing EndIf If fb2_exist=0 Then 'If fireball 2 hasn't spawned then fb2x= Int(Rnd*224) 'reset fireball 2 x position to random fb2y= -16 'reset fireball 2 y position to random Sprite on 3,fb2x,fb2y,Black 'spawn fireball 2 fb2_exist=1 'mark fireball 2 as existing EndIf If fb3_exist=0 Then 'If fireball 3 hasn't spawned then fb3x= Int(Rnd*224) 'reset fireball 3 x position to random fb3y= -16 'reset fireball 3 y position to random Sprite on 4,fb3x,fb3y,Black 'spawn fireball 3 fb3_exist=1 'mark fireball 3 as existing EndIf If fb4_exist=0 Then 'If fireball 4 hasn't spawned then fb4x= Int(Rnd*224) 'reset fireball 4 x position to random fb4y= -16 'reset fireball 4 y position to random Sprite on 5,fb4x,fb4y,Black 'spawn fireball 4 fb4_exist=1 'mark fireball 4 as existing EndIf If fb5_exist=0 Then 'If fireball 5 hasn't spawned then fb5x= Int(Rnd*224) 'reset fireball 5 x position to random fb5y= -16 'reset fireball 5 y position to random Sprite on 6,fb5x,fb5y,Black 'spawn fireball 5 fb5_exist=1 'mark fireball 5 as existing EndIf If fb6_exist=0 Then 'If fireball 6 hasn't spawned then fb6x= Int(Rnd*224) 'reset fireball 6 x position to random fb6y= -16 'reset fireball 6 y position to random Sprite on 7,fb6x,fb6y,Black 'spawn fireball 6 fb6_exist=1 'mark fireball 6 as existing EndIf If fb7_exist=0 Then 'If fireball 7 hasn't spawned then fb7x = Int(Rnd*224) 'reset fireball 7x position to random fb7y = -16 'reset y position to -16 Sprite on 8,fb7x,fb7y,Black 'spawn fireball 7 fb7_exist=1 'mark fireball 7 as existing EndIf If fb8_exist=0 Then 'If fireball 8 hasn't spawned then fb8x = Int(Rnd*224) 'reset fireball 8 x position to random fb8y = -16 'reset y position to -16 Sprite on 9,fb8x,fb8y,Black 'spawn fireball 8 fb8_exist=1 'mark fireball 8 as existing EndIf If fb9_exist=0 Then 'If fireball 9 hasn't spawned then fb9x = Int(Rnd*224) 'reset fireball 9 x position to random fb9y = -16 'reset y position to -16 Sprite on 10,fb9x,fb9y,Black 'spawn fireball 9 fb9_exist=1 'mark fireball 9 as existing EndIf If fb10_exist=0 Then 'If fireball 10 hasn't spawned then fb10x = Int(Rnd*224) 'reset fireball 10 x position to random fb10y = -16 'reset y position to -16 Sprite on 11,fb10x,fb10y,Black 'spawn fireball 10 fb10_exist=1 'mark fireball 10 as existing EndIf If fb11_exist=0 Then 'If fireball 11 hasn't spawned then fb11x = Int(Rnd*224) 'reset fireball 11 x position to random fb11y = -16 'reset y position to -16 Sprite on 12,fb11x,fb11y,Black 'spawn fireball 11 fb11_exist=1 'mark fireball 11 as existing EndIf If fb12_exist=0 Then 'If fireball 12 hasn't spawned then fb12x = Int(Rnd*224) 'reset fireball 12 x position to random fb12y = -16 'reset y position to -16 Sprite on 13,fb12x,fb12y,Black 'spawn fireball 12 fb12_exist=1 'mark fireball 12 as existing EndIf If fb13_exist=0 Then 'If fireball 13 hasn't spawned then fb13x = Int(Rnd*224) 'reset fireball 13 x position to random fb13y = -16 'reset y position to -16 Sprite on 14,fb13x,fb13y,Black 'spawn fireball 13 fb13_exist=1 'mark fireball 13 as existing EndIf If fb14_exist=0 Then 'If fireball 14 hasn't spawned then fb14x = Int(Rnd*224) 'reset fireball 14 x position to random fb14y = -16 'reset y position to -16 Sprite on 15,fb14x,fb14y,Black 'spawn fireball 14 fb14_exist=1 'mark fireball 14 as existing EndIf If fb15_exist=0 Then 'If fireball 15 hasn't spawned then fb15x = Int(Rnd*224) 'reset fireball 15 x position to random fb15y = -16 'reset y position to -16 Sprite on 16,fb15x,fb15y,Black 'spawn fireball 15 fb15_exist=1 'mark fireball 15 as existing EndIf If fb16_exist=0 Then 'If fireball 16 hasn't spawned then fb16x = Int(Rnd*224) 'reset fireball 16 x position to random fb16y = -16 'reset y position to -16 Sprite on 17,fb16x,fb16y,Black 'spawn fireball 16 fb16_exist=1 'mark fireball 16 as existing EndIf If fb17_exist=0 Then 'If fireball 17 hasn't spawned then fb17x = Int(Rnd*224) 'reset fireball 17 x position to random fb17y = -16 'reset y position to -16 Sprite on 18,fb17x,fb17y,Black 'spawn fireball 17 fb17_exist=1 'mark fireball 17 as existing EndIf If fb18_exist=0 Then 'If fireball 18 hasn't spawned then fb18x = Int(Rnd*224) 'reset fireball 18 x position to random fb18y = -16 'reset y position to -16 Sprite on 19,fb18x,fb18y,Black 'spawn fireball 18 fb18_exist=1 'mark fireball 18 as existing EndIf If fb19_exist=0 Then 'If fireball 19 hasn't spawned then fb19x = Int(Rnd*224) 'reset fireball 19 x position to random fb19y = -16 'reset y position to -16 Sprite on 20,fb19x,fb19y,Black 'spawn fireball 19 fb19_exist=1 'mark fireball 19 as existing EndIf If fb20_exist=0 Then 'If fireball 20 hasn't spawned then fb20x = Int(Rnd*224) 'reset fireball 20 x position to random fb20y = -16 'reset y position to -16 Sprite on 21,fb20x,fb20y,Black 'spawn fireball 20 fb20_exist=1 'mark fireball 20 as existing EndIf If fb1_exist=1 Then Sprite move 2,fb1x,fb1y,Black 'move fireball 1 sprite EndIf If fb2_exist=1 Then Sprite move 3,fb2x,fb2y,Black 'move fireball 2 sprite EndIf If fb3_exist=1 Then Sprite move 4,fb3x,fb3y,Black 'move fireball 3 sprite EndIf If fb4_exist=1 Then Sprite move 5,fb4x,fb4y,Black 'move fireball 4 sprite EndIf If fb5_exist=1 Then Sprite move 6,fb5x,fb5y,Black 'move fireball 5 sprite EndIf If fb6_exist=1 Then Sprite move 7,fb6x,fb6y,Black 'move fireball 6 sprite EndIf If fb7_exist=1 Then Sprite move 8,fb7x,fb7y,Black 'move fireball 7 sprite EndIf If fb8_exist=1 Then Sprite move 9,fb8x,fb8y,Black 'move fireball 8 sprite EndIf If fb9_exist=1 Then Sprite move 10,fb9x,fb9y,Black 'move fireball 9 sprite EndIf If fb10_exist=1 Then Sprite move 11,fb10x,fb10y,Black 'move fireball 10 sprite EndIf If fb11_exist=1 Then Sprite move 12,fb11x,fb11y,Black 'move fireball 11 sprite EndIf If fb12_exist=1 Then Sprite move 13,fb12x,fb12y,Black 'move fireball 12 sprite EndIf If fb13_exist=1 Then Sprite move 14,fb13x,fb13y,Black 'move fireball 13 sprite EndIf If fb14_exist=1 Then Sprite move 15,fb14x,fb14y,Black 'move fireball 14 sprite EndIf If fb15_exist=1 Then Sprite move 16,fb15x,fb15y,Black 'move fireball 15 sprite EndIf If fb16_exist=1 Then Sprite move 17,fb16x,fb16y,Black 'move fireball 16 sprite EndIf If fb17_exist=1 Then Sprite move 18,fb17x,fb17y,Black 'move fireball 17 sprite EndIf If fb18_exist=1 Then Sprite move 19,fb18x,fb18y,Black 'move fireball 18 sprite EndIf If fb19_exist=1 Then Sprite move 20,fb19x,fb19y,Black 'move fireball 19 sprite EndIf If fb20_exist=1 Then Sprite move 21,fb20x,fb20y,Black 'move fireball 20 sprite EndIf If fb1y > 216 Then 'If fireball 1 goes off the bottom fb1x = Int(Rnd(1)*224) 'reset x position to random fb1y = -16 'reset y position to just off the top EndIf If fb2y > 216 Then 'If fireball 2 goes off the bottom fb2x = Int(Rnd(1)*224) 'reset x position to random fb2y = -16 'reset y position to just off the top EndIf If fb3y > 216 Then 'If fireball 3 goes off the bottom fb3x = Int(Rnd(1)*224) 'reset x position to random fb3y = -16 'reset y position to just off the top EndIf If fb4y > 216 Then 'If fireball 4 goes off the bottom fb4x = Int(Rnd(1)*224) 'reset x position to random fb4y = -16 'reset y position to just off the top EndIf If fb5y > 216 Then 'If fireball 5 goes off the bottom fb5x = Int(Rnd(1)*224) 'reset x position to random fb5y = -16 'reset y position to just off the top EndIf If fb6y > 216 Then 'If fireball 6 goes off the bottom fb6x = Int(Rnd(1)*224) 'reset x position to random fb6y = -16 'reset y position to just off the top EndIf If fb7y > 216 Then 'If fireball 7 goes off the bottom fb7x = Int(Rnd(1)*224) 'reset x position to random fb7y = -16 'reset y position to just off the top EndIf If fb8y > 216 Then 'If fireball 8 goes off the bottom fb8x = Int(Rnd*224) 'reset x position to random fb8y = -16 'reset y position to just off the top EndIf If fb9y > 216 Then 'If fireball 9 goes off the bottom fb9x = Int(Rnd*224) 'reset x position to random fb9y = -16 'reset y position to just off the top EndIf If fb10y > 216 Then 'If fireball 10 goes off the bottom fb10x = Int(Rnd(1)*224) 'reset x position to random fb10y = -16 'reset y position to just off the top EndIf If fb11y > 216 Then 'If fireball 11 goes off the bottom fb11x = Int(Rnd(1)*224) 'reset x position to random fb11y = -16 'reset y position to just off the top EndIf If fb12y > 216 Then 'If fireball 12 goes off the bottom fb12x = Int(Rnd(1)*224) 'reset x position to random fb12y = -16 'reset y position to just off the top EndIf If fb13y > 216 Then 'If fireball 13 goes off the bottom fb13x = Int(Rnd(1)*224) 'reset x position to random fb13y = -16 'reset y position to just off the top EndIf If fb14y > 216 Then 'If fireball 14 goes off the bottom fb14x = Int(Rnd(1)*224) 'reset x position to random fb14y = -16 'reset y position to just off the top EndIf If fb15y > 216 Then 'If fireball 15 goes off the bottom fb15x = Int(Rnd(1)*224) 'reset x position to random fb15y = -16 'reset y position to just off the top EndIf If fb16y > 216 Then 'If fireball 16 goes off the bottom fb16x = Int(Rnd*224) 'reset x position to random fb16y = -16 'reset y position to just off the top EndIf If fb17y > 216 Then 'If fireball 17 goes off the bottom fb17x = Int(Rnd(1)*224) 'reset x position to random fb17y = -16 'reset y position to just off the top EndIf If fb18y > 216 Then 'If fireball 18 goes off the bottom fb18x = Int(Rnd(1)*224) 'reset x position to random fb18y = -16 'reset y position to just off the top EndIf If fb19y > 216 Then 'If fireball 19 goes off the bottom fb19x = Int(Rnd(1)*224) 'reset x position to random fb19y = -16 'reset y position to just off the top EndIf If fb20y > 216 Then 'If fireball 20 goes off the bottom fb20x = Int(Rnd(1)*224) 'reset x position to random fb20y = -16 'reset y position to just off the top EndIf Return ShipControl: If KeyDown = 130 Then 'if left arrow key pressed px=px-ship_speed ElseIf KeyDown = 131 Then 'if right arrow key pressed px=px+ship_speed ElseIf KeyDown = 128 Then 'if up arrow key pressed py=py-ship_speed ElseIf KeyDown = 129 Then 'if down arrow key pressed py=py+ship_speed EndIf Sprite move 1,px,py if collision(1,sprite) >0 then if shipExist = 1 and lasFillExist = 1 then if collision(1,sprite) and collision(27,sprite) > 0 then shots = 10 'Shots refill up to 10 when powerup collected sprite off 27 'cls lasFillExist = 0 lassFillTimer = 0 for x=1 to 1000 step 1 'Noise for when you pick up powerup. tone x,x,1 next x endif endif if shipExist = 1 and fb1_exist = 1 then if collision(1,sprite) and collision(2,sprite) > 0 then gosub gameOver 'Goto gameover subroutine endif endif if shipExist = 1 and fb2_exist = 1 then if collision(1,sprite) and collision(3,sprite) > 0 then gosub gameOver 'Goto gameover subroutine endif endif if shipExist = 1 and fb3_exist = 1 then if collision(1,sprite) and collision(4,sprite) > 0 then gosub gameOver 'Goto gameover subroutine endif endif if shipExist = 1 and fb4_exist = 1 then if collision(1,sprite) and collision(5,sprite) > 0 then gosub gameOver 'Goto gameover subroutine endif endif if shipExist = 1 and fb5_exist = 1 then if collision(1,sprite) and collision(6,sprite) > 0 then gosub gameOver 'Goto gameover subroutine endif endif if shipExist = 1 and fb6_exist = 1 then if collision(1,sprite) and collision(7,sprite) > 0 then gosub gameOver 'Goto gameover subroutine endif endif if shipExist = 1 and fb7_exist = 1 then if collision(1,sprite) and collision(8,sprite) > 0 then gosub gameOver 'Goto gameover subroutine endif endif if shipExist = 1 and fb8_exist = 1 then if collision(1,sprite) and collision(9,sprite) > 0 then gosub gameOver 'Goto gameover subroutine endif endif if shipExist = 1 and fb9_exist = 1 then if collision(1,sprite) and collision(10,sprite) > 0 then gosub gameOver 'Goto gameover subroutine endif endif if shipExist = 1 and fb10_exist = 1 then if collision(1,sprite) and collision(11,sprite) > 0 then gosub gameOver 'Goto gameover subroutine endif endif if shipExist = 1 and fb11_exist = 1 then if collision(1,sprite) and collision(12,sprite) > 0 then gosub gameOver 'Goto gameover subroutine endif endif if shipExist = 1 and fb12_exist = 1 then if collision(1,sprite) and collision(13,sprite) > 0 then gosub gameOver 'Goto gameover subroutine endif endif if shipExist = 1 and fb13_exist = 1 then if collision(1,sprite) and collision(14,sprite) > 0 then gosub gameOver 'Goto gameover subroutine endif endif if shipExist = 1 and fb14_exist = 1 then if collision(1,sprite) and collision(15,sprite) > 0 then gosub gameOver 'Goto gameover subroutine endif endif if shipExist = 1 and fb15_exist = 1 then if collision(1,sprite) and collision(16,sprite) > 0 then gosub gameOver 'Goto gameover subroutine endif endif if shipExist = 1 and fb16_exist = 1 then if collision(1,sprite) and collision(17,sprite) > 0 then gosub gameOver 'Goto gameover subroutine endif endif if shipExist = 1 and fb17_exist = 1 then if collision(1,sprite) and collision(18,sprite) > 0 then gosub gameOver 'Goto gameover subroutine endif endif if shipExist = 1 and fb18_exist = 1 then if collision(1,sprite) and collision(19,sprite) > 0 then gosub gameOver 'Goto gameover subroutine endif endif if shipExist = 1 and fb19_exist = 1 then if collision(1,sprite) and collision(20,sprite) > 0 then gosub gameOver 'Goto gameover subroutine endif endif if shipExist = 1 and fb20_exist = 1 then if collision(1,sprite) and collision(21,sprite) > 0 then gosub gameOver 'Goto gameover subroutine endif endif endif Return EdgeDetect: 'sprite edge detection routine If Collision(1,EDGE) = 1 Then 'if ship hits left edge px=0 ElseIf Collision(1,EDGE) = 2 Then 'if ship hits right edge px=224 ElseIf Collision(1,EDGE) = 4 Then 'if ship hits top edge py=0 ElseIf Collision(1,EDGE) = 8 Then 'if ship hits bottom edge py=200 ElseIf Collision(1,EDGE) = 5 Then 'if ship hits top and left edges px=0 py=0 ElseIf Collision(1,EDGE) = 6 Then 'if ship hits top and right edges px=224 py=0 ElseIf Collision(1,EDGE) = 9 Then 'if ship hits bottom and left edges px=0 py=200 ElseIf Collision(1,EDGE) = 10 Then 'if ship hits bottom and right edges px=224 py=200 EndIf Return LaserControl: If KeyDown = 32 And laserExist=0 AND shots>0 Then 'If space key is pressed lx = px 'Laser x position same as ship ly = py-2 'Laser y position same as ship-2 pixel Sprite on 22,lx,ly 'spawn laser laserExist = 1 'mark laser as existing shots = shots-1 'decrease shots counter by 1 'cls for x =1 to 2000 step 10 'Laser shot noise generating loop tone x,x,1 next x 'elseif keydown = 32 and laserExist=0 and shots = 0 then ' for x=1 to 200 step 1 ' tone x,x,1 ' next x EndIf If laserExist = 1 Then 'Check to see if laser exists ly=ly-las_speed 'Move laser Y position up the screen Sprite move 22,lx,ly 'Move laser to new coords If Collision(22,Edge) = 4 Then 'If laser hits top of screen Sprite off 22 'Turn the laser sprite off laserExist = 0 'Mark laser as not existing lasFillX = 0 'Reset power up X coord lasFillY = 0 'Reset powerup Y coord EndIf EndIf If laserExist = 1 Then 'If the laser exists If Collision(22,SPRITE) > 0 Then 'Is it colliding with another sprite? If fb1_exist = 1 Then 'Does fireball1 exist? If Collision(2,SPRITE) > 0 Then 'Is it colliding? for x = 23 to 26 sprite copy x to 2 pause 15 next x sprite copy 28 to 2 Sprite off 2 'If it is turn the sprite off fb1_exist = 3 'Mark fireball1 as despawned EndIf EndIf If fb2_exist = 1 Then 'Does fireball2 exist? If Collision(3,SPRITE) > 0 Then 'Is it colliding? for x = 23 to 26 sprite copy x to 3 pause 15 next x sprite copy 28 to 3 Sprite off 3 'If it is turn the sprite off fb2_exist = 3 'Mark fireball2 as despawned EndIf EndIf If fb3_exist = 1 Then 'Does fireball3 exist? If Collision(4,SPRITE) > 0 Then 'Is it colliding? for x = 23 to 26 sprite copy x to 4 pause 15 next x sprite copy 28 to 4 Sprite off 4 'If it is turn the sprite off fb3_exist = 3 'Mark fireball3 as despawned EndIf EndIf If fb4_exist = 1 Then 'Does fireball4 exist? If Collision(5,SPRITE) > 0 Then 'Is it colliding? for x = 23 to 26 sprite copy x to 5 pause 15 next x sprite copy 28 to 5 Sprite off 5 'If it is turn the sprite off fb4_exist = 3 'Mark fireball4 as despawned EndIf EndIf If fb5_exist = 1 Then 'Does fireball5 exist? If Collision(6,SPRITE) > 0 Then 'Is it colliding? for x = 23 to 26 sprite copy x to 6 pause 15 next x sprite copy 28 to 6 Sprite off 6 'If it is turn the sprite off fb5_exist = 3 'Mark fireball5 as despawned EndIf EndIf If fb6_exist = 1 Then 'Does fireball6 exist? If Collision(7,SPRITE) > 0 Then 'Is it colliding? for x = 23 to 26 sprite copy x to 7 pause 15 next x sprite copy 28 to 7 Sprite off 7 'If it is turn the sprite off fb6_exist = 3 'Mark fireball6 as despawned EndIf EndIf If fb7_exist = 1 Then 'Does fireball7 exist? If Collision(8,SPRITE) > 0 Then 'Is it colliding? for x = 23 to 26 sprite copy x to 8 pause 15 next x sprite copy 28 to 8 Sprite off 8 'If it is turn the sprite off fb7_exist = 3 'Mark fireball7 as despawned EndIf EndIf If fb8_exist = 1 Then 'Does fireball8 exist? If Collision(9,SPRITE) > 0 Then 'Is it colliding? for x = 23 to 26 sprite copy x to 9 pause 15 next x sprite copy 28 to 9 Sprite off 9 'If it is turn the sprite off fb8_exist = 3 'Mark fireball8 as despawned EndIf EndIf If fb9_exist = 1 Then 'Does fireball9 exist? If Collision(10,SPRITE) > 0 Then 'Is it colliding? for x = 23 to 26 sprite copy x to 10 pause 15 next x sprite copy 28 to 10 Sprite off 10 'If it is turn the sprite off fb9_exist = 3 'Mark fireball9 as despawned EndIf EndIf If fb10_exist = 1 Then 'Does fireball0 exist? If Collision(11,SPRITE) > 0 Then 'Is it colliding? for x = 23 to 26 sprite copy x to 11 pause 15 next x sprite copy 28 to 11 Sprite off 11 'If it is turn the sprite off fb10_exist = 3 'Mark fireball10 as despawned EndIf EndIf If fb11_exist = 1 Then 'Does fireball11 exist? If Collision(12,SPRITE) > 0 Then 'Is it colliding? for x = 23 to 26 sprite copy x to 12 pause 15 next x sprite copy 28 to 12 Sprite off 12 'If it is turn the sprite off fb11_exist = 3 'Mark fireball11 as despawned EndIf EndIf If fb12_exist = 1 Then 'Does fireball12 exist? If Collision(13,SPRITE) > 0 Then 'Is it colliding? for x = 23 to 26 sprite copy x to 13 pause 15 next x sprite copy 28 to 13 Sprite off 13 'If it is turn the sprite off fb12_exist = 3 'Mark fireball12 as despawned EndIf EndIf If fb13_exist = 1 Then 'Does fireball13 exist? If Collision(14,SPRITE) > 0 Then 'Is it colliding? for x = 23 to 26 sprite copy x to 14 pause 15 next x sprite copy 28 to 14 Sprite off 14 'If it is turn the sprite off fb13_exist = 3 'Mark fireball13 as despawned EndIf EndIf If fb14_exist = 1 Then 'Does fireball14 exist? If Collision(15,SPRITE) > 0 Then 'Is it colliding? for x = 23 to 26 sprite copy x to 15 pause 15 next x sprite copy 28 to 15 Sprite off 15 'If it is turn the sprite off fb14_exist = 3 'Mark fireball14 as despawned EndIf EndIf If fb15_exist = 1 Then 'Does fireball15 exist? If Collision(16,SPRITE) > 0 Then 'Is it colliding? for x = 23 to 26 sprite copy x to 16 pause 15 next x sprite copy 28 to 16 Sprite off 16 'If it is turn the sprite off fb15_exist = 3 'Mark fireball15 as despawned EndIf EndIf If fb16_exist = 1 Then 'Does fireball16 exist? If Collision(17,SPRITE) > 0 Then 'Is it colliding? for x = 23 to 26 sprite copy x to 17 pause 15 next x sprite copy 28 to 17 Sprite off 17 'If it is turn the sprite off fb16_exist = 3 'Mark fireball16 as despawned EndIf EndIf If fb17_exist = 1 Then 'Does fireball17 exist? If Collision(18,SPRITE) > 0 Then 'Is it colliding? for x = 23 to 26 sprite copy x to 18 pause 15 next x sprite copy 28 to 18 Sprite off 18 'If it is turn the sprite off fb17_exist = 3 'Mark fireball17 as despawned EndIf EndIf If fb18_exist = 1 Then 'Does fireball18 exist? If Collision(19,SPRITE) > 0 Then 'Is it colliding? for x = 23 to 26 sprite copy x to 19 pause 15 next x sprite copy 28 to 19 Sprite off 19 'If it is turn the sprite off fb18_exist = 3 'Mark fireball18 as despawned EndIf EndIf If fb19_exist = 1 Then 'Does fireball19 exist? If Collision(20,SPRITE) > 0 Then 'Is it colliding? for x = 23 to 26 sprite copy x to 20 pause 15 next x sprite copy 28 to 20 Sprite off 20 'If it is turn the sprite off fb19_exist = 3 'Mark fireball19 as despawned EndIf EndIf If fb20_exist = 1 Then 'Does fireball20 exist? If Collision(21,SPRITE) > 0 Then 'Is it colliding? for x = 23 to 26 sprite copy x to 21 pause 15 next x sprite copy 28 to 21 Sprite off 21 'If it is turn the sprite off fb20_exist = 3 'Mark fireball20 as despawned EndIf EndIf Sprite off 22 'Turn laser sprite off after checks laserExist = 0 'Mark laser as not existing for b = 2000 to 1 step -10 tone b,b,1 next b Cls EndIf EndIf Return HUD: print @(2,0) "Score:";score Print @(85,0)"HiScore:";highScore print @(185,0)"Shots:";shots if score > highScore then highScore=score endif 'if lasFillExist=1 and shipExist=1 then ' print @(0,50)"Plr";collision(1,sprite) ' print @(0,100)"lf";collision(27,sprite) 'debugging collision 'elseif lasFillExist=0 and shipExist=1 then ' print @(0,50)"Plr";collision(1,sprite) 'endif return powerUp: 'The amount the powerup refills in on line 623 if lasTimer > 30 and lasFillExist = 0 then 'If the powerup timer is up and no powerups exist then lasTimer = 0 'reset lastimer to 0 lasFillX=int(rnd*240) 'generate random X coord do while lasFillY < 100 'Doing this so powerups dont spawn too near the top lasFillY=Int(rnd*216) loop sprite on 27,lasFillX,lasFillY lasFillExist = 1 endif if lasFillExist = 1 then sprite move 27,lasFillX,lasFillY 'Doing this to stop fireballs from overwriting the powerup endif return gameOver: sprite off all cls font 2 print @(65,80) "Game Over" font 1 print @(90,120) "Score:";score print @(76,140) "Press r to retry" for x=5000 to 1 step -1 tone x,x,1 next x for x=1 to 5000 step 1 tone x,x,1 next x if score > highScore then highScore = score endif do while keydown <> 114 shipExist=0 shots = 10 'setting shots variable score=0 'setting score variable laserExist=0 lasTimer=0 'Setting up laser refill powerup timer variable lasFillExist=0 'Setting up laser refill powerup existence variable lasFillX=0 'Setting up laser fill powerup x position variable lasFillY=0 'Setting up laser fill powerup y position variable 'Setting up all position variables px=120 py=100 lx=0 ly=0 fbtotal = 0 fb1x = 0 fb1y = -16 fb2x = 0 fb2y = -16 fb3x = 0 fb3y = -16 fb4x = 0 fb4y = -16 fb5x = 0 fb5y = -16 fb6x = 0 fb6y = -16 fb7x = 0 fb7y = -16 fb8x = 0 fb8y = -16 fb9x = 0 fb9y = -16 fb10x = 0 fb10y = -16 fb11x = 0 fb11y = -16 fb12x = 0 fb12y = -16 fb13x = 0 fb13y = -16 fb14x = 0 fb14y = -16 fb15x = 0 fb15y = -16 fb16x = 0 fb16y = -16 fb17x = 0 fb17y = -16 fb18x = 0 fb18y = -16 fb19x = 0 fb19y = -16 fb20x = 0 fb20y = -16 'setting up all existence variables fb1_exist = 3 fb2_exist = 3 fb3_exist = 3 fb4_exist = 3 fb5_exist = 3 fb6_exist = 3 fb7_exist = 3 fb8_exist = 3 fb9_exist = 3 fb10_exist = 3 fb11_exist = 3 fb12_exist = 3 fb13_exist = 3 fb14_exist = 3 fb15_exist = 3 fb16_exist = 3 fb17_exist = 3 fb18_exist = 3 fb19_exist = 3 fb20_exist = 3 loop cls goto Start return antiOverlap:'Need to move asteroids if they're touching after respawn while their still out of sight If fb1_exist=1 and fb1y < -8 then if collision(2,sprite) >0 then 'If fireball is colliding with anything after position reset fb1x = Int(Rnd*224) 'reset x position to random fb1y = -16 'reset y position to just off the top endif endif If fb2_exist=1 and fb2y < -8 then if collision(3,sprite) >0 then 'If fireball is colliding with anything after position reset fb2x = Int(Rnd*224) 'reset x position to random fb2y = -16 'reset y position to just off the top endif endif If fb3_exist=1 and fb3y < -8 then if collision(4,sprite) >0 then 'If fireball is colliding with anything after position reset fb3x = Int(Rnd*224) 'reset x position to random fb3y = -16 'reset y position to just off the top endif endif If fb4_exist=1 and fb4y < -8 then if collision(5,sprite) >0 then 'If fireball is colliding with anything after position reset fb4x = Int(Rnd*224) 'reset x position to random fb4y = -16 'reset y position to just off the top endif endif If fb5_exist=1 and fb5y < -8 then if collision(6,sprite) >0 then 'If fireball is colliding with anything after position reset fb5x = Int(Rnd*224) 'reset x position to random fb5y = -16 'reset y position to just off the top endif endif If fb6_exist=1 and fb6y < -8 then if collision(7,sprite) >0 then 'If fireball is colliding with anything after position reset fb6x = Int(Rnd*224) 'reset x position to random fb6y = -16 'reset y position to just off the top endif endif If fb7_exist=1 and fb7y < -8 then if collision(8,sprite) >0 then 'If fireball is colliding with anything after position reset fb7x = Int(Rnd*224) 'reset x position to random fb7y = -16 'reset y position to just off the top endif endif If fb8_exist=1 and fb8y < -8 then if collision(9,sprite) >0 then 'If fireball is colliding with anything after position reset fb8x = Int(Rnd*224) 'reset x position to random fb8y = -16 'reset y position to just off the top endif endif If fb9_exist=1 and fb9y < -8 then if collision(10,sprite) >0 then 'If fireball is colliding with anything after position reset fb9x = Int(Rnd*224) 'reset x position to random fb9y = -16 'reset y position to just off the top endif endif If fb10_exist=1 and fb10y < -8 then if collision(11,sprite) >0 then 'If fireball is colliding with anything after position reset fb10x = Int(Rnd*224) 'reset x position to random fb10y = -16 'reset y position to just off the top endif endif If fb11_exist=1 and fb11y < -8 then if collision(12,sprite) >0 then 'If fireball is colliding with anything after position reset fb11x = Int(Rnd*224) 'reset x position to random fb11y = -16 'reset y position to just off the top endif endif If fb12_exist=1 and fb12y < -8 then if collision(13,sprite) >0 then 'If fireball is colliding with anything after position reset fb12x = Int(Rnd*224) 'reset x position to random fb12y = -16 'reset y position to just off the top endif endif If fb13_exist=1 and fb13y < -8 then if collision(14,sprite) >0 then 'If fireball is colliding with anything after position reset fb13x = Int(Rnd*224) 'reset x position to random fb13y = -16 'reset y position to just off the top endif endif If fb14_exist=1 and fb14y < -8 then if collision(15,sprite) >0 then 'If fireball is colliding with anything after position reset fb14x = Int(Rnd*224) 'reset x position to random fb14y = -16 'reset y position to just off the top endif endif If fb15_exist=1 and fb15y < -8 then if collision(16,sprite) >0 then 'If fireball is colliding with anything after position reset fb15x = Int(Rnd*224) 'reset x position to random fb15y = -16 'reset y position to just off the top endif endif If fb16_exist=1 and fb16y < -8 then if collision(17,sprite) >0 then 'If fireball is colliding with anything after position reset fb16x = Int(Rnd*224) 'reset x position to random fb16y = -16 'reset y position to just off the top endif endif If fb17_exist=1 and fb17y < -8 then if collision(18,sprite) >0 then 'If fireball is colliding with anything after position reset fb17x = Int(Rnd*224) 'reset x position to random fb17y = -16 'reset y position to just off the top endif endif If fb18_exist=1 and fb18y < -8 then if collision(19,sprite) >0 then 'If fireball is colliding with anything after position reset fb18x = Int(Rnd*224) 'reset x position to random fb18y = -16 'reset y position to just off the top endif endif If fb19_exist=1 and fb19y < -8 then if collision(20,sprite) >0 then 'If fireball is colliding with anything after position reset fb19x = Int(Rnd*224) 'reset x position to random fb19y = -16 'reset y position to just off the top endif endif If fb20_exist=1 and fb20y < -8 then if collision(21,sprite) >0 then 'If fireball is colliding with anything after position reset fb20x = Int(Rnd*224) 'reset x position to random fb20y = -16 'reset y position to just off the top endif endif return