Well, finally done!! Though, I will admit I started to get sloppy with my coding in the end. Though I'm not worried about it, I learned what I needed to learn from doing this project.
Screen Shot:
Source:
Rem Project: Blast Invaders
Rem Setup Screen goodies
Set Display Mode 800,600,16 : Set Window On
Set Window Layout 3,1,0 : Set Window Title "Blast Invaders V1.0"
Sync Rate 0 : Sync On : Sync Rate 30
Hide Mouse : Autocam Off : Backdrop on : Color Backdrop 0
Set Ambient Light 75
Rem Variables
Score# = 0
Dim Base#(3)
for i = 1 to 3
Base#(i)=1
next i
Enemy_X#=-220
Enemy_Z#=40
Enm_m#=-10
Fire_Rate# = 20
XM_D#=15
Dim Invaders#(10,3)
for y = 1 to 3
for x = 1 to 10
If y=1 then Invaders#(x,y)=1
If y=2 then Invaders#(x,y)=2
If y=3 then Invaders#(x,y)=3
next x
next y
Rem Load Graphics
Rem Enemies
Load Image "enemies\inv01.bmp",1,1
Load Image "enemies\inv02.bmp",2,1
Load Image "enemies\inv03.bmp",3,1
Load Image "enemies\ship01.bmp",4,1
Rem Base
Load Image "player\base01.bmp",5,1
Load Image "player\base02.bmp",6,1
Load Image "player\base03.bmp",7,1
Load Image "player\base04.bmp",8,1
Load Image "player\base05.bmp",9,1
Load Image "player\base06.bmp",10,1
Load Image "player\base07.bmp",11,1
Load Image "player\base08.bmp",12,1
Rem Player
Load Image "player\player01.bmp",13,1
Rem SFX
Load Image "sfx\laser01.bmp",14,1
Load Image "sfx\laser02.bmp",15,1
Rem Sounds
Load Sound "sound\inv01.wav",1
Load Sound "sound\fire01.wav",2
Load Sound "sound\death01.wav",3
Load Sound "sound\ship01.wav",4
Load Sound "sound\base01.wav",5
Rem Create Player and Bases
Rem Player Model
Make Object Plain 1,20,20 : Position Object 1,0,0,-210
Rotate Object 1,90,0,0 : Texture Object 1,13 : Set Object Ambient 1,1
Set object Transparency 1,1 : Set Object Filter 1,0
Rem Center Base
Make Object Plain 2,40,40 : Position Object 2,0,5,-150
Rotate Object 2,90,0,0 : Texture Object 2,5 : Set Object Ambient 2,1
Set object Transparency 2,1 : Set Object Filter 2,0
Rem Left Base
Make Object Plain 3,40,40 : Position Object 3,-190,5,-150
Rotate Object 3,90,0,0 : Texture Object 3,5 : Set Object Ambient 3,1
Set object Transparency 3,1 : Set Object Filter 3,0
Rem Right Base
Make Object Plain 4,40,40 : Position Object 4,190,5,-150
Rotate Object 4,90,0,0 : Texture Object 4,5 : Set Object Ambient 4,1
Set object Transparency 4,1 : Set Object Filter 4,0
Rem Build Monsters and Position
for m = 1 to 3
for n = 1 to 10
model_N#=(((m*10)-10)+(n-1))+100
make object plain model_N#,20,20 : texture object model_N#,Invaders#(n,m)
position object model_N#,Enemy_X#+(n*40),0,Enemy_Z#+(m*40)
rotate object model_N#,90,0,0 : Set Object Ambient model_N#,1
Set object Transparency model_N#,1 : Set Object Filter model_N#,0
next n
next m
Rem Build Space Ship
Make Object Plain 200,20,20 : Texture Object 200,4
Rotate Object 200,90,0,0 : Set Object Ambient 200,1
Set object Transparency 200,1 : Set Object Filter 200,0
Ship_P# = Rnd(1)+1
If Ship_P# = 1 then Position Object 200,600,0,180
If Ship_P# = 2 then Position Object 200,-600,0,180
Rem Camera Position
Position Camera 0,400,0 : Point Camera 0,0,0
REm text
Set Text Size 42
Rem Main Loop
Start:
Do
Rem Print Score
Text 22,22,"Score: "+STR$(Score#)
Rem Enemy Ship Code
Rem Go Left
If Ship_P# = 1
Move Object Left 200,4
If Object Position X(200)<-600 then Ship_P# = 2
Endif
Rem Go Right
If Ship_P# = 2
Move Object Right 200,4
If Object Position X(200)>600 then Ship_P# = 1
Endif
Rem Sounds
If Object In Screen(200) = 1
If Sound Looping(4) = 0 Then Loop Sound 4
Else
Stop Sound 4
Endif
Rem Ship Fires
Ship_dly# = Ship_dly# + 1
If Ship_dly# > 30
Ship_dly# = 0
If Object In Screen(200) = 1
for p = 1 to 30
if object exist(p+200)=0
make object plain p+200,20,20
position object p+200,object position x(200),5,object position z(200)
rotate object p+200,90,0,0 : Texture object p+200,15 : Set Object Ambient P+200,1
Set object Transparency p+200,1 : Set Object Filter p+200,0
Play Sound 2
goto skip_eb
endif
next p
skip_eb:
Endif
Endif
Rem Enemy Ships Fire
for r = 1 to 30
enf_A# = RND(29)+1
if Object Visible(enf_A#+99)=1 then goto end_fc
next r
end_fc:
EN_Fire# = EN_Fire# + 1
If EN_Fire# > Fire_Rate#
EN_Fire# = 0
If Object Visible(enf_A#+99)=1
for p = 1 to 30
if object exist(p+200)=0
make object plain p+200,20,20
position object p+200,object position x(enf_A#+99),5,object position z(enf_A#+99)
rotate object p+200,90,0,0 : Texture object p+200,15 : Set Object Ambient P+200,1
Set object Transparency p+200,1 : Set Object Filter p+200,0
Play Sound 2
goto skip_ec
endif
next p
skip_ec:
Endif
Endif
Rem Update Enemy Bullets
For u = 1 to 30
If Object Exist(u+200)=1
Move Object Down u+200,5
Rem Check for player hit and die
If Object Position X(u+200)>Object Position X(1)-10
If Object Position X(u+200)<Object Position X(1)+10
If Object Position Z(u+200)>Object Position Z(1)-10
If Object Position Z(u+200)<Object Position Z(1)+10
Game_O# = 1
win# = 2
Delete Object u+200
Play Sound 3 : Play Sound 5
Endif
Endif
Endif
Endif
Rem Check For Base Hit
For h = 1 to 3
If Base#(h)<8
If Object Exist(u+200)=1
If Object Position X(u+200)>Object Position X(h+1)-20
If Object Position X(u+200)<Object Position X(h+1)+20
If Object Position Z(u+200)>Object Position Z(h+1)-20
If Object Position Z(u+200)<Object Position Z(h+1)+20
Base#(h)=Base#(h)+1
Delete Object u+200
Play Sound 5
Endif
Endif
Endif
Endif
Endif
Endif
Next h
If Object Exist(u+200)=1
If Object Position z(u+200)<-350 then delete object u+200
Endif
Endif
Next u
Rem Update Base
For h = 1 to 3
Texture Object h+1,Base#(h)+4
Next h
Rem Ship Kill
For s = 1 to 10
If Object Exist(s+20)
If Object Position Z(s+20)>Object Position Z(200)-10
If Object Position Z(s+20)<Object Position Z(200)+10
If Object Position X(s+20)>Object Position X(200)-10
If Object Position X(s+20)<Object Position X(200)+10
Ship_P# = RND(1)+1
If Ship_P# = 1 then Position Object 200,800,0,180
If Ship_P# = 2 then Position Object 200,-800,0,180
Play Sound 3
Score# = Score# + 50
Delete Object s+20
Endif
Endif
Endif
Endif
Endif
next s
Rem Update Monsters and Movement
XM_dly#=XM_dly#+1
If XM_dly#>XM_D#
Enemy_X#=Enemy_X#+Enm_m#
If Enemy_X#<-250 then Enm_m#=10 : Enemy_Z#=Enemy_Z#-10
If Enemy_X#>-180 then Enm_M#=-10 : Enemy_Z#=Enemy_Z#-10
XM_dly#=0
for m = 1 to 3
for n = 1 to 10
model_N#=(((m*10)-10)+(n-1))+100
position object model_N#,Enemy_X#+(n*40),0,Enemy_Z#+(m*40)
next n
next m
Endif
Rem Monster Hit Bases
If Enemy_Z#<-160
for q = 1 to 10
If Invaders#(q,1)>0 then Game_O#=1
win#=2
next q
Endif
If Enemy_Z#<-200
for w = 1 to 10
If Invaders#(w,2)>0 then Game_O#=1
win#=2
next w
Endif
If Enemy_Z#<-240
for e = 1 to 10
If Invaders#(e,3)>0 then Game_O#=1
win#=2
next e
Endif
Rem Kill All Monsters Win
kill_all#=0
For g = 1 to 3
For h = 1 to 10
kill_all#=kill_all#+Invaders#(h,g)
Next h
Next g
If kill_all#=0
Game_O# = 1
win#=1
Endif
Rem Game Over Code
If Game_O# > 0
for y = 1 to 3
for x = 1 to 10
If y=1 then Invaders#(x,y)=1
If y=2 then Invaders#(x,y)=2
If y=3 then Invaders#(x,y)=3
model_N#=(((y*10)-10)+(x-1))+100
Show Object model_N#
next x
next y
Enemy_X#=-220
Enemy_Z#=40
Enm_m#=-10
If win# = 2
for i = 1 to 3
Base#(i)=1
next i
XM_D#=15
else
for i = 1 to 3
Base#(i)=Base#(i)-4
if Base#(i)<1 then Base#(i)=1
next i
XM_D#=XM_D#-1
If XM_D#<5 then XM_D#=5
Endif
for k = 1 to 10
if object exist(k+20)=1 then delete object k+20
next k
for l = 1 to 30
if object exist(l+200)=1 then delete object l+200
next l
Rem Game Over
Game_Over:
If win#=1 then Center Text 400,300,"INCOMING NEXT WAVE!"
If win#=2 then Center Text 400,300,"GAME OVER!"
Center Text 400,350,"Your Score: "+STR$(Score#)
Game_O# = Game_O# + 1
If Game_O# = 100
if win# = 1
Fire_Rate#=Fire_Rate#-2
if Fire_Rate#<2 then Fire_Rate#=2
Endif
if win# = 2 then Score# = 0 : Fire_Rate#=20
Game_O# = 0
Goto Start
Endif
sync
Goto Game_Over
Endif
Rem Player Control
Rem Move
If Rightkey()=1 then Move Object Right 1,5
If Leftkey()=1 then Move Object Left 1,5
Rem Fire
If fire=3
dly=dly+1
If dly=10
dly=0
fire=0
Endif
Endif
If fire=0
If Spacekey()=1
fire=1
Play Sound 2
Endif
Endif
If fire=1
for f = 1 to 10
If Object Exist(f+20) = 0
Make Object Plain f+20,20,20 : Position Object f+20,Object Position x(1),Object Position y(1)+5,Object Position z(1)
Rotate Object f+20,90,0,0 : Texture Object f+20,14 : Set Object Ambient f+20,1
Set object Transparency f+20,1 : Set Object Filter f+20,0
fire=3 : goto no_fire
Endif
next f
Endif
no_fire:
Rem Update Bullets
for k = 1 to 10
If Object Exist(k+20) = 1
Move Object Up k+20,5
If Object Position z(k+20)>350 then Delete Object k+20
Rem Collision And destruction with enemy
For v = 1 to 3
For b = 1 to 10
If Invaders#(b,v)>0
If Object Exist(k+20)
model_K#=(((v*10)-10)+(b-1))+100
If Object Position Z(k+20) > Object Position Z(model_K#)-10
If Object Position Z(k+20) < Object Position Z(model_K#)+10
If Object Position X(k+20) > Object POsition X(model_K#)-10
If Object Position X(k+20) < Object Position X(model_K#)+10
If Invaders#(b,v) = 1 then Score# = Score#+5
If Invaders#(b,v) = 2 then Score# = Score#+10
If Invaders#(b,v) = 3 then Score# = Score#+15
Invaders#(b,v)=0
Delete Object k+20
Hide Object model_K#
Play Sound 3
Endif
Endif
Endif
Endif
Endif
Endif
Next b
Next v
Endif
next k
sync
Loop
and attached game at the bottom. ENJOY!
BWM
"I wish I was a wizard, becuase then I could wave my wand and perfect code would just appear."