Space Wave by soapyfish20th Mar 2004 9:26
|
---|
Summary My first complete game in DBP, There were some aspects I struggled with such as bullet movement, bonus enemies etc so I posted it here for all to see. Description You pilot a spaceship at the bottom of the screen moving left and right. You have to shoot enemies coming from the top of the screen Which get faster and faster as the levels go up. Your allowd to let 5 enemies get past you before you lose a life. Every so often a yellow bonus star will appear, shooting this nets you 500 points missing it does nothing but letting it hit you loses you 500 points. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com Rem Project: Space Wave Rem Created: 04/03/2004 17:40:53 ` COPYRIGHT Oliver Fishwick 2004 ` Created in 10 days Rem ***** Main Source File ***** set display mode 800,600,32 hide mouse backdrop off cls rgb(10,10,10) randomize timer() plx#=350 ply#=540 bux#=350 buy#=540 enx#=(rnd(800)) eny#=-100 score#=0 target#=100 level#=1 enspeed#=1 lives=3 missed=5 enemies_shot=0 stry#=-10000 strx#=(rnd(600)) strspeed#=2 sync on load image "player ship.bmp",1 sprite 1,plx#,ply#,1 spritewidth=(sprite width(1)/2) spriteheight=(sprite height(1)/2) offset sprite 1,spritewidth,spriteheight hide sprite 1 load image "bullet.bmp",2 sprite 2,bux#,buy#,2 spritewidth=(sprite width(2)/2) spriteheight=(sprite height(2)/2) offset sprite 2,spritewidth,spriteheight hide sprite 2 load image "enemy grunt.bmp",3 sprite 3,enx#,eny#,3 hide sprite 3 load image "explosion.bmp",4 sprite 4,enx#,eny#,4 hide sprite 4 load image "player explosion.bmp",5 sprite 5,plx#,ply#,5 spritewidth=(sprite width(5)/2) spriteheight=(sprite height(5)/2) offset sprite 5,spritewidth,spriteheight hide sprite 5 load image "start screen.bmp",6,1 sprite 6,0,0,6 hide sprite 6 load image "bonus star.bmp",7 sprite 7,strx#,stry#,7 load image "bonus star shot.bmp",8 sprite 8,strx#,stry#,8 hide sprite 8 load image "bonus star miss.bmp",9 sprite 9,strx#,stry#,9 hide sprite 9 load image "logo.bmp",10,1 sprite 10,20,150,10 load music "background.mid",1 load sound "explosion.wav",1 load sound "next level.wav",2 load sound "points up.wav",3 load sound "points down.wav",4 load sound "chimp.wav",5 play sound 5 repeat sync x=x+1 until x=500 delete sprite 10 delete sound 5 show sprite 6 repeat sync until returnkey()=1 delete sprite 6 `%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% main_loop: do loop music 1 gosub player_movement gosub bullet_movement gosub enemy_movement gosub collision_detection gosub player_stats sync loop `%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% `&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& player_movement: if eny#>-30 show sprite 1 show sprite 3 hide sprite 5 sprite 1,plx#,ply#,1 sprite 5,ply#,plx#,5 if leftkey()=1 plx#=plx#-1.75 endif if plx#<0 then plx#=0 if leftkey()=1 and buy#=540 bux#=bux#-1.75 else buy#=buy#-0 endif if bux#<0 then bux#=0 if rightkey()=1 and buy#=540 bux#=bux#+1.75 else bux=bux+0 endif if bux#>800 then bux#=800 if rightkey()=1 plx#=plx#+1.75 endif if plx#>800 then plx#=800 sprite 1,plx#,ply#,1 sprite 2,bux#,buy#,2 endif return `&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& bullet_movement: if spacekey()=1 show sprite 2 bullet_move=1 endif if bullet_move=1 buy#=buy#-2 endif if buy#<0 bullet_move=2 endif if bullet_move=2 bux#=plx# buy#=ply# hide sprite 2 endif return `&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& enemy_movement: eny#=eny#+enspeed# if eny#>600 missed=missed-1 eny#=0 enx#=(rnd(600)) endif sprite 3,enx#,eny#,3 stry#=stry#+strspeed# if stry#>600 strx#=(rnd(600)) stry#=-10000 endif sprite 7,strx#,stry#,7 return `&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& collision_detection: if sprite hit(2,3) and buy#<540 enemies_shot=enemies_shot+10 play sound 1 show sprite 4 eny#=-30 enx#=(rnd(600)) bullet_move=2 score#=score#+10 endif if eny#>10 hide sprite 4 sprite 4,enx#,eny#,4 endif if sprite hit(1,3) play sound 1 lives=lives-1 eny#=-100 hide sprite 1 show sprite 5 endif sprite 1,plx#,ply#,1 sprite 5,plx#,ply#,5 if sprite hit (2,7) and buy#<540 play sound 3 enemies_shot=enemies_shot+500 show sprite 8 stry#=-10000 strx#=(rnd(600)) bullet_move=2 score#=score#+500 endif if stry#>-9000 hide sprite 8 sprite 8,strx#,stry#,8 endif if sprite hit(1,7) and stry#>0 play sound 4 show sprite 9 stry#=-10000 strx#=(rnd(600)) bullet_move=2 score#=score#-500 enemies_shot=enemies_shot-500 endif if stry#>-9000 hide sprite 9 sprite 9,strx#,stry#,9 endif return `&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& player_stats: set text size 18 set text to bold text 10,10,"score "+str$(score#) center text 370,10,"level "+str$(level#) text 10,30,"miss"+str$(missed) text 10,50,"lives "+str$(lives) if target#=score# target#=target#*2 level#=level#+1 play sound 2 enspeed#=enspeed#+0.25 endif if enemies_shot=>1000 lives=lives+1 level#=level#+1 enemies_shot=0 enspeed#=enspeed#+0.25 endif if lives=1 center text 370,30,"NEAR DEATH" endif if missed=0 lives=lives-1 missed=5 endif if lives=0 hide all sprites stop music 1 set text size 40 center text 370,280,"GAME OVER" set text size 15 center text 700,580,"copyright Oliver Fishwick 2004" center text 370,330,"Enter=Try Again" center text 370,350,"Esc=Exit" center text 370,380,"Programming&Graphics Oliver Fishwick" center text 370,390,"Logo Design Michael Eddie" center text 370,400,"Sound PartnersInRhyme" center text 370,410,"Thanks to everyone on the DarkBASIC forums!!!" if returnkey()=1 lives=3 score#=0 enemies_shot=0 show sprite 3 show sprite 7 if escapekey()=1 end endif endif endif return |