Post by ilavos on Sept 8, 2004 12:53:27 GMT -5
Well one thing leading to another,I added a few more features to the space invaders game from Tom's tutorial that i had modified.
I added sound,and bullets to the boss so that the Lives sign in the upper right corner finally has a use!!You get three more aliens at each level. Enjoy
I added sound,and bullets to the boss so that the Lives sign in the upper right corner finally has a use!!You get three more aliens at each level. Enjoy
dim alienCount
dim score, lives, turretx
dim alienx (1000), alieny (1000), alienOnScreen (1000),alienx2,alieny2,shot,blowup
dim bulletx, bullety, bulletOnScreen, i,tonextlevel,level,t,levelc,n,hits,aliencount2,bbc
dim bossbulletx(10),bossbullety
shot=loadsound("sounds/laser.wav")
blowup=loadsound("sounds/gunshot5.wav")
alienCount=1
level=1
n=1
lives = 3
start:
aliencount2=aliencount
turretx = 19
for i = 1 to alienCount
alienx(i) = rnd () % 37
alieny(i) = rnd () % 22 + 1
alienOnScreen(i) = true
next
bulletOnScreen = false
TextMode (TEXT_BUFFERED)
cls
locate 17,10
print"level "
print level
drawtext()
sleep(2000)
while aliencount2>0
if ScanKeyDown (VK_LEFT) and turretx > 0 then
turretx = turretx - 1
endif
if ScanKeyDown (VK_RIGHT) and turretx < 37 then
turretx = turretx + 1
endif
for i = 1 to alienCount
if alienOnScreen (i) then
alienx (i) = alienx (i) + 1
if alienx (i) > 37 then
alienx (i) = 0
alieny (i) = rnd () % 22 + 1
endif
endif
next
if bulletOnScreen then
bullety = bullety - 1
if bullety < 1 then
bulletOnScreen = false
endif
else
if ScanKeyDown (VK_SPACE) then
playsound(shot)
bulletOnScreen = true
bullety = 22
bulletx = turretx + 1
endif
endif
cls
color (255, 255, 255)
locate 0, 0: print "Score=" + score
locate 30, 0: print "Lives=" + lives
color (255, 50, 50)
for i = 1 to alienCount
if alienOnScreen (i) then
locate alienx (i), alieny (i): print ">O<"
endif
next
color (150, 150, 150)
locate turretx, 23: print "<!>"
if bulletOnScreen then
color (255, 255, 50)
locate bulletx, bullety: print "!"
endif
if bulletOnScreen then
for i = 1 to alienCount
if alienOnScreen (i) then
if bullety = alieny (i) and bulletx >= alienx (i) and bulletx <= alienx (i) + 2 then
playsound(blowup)
aliencount2=aliencount2-1
alienOnScreen (i) = false
bulletOnScreen = false
score = score + 100
endif
endif
next
endif
DrawText ()
Sleep (75)
wend
levelc=levelc+1
tonextlevel=0
level=level+1
if levelc=5 then
gosub bosssequence
levelc=0
tonextlevel=0
endif
aliencount=aliencount+3
goto start
bosssequence:
cls
locate 17,10
print"BOSS "
print n
drawtext()
sleep(2000)
cls
locate 17,10
print"Ready??"
drawtext()
sleep(1500)
for i = 1 to 10
bossbulletx(i) = rnd () % 37
next
alienx2=0
alieny2=3
while true
if ScanKeyDown (VK_LEFT) and turretx > 0 then
turretx = turretx - 1
endif
if ScanKeyDown (VK_RIGHT) and turretx < 37 then
turretx = turretx + 1
endif
if alienx2<25 and t=0 then
alienx2=alienx2+1
endif
if alienx2>0 and t=1 then
alienx2=alienx2-1
endif
if alienx2=25 then
t=1
endif
if alienx2=0 then
t=0
endif
if bulletOnScreen then
bullety = bullety - 1
if bullety < 1 then
bulletOnScreen = false
endif
else
if ScanKeyDown (VK_SPACE) then
playsound(shot)
bulletOnScreen = true
bullety = 22
bulletx = turretx + 1
endif
endif
cls
color (255, 255, 255)
locate 0, 0: print "Score=" + score
locate 30, 0: print "Lives=" + lives
color (255, 50, 50)
locate alienx2, alieny2: print "=/\w"
color (50, 255, 50)
locate alienx2+4,alieny2
print "ww/\ww"
color (255, 50, 50)
locate alienx2+9,alieny2
print "w/\="
color (150, 150, 150)
for bbc=1 to 10
locate bossbulletx(bbc),bossbullety
print"V"
next
if bossbullety<23 then
bossbullety=bossbullety+1
else
for i = 1 to 10
bossbulletx(i) = rnd () % 37
bossbullety=1
next
endif
if bossbullety=23 then
for i=1 to 10
if bossbulletx(i)>=turretx and bossbulletx(i)<=turretx+2 then
goto lifeloss
endif
next
endif
locate turretx, 23: print "<!>"
if bulletOnScreen then
color (255, 255, 50)
locate bulletx, bullety: print "!"
endif
if bulletOnScreen and bullety = alieny2 and bulletx >= alienx2+5 and bulletx <= alienx2 + 9 then
hits=hits+1
bullety=0
playsound(blowup)
if hits=10 then
color (255, 255, 100)
for i = 1 to 10
locate alienx2, alieny2: print "///\\\///\\\\"
DrawText ()
Sleep (50)
locate alienx2, alieny2: print "\\\///\\\////"
DrawText ()
Sleep (50)
next
bulletOnScreen = false
alienx2 = 0
score = score + 1000
Sleep (1000)
cls
locate 10,10
print"Boss "
print n
print" defeated!!!"
drawtext()
sleep(2000)
cls
n=n+1
locate 10,10
print"you get 1000 points"
drawtext()
sleep(2000)
return
endif
endif
DrawText ()
Sleep (75)
wend
lifeloss:
playsound(blowup)
color (255, 255, 100)
for i = 1 to 10
locate turretx, 23
print "///"
DrawText ()
Sleep (50)
locate turretx, 23
print "\\\"
DrawText ()
Sleep (50)
next
if lives>0 then
lives=lives-1
goto bosssequence
else
cls
locate 15,12
print"Game Over!"
drawtext()
sleep(2000)
endif
end