Alright, this is only my third dbp game ever, and there all basic. However, i can release this one cause its pure code! tooke me about 10 hours, and being reletavly new to the language, I am very proud of it.
So, down to bussness. The game is called Block defence. Basicly, you are the pink block and you have to shoot the blue blocks before they get to you.
The code is VERY messy, and there is somthing in there that is pointless. I have an extra particle explosion in there somwere, but being the lazy guy I am, didnt take it out.
Heres the code! enjoy, CC is welcome
REM Project: no media
REM Created: 11/25/2006 10:26:22 PM
REM
REM ***** Main Source File *****
REM
gamemenu:
text screen width()/2,10,"BLOCK DEFENCE"
print ""
print "OBJECTIVE:"
print "In this game, your objective is to shoot every blue block"
print "before it can get behind you. "
print "CONTROLS:"
print "right key - move block right"
print "left key -- move block left"
print "up key ---- shoot"
print "mouse ----- look around"
suspend for key
cls
autocam off
game:
if matrix exist(1)
delete matrix 1
endif
if light exist(1)
delete light 1
endif
if light exist(2)
delete light 2
endif
if particles exist(1)
delete particles 1
endif
if particles exist(2)
delete particles 2
endif
if particles exist(3)
delete particles 3
endif
if object exist(1)
delete object 1
endif
if object exist(2)
delete object 2
endif
if object exist(3)
delete object 3
endif
if object exist(4)
delete object 4
endif
if object exist(5)
delete object 5
endif
if object exist(6)
delete object 6
endif
if object exist(7)
delete object 7
endif
if object exist(8)
delete object 8
endif
if object exist(9)
delete object 9
endif
color backdrop rgb(50,0,50)
make matrix 1,8,12,15,15
make object cube 1,1
scale object 1,48,48,48
color object 1,rgb(255,0,100)
position object 1,4,0,0
position camera 4,2,-4
pitch camera down 20
z=12
make object cube 3,1
position object 3,rnd(7),0,z
color object 3,rgb(0,255,255)
playerspeed#=.01
speed#=.005
t#=0
make light 1
color light 1,100,255,0
set light range 1,70000
position light 1,4,3,6
make object cube 4,1
scale object 4,60,600,1200
position object 4,-.3,3,6
make object cube 5,1
scale object 5,900,600,200
position object 5,4,3,13
make object cube 7,1
scale object 7,60,600,1200
position object 7,8.3,3,6
vary#=.01
ai#=0
sx#=25
sy#=25
fa#=0
put#=0
bp#=0
r#=100
g#=255
b#=0
one#=1
ltime#=0
do
if object exist(3)
if object position z(3)=<3
text screen width()/2,100,"WARNING!"
ltime#=ltime#+1
if ltime#=0
r#=255
g#=0
color light 1,r#,g#,b#
endif
if ltime#=10
ltime#=-10
r#=0
g#=255
color light 1,r#,g#,b#
endif
else
color light 1,100,255,0
endif
endif
if particles exist(2)
delete particles 2
endif
if object exist(2)
pz#=pz+.001
if particles exist(3)
delete particles 3
endif
make snow particles 3,0,40,object position x(2),object position y(2),object position z(2),.02,.02,pz#
color particles 3,0,0,0
endif
if blockskilled#=10
ai#=1
endif
if ai#=1
ais#=rnd(10)
if ais#=<5
ais#=-.01
endif
if ais#=>5
ais#=.01
endif
ais#=vary#
move object left 3,ais#
endif
if object hit(3,4)
vary#=-.01
endif
if object position x(3)>8
vary#=.01
endif
if blockskilled#=30
fa#=1
endif
if fa#=1
ft#=ft#+1
endif
if ft#=500
make object cube 8,1
scale object 8,200,200,200
fallx#=rnd(8)
fally#=rnd(10)
fallz#=rnd(10)
position object 8,fallx#,fally#,fallz#
fas#=.01
endif
if object exist(8)
if fa#=1
move object down 8,fas#
endif
endif
if object exist(8)
if object position y(8)=<0
fa#=2
ft#=0
endif
endif
if fa#=2
ft2#=ft2#+1
endif
if ft2#=400
if object exist(8)
delete object 8
endif
fa#=1
ft#=0
ft2#=0
endif
if object exist(2)
if object exist(8)
if object hit(2,8)
if particles exist(1)
delete particles 1
endif
make particles 1,0,5,3
position particles 1,object position x(2),0,object position z(2)
color particles 1,255,0,0
p1=1
if light exist(2)
delete light 2
endif
delete object 2
endif
endif
endif
t#=t#+1
if t#=400
randomize timer()
tt#=tt#+1
t#=0
endif
if object exist(3)
move object 3,-speed#
endif
if light exist(2)
if object exist(2)
position light 2,object position x(2),0,object position z(2)
endif
endif
if object exist(2)
if object exist(3)
if object hit(2,3)
if particles exist(3)
delete particles 3
endif
sx#=sx#-.3
sy#=sy#-.3
if particles exist(1)
DELETE PARTICLES 1
endif
make particles 1,0,5,3
position particles 1,object position x(2),0,object position z(2)
color particles 1,255,0,0
p1=1
if light exist(2)
delete light 2
endif
delete object 2
delete object 3
if blockskilled#=>10
vary#=.01
endif
blockskilled#=blockskilled#+1
speed#=speed#+.001
playerspeed#=playerspeed#+.0005
zredo:
z=rnd(12)
if z=<6
goto zredo
endif
make object cube 3,1
position object 3,rnd(7),0,z
color object 3,rgb(0,255,255)
endif
endif
endif
if object exist(2)
if object hit(2,5)
if particles exist(3)
delete particles 3
endif
if particles exist(1)
delete particles 1
endif
make particles 1,0,5,3
position particles 1,object position x(2),0,object position z(2)
color particles 1,255,0,0
p1=1
delete object 2
endif
endif
if p1=1
pt=pt+1
endif
if pt=200
if particles exist(1)
delete particles 1
endif
p1=0
pt=0
endif
if p2=1
pt2=pt2+1
endif
if pt2=200
if particles exist(2)
delete particles 2
endif
p2=0
pt2=0
endif
if object position z(3)=<0
goto gameover
endif
if object exist(2)
color object 2,rgb(255,0,0)
move object 2,.05
endif
if rightkey()=1
move object right 1,playerspeed#
endif
if leftkey()=1
move object left 1,playerspeed#
endif
if upkey()=1
if light exist(2)
delete light 2
endif
make light 2
color light 2,255,0,0
set light range 2,9
if object exist(2)
if particles exist(2)
delete particles 2
endif
make particles 2,0,5,3
position particles 2,object position x(2),0,object position z(2)
color particles 2,255,0,0
p2=1
delete object 2
endif
make object cube 2,1
scale object 2,sx#,sy#,15
position object 2,object position x(1),0,.05
position light 2,object position x(2),0,object position z(2)
if particles exist(3)
delete particles 3
endif
pz#=1
make snow particles 3,0,40,object position x(2),-.5,object position z(2)+.5,.02,.02,pz#
set particle life 3,.5
endif
rotate camera camera angle x(0)+(mousemovey()/2.0),camera angle y(0)+(mousemovex()/2.0),0
if object position x(1)=>7.87
position object 1,7.87,0,0
endif
if object position x(1)=<.2
position object 1,.21,0,0
endif
wait 1
loop
gameover:
ink rgb (200,0,0),1
color light 1,255,0,0
do
text screen width()/2,screen height()/2,"YOU LOSE!"
print ""
print ""
print "You killed ",blockskilled#
print "Your time was ",tt#
print "press return to play again"
if returnkey()=1
tt#=0
blockskilled#=0
goto game
endif
loop
there is one known bug. If you reset the game in-game, then the falling blocks ont come the second time around.
also, my high score is 62. if you bother to player, please post yours.