I can't get my shooting code to work... It goes funky, as in, I put a crosshair sprite at 320, 240 on the screen, and that should be the middle of the screen right? Well, I thought set object to camera orientation set it to the middle of the screen as well?
It doesn't seem to, as when I turn to the left, it shoots to the left of the crosshair, and when I turn to the right, it shoots to the right of the crosshair...
if Mouseclick()=1 and BulletLife=0
Position object 3,X#,Y#+18,Z#
Set object to camera orientation 3
BulletLife = 150
shooting = 1
Show object 3
Endif
if shooting = 1 then gosub BulletMove
sync
loop
BulletMove:
Dec BulletLife
If BulletLife = 0 then hide object 3 : shooting = 0
move object 3, 15
x = object position x(3)
z = object position z(3)
y = object position y(3)
if y < get ground height(1, x, z) + 0.5 and hit = 0 or x < 0 and hit = 0 or x > 1000 and hit = 0 or z < 0 and hit = 0 or z > 1000 and hit = 0
hit = 1
if x > 0 and x < 1000 and z > 0 and z < 1000
tilex = Int(x/tilewidth)
tilez = Int(z/tiledepth)
set matrix height 1, tilex, tilez, get matrix height(1, tilex, tilez) - 10
update matrix 1
endif
position object 4, x, y, z
position light 1, x, y, z
set light range 1, 5000
color light 1, 255, 0, 0
set point light 1, X#, Y#, Z#
show light 1
position object 3, 30000, 30000, 30000
endif
if hit = 1
if exploding < 10 and exploded = 0
scale object 4, exploding * 250, exploding * 250, exploding * 250
exploding = exploding + 1
scroll object texture 4, 10, 10
if exploding = 10 then exploded = 1
endif
if exploded = 1
scale object 4, exploding * 250, exploding * 250, exploding * 250
exploding = exploding - 1
scroll object texture 4, 10, 10
if exploding = 1
exploded = 0
position object 4, 30000, 30000, 30000
shooting = 0
bulletlife = 0
position object 3, 30000, 30000, 30000
hit = 0
hide light 1
endif
endif
return
endif
position object 3, x, y, z
return