Hey, I am working on a game I started from a tutorial (forgot which one) and I got stuck. I use DBC for now, plan on getting pro on Christmas. The game was working fine untill I added the ability to shoot. The bullet object (11) stays in the center of the player object (10) at all times. However, this triggers a collision that stops the player from moving. I have tried a couple things but nothing has worked. Here is the collision code (objects 1-5 are block objects, the ones the player is supposed to collide with):
if Object collision(10,0)>0 and Object collision(10,0)
position object 10,X#,0,Z#
endif
Here is the rest of the program if you can't find it in the above snippet:
rem Setup sync rate
sync on
sync rate 30
Load image "cottag02.bmp",1
Load image "barry.bmp",2
rem Make some cubes
For x=1 to 5
Make object cube x, 100
Position object x, Rnd(2000), 0, Rnd(2000)
Rotate object x, 0, rnd(360), 0
Set object collision to boxes x
Texture object x, 1
Next x
rem Make the player
Make object sphere 10, 50
Set object collision to spheres 10
set global collision on
Texture object 10, 2
X#=0
Z#=0
rem Make bullet object and variables
Make object sphere 11, 5
color object 11, RGB(255, 255, 255)
set object collision to spheres 11
bulletx=0
bullety=0
canShoot=1
bulletLife=0
hide object 11
rem Main Loop
do
rem Store the camera's y angle in caY#
caY#=camera angle y()
rem Store the player's y angle in aY#
aY#=object angle y(10)
rem Give player object movement inputs
If upkey()=1 then move object 10,10
If downkey()=1 then move object 10,-10
If leftkey()=1 then Yrotate object 10, wrapvalue(aY#-5)
If rightkey()=1 then Yrotate object 10, wrapvalue(aY#+5)
Rem Detect collision
if Object collision(10,0)>0 and Object collision(10,0)
position object 10,X#,0,Z#
endif
rem Get player object position and store in X# and Z#
X# = Object position x(10)
Z# = Object position z(10)
rem Get new camera position and store in cZ# and cX#
cZ# = Newzvalue(Z#,aY#-180,100)
cX# = Newxvalue(X#,aY#-180,100)
rem Position camera
position camera cX#, 100, cZ#
rem Point camera at player
point camera X#, 50, Z#
rem Shoot *Incomplete*
If spacekey()=1 and canShoot=1
show object 11; move object 11, 50; canShoot=0
bulletLife=15
Endif
rem Bullet Control BEGIN
if bulletLife>0 then dec bulletLife, 1; move object 11, 50
if bulletLife=1
hide object 11; canShoot=1; bulletLife=0
endif
if canShoot=1
position object 11, X#, 0, Z#
set object to object orientation 11, 10
endif
for i=1 to 5
if Object collision(11, i)=1 then bulletLife=1
Next i
rem Bullet Control END
rem Sync
sync
loop
Normally I wouldn't post code for error finding but I've been trying to find this thing for two or three days now...
Thanks,
Tim
Timothy Sassone