Hello fellow DarkBasicPro coders.
I have started my first game in Dbpro.It's a simple asteroid like top view shooter.But i have a problem.
I used a shootin snippet modified a bit for my code.But it doesn't shoot.Can some one check my cod and see whats wrong ?
set display mode 800,600,32
sync on
sync rate 60
set ambient light 50
`Global VARIABLES
global MissileDelay# as float : global TotalMissiles as integer : TotalMissiles = 5
global PosukioGreitis# as integer : PosukioGreitis# = 3.5
global MaxGreitis# as integer : MaxGreitis# = 5
global Frikcija# as integer : Frikcija# = 0.95
global Greitukas# as integer : Greitukas# = 5
global Missilespeed# as float : Missilespeed# = 5.0
global Missilethrust# as float : Missilethrust# = 5.0
`Arrays
dim Missile(TotalMissiles,5)
for i= 1 to TotalMissiles
missile(i,1) = 99 + i : ` object number
missile(i,2) = rgb(rnd(128) + 127,rnd(128) + 127,rnd(128) + 127) : ` color
missile(i,3) = 0 : ` status 0 = inactive 1 = moving
missile(i,4) = 8.0 : ` speed
missile(i,5) = 0 : ` move counter
next i
MakeModels()
`VAR
score# = 0
Ship = 11
load object "media/moduls/ship.x",Ship
Position Object Ship,5000/50,590,5000/50
load image "media/moduls/SHIPBUMP.tga",2
set bump mapping on Ship,2
rotate object Ship,90,270,0
texture object Ship,1,2
Load Image "media/fx/gloss.dds", 1
Load Effect "media/fx/Gloss.fx", 1, 0
Set Object Effect Ship, 1
remstart
Make Matrix 1,5000,5000,20,20
load image "media/tex/sand.bmp",3
prepare matrix texture 1,3,1,1
POSITION MATRIX 1, -2000, 0, -2000
update matrix 1
remend
`terrain
load object "media/lvl/terrain.x",2
position object 2,0,0,0
scale object 2,70,40,70
do
`Print out FPS
TEXT 10,10,"FPS"+str$(screen fps())
`print out score
Text 10,20,"SCORE: "+str$(score#)
Greitukas# = Greitis#/1.5
inputas()
`add friction and check max speed limit
If Greitis#>MaxGreitis# then Greitis# = MaxGreitis#
If Greitis#<-MaxGreitis# then Greitis# = -MaxGreitis#
Greitis# = Greitis#*Frikcija#
`move the car
Move Object Ship,Greitis#
Position Camera Object Position X(11),Object Position Y(11)+2000,Object Position Z(11)
Point Camera Object Position X(11),Object Position Y(11),Object Position Z(11)
sync
LOOP
function inputas()
If Upkey()=1 then move object right 11,10
If Downkey()=1 then move object left 11,10
If Leftkey()=1 then roll Object left 11,PosukioGreitis#
If Rightkey()=1 then roll Object Right 11,PosukioGreitis#
if spacekey() = 1 : ` fire missile
if timer() > MissileDelay#
` see if a missile is available
avbl = 0
for i = 1 to 5
if missile(i,3) = 0 then avbl = i : exit
next i
if avbl > 0
obj = missile(avbl,1)
camx# = camera position x()
camy# = camera position y()
camz# = camera position z()
position object obj,camx#,camy#,camz#
set object to camera orientation obj
pitch object down obj,1
missile(avbl,3) = 1
show object Missile(avbl,1)
MissileDelay# = timer() + 150.0
endif
endif
endif
Missilespeed# = curvevalue(Missilethrust#,Missilespeed#,25)
ENDFUNCTION
function MakeModels()
` make missiles
for m = 100 to (TotalMissiles + 99)
make object sphere m,5
color object m,(missile((m - 99),2))
hide object m
next m
endfunction
function MoveMissiles()
for i = 1 to TotalMissiles
` check status
if Missile(i,3) = 1
move object Missile(i,1),Missile(i,4)
Missile(i,5) = Missile(i,5) + 1
if Missile(i,5) > 100
` missile has gone too far
hide object Missile(i,1)
Missile(i,3) = 0
Missile(i,5) = 0
else
` check collision w/baddies
` check collision with planets, etc.
` check collision with matrix
endif
endif
next i
endfunction