I would adjust your movement. Now it's impossible to fly forward.
A suggestion:
if leftkey() = 1
zrotate object 1,345
posx# = posx# - 3.5
endif
if rightkey() = 1
zrotate object 1,15
posx# = posx# + 3.5
endif
For collision:
Collision boxes are easy to use and come in handy for sliding collision. But not very useful in your program.
hide mouse
make matrix 1,1200,3200,50,50
`FIX TEXTURE
load bitmap "ground1.bmp",1
get image 1,0,0,256,256
delete bitmap 1
prepare matrix texture 1,1,256,256
`FIX TEXTURE
randomize matrix 1,50.0
load object "HELICO13.x",1
make object collision box 1,-0.5,-0.5,-0.5,0.5,0.5,0.5,0
scale object 1,210,190,250
YROTATE OBJECT 1,180:FIX OBJECT PIVOT 1
position matrix 1,posx#-600,posy#-300,posz#-160
XROTATE CAMERA 90
Make object box 5,1200,200,120
make object collision box 5,-600,-100,-60,600,100,60,0
color object 5,rgb(20,20,40)
color object 1,rgb(10,20,10)
Make object box 6,1200,400,50
make object collision box 6,-600,-100,-60,600,100,60,0
position object 6,posx#,0,posz#+400
bullet=100
sync on
do
posz#=posz#+3
if spacekey()>0 then makebullet=1 else makebullet=0
if bulletmade=1 then firebullet=1 else firebullet=0
if bullethit=1 then restartbullet=1 else restartbullet=0
if inkey$()="w" or inkey$()="W" then accelerate=1 else accelerate=0
if inkey$()="s" or inkey$()="S" then deaccelerate=1 else deaccelerate=0
zrotate object 1,0
if rightkey()=1
zrotate object 1,345
posx# = posx# + 3.5
endif
if leftkey()=1
zrotate object 1,15
posx# = posx# - 3.5
endif
`vFIX BULLETv
if makebullet=1
if object exist(bullet)
delete object bullet
else
make object box bullet,2,1,5
color object bullet,rgb(130,140,150)
position object bullet,posx#,posy#,posz#
bulletx#=object position x(bullet):bullety#=object position y(bullet):bulletz#=object position z(bullet)
bulletmade=1
endif
endif
if firebullet=1
if object exist(bullet)
bullety#=bullety#-40
bulletz#=bulletz#+80
if object hit(bullet,6)
bullethit=1
endif
if bullety#=0 or bullety#<0
`ADD SPRITE COLLSION HERE
bullethit=1
endif
endif
bullethit=0
endif
if restartbullet=1
if object exist(bullet)
delete object bullet
goto end
endif
endif
`^FIX BULLET^
if accelerate=1
posz#=posz#+8
endif
if deaccelerate=1
posz#=posz#-.1
endif
angle#=object angle z(1)
camdist#=0 : camhigh#=posy#+400.0 : camfade#=1
set camera to follow posx#,posy#,posz#,angle#,camdist#,camhigh#,camfade#,1
position object 1,posx#,posy#,posz#
if object exist(bullet) then position object bullet,bulletx#,bullety#,bulletz#
`collision handling
if object collision(1,0) > 0
center text 50,50,"You hit an object"
endif
sync
loop
end:
suspend for key
cls
Print "SUCCESS!"
(I added the movement thing too)
OR
Even better in your case.
use set object collision to polygons for your heli and set object collision to boxes for the boxes:
hide mouse
make matrix 1,1200,3200,50,50
`FIX TEXTURE
load bitmap "ground1.bmp",1
get image 1,0,0,256,256
delete bitmap 1
prepare matrix texture 1,1,256,256
`FIX TEXTURE
randomize matrix 1,50.0
load object "HELICO13.x",1
set object collision on 1
set object collision to polygons 1
scale object 1,210,190,250
YROTATE OBJECT 1,180:FIX OBJECT PIVOT 1
position matrix 1,posx#-600,posy#-300,posz#-160
XROTATE CAMERA 90
Make object box 5,1200,200,120
set object collision on 5
set object collision to boxes 5
color object 5,rgb(20,20,40)
color object 1,rgb(10,20,10)
Make object box 6,1200,400,50
set object collision on 6
set object collision to boxes 6
position object 6,posx#,0,posz#+400
bullet=100
sync on
do
posz#=posz#+3
if spacekey()>0 then makebullet=1 else makebullet=0
if bulletmade=1 then firebullet=1 else firebullet=0
if bullethit=1 then restartbullet=1 else restartbullet=0
if inkey$()="w" or inkey$()="W" then accelerate=1 else accelerate=0
if inkey$()="s" or inkey$()="S" then deaccelerate=1 else deaccelerate=0
zrotate object 1,0
if rightkey()=1
zrotate object 1,345
posx# = posx# + 3.5
endif
if leftkey()=1
zrotate object 1,15
posx# = posx# - 3.5
endif
`vFIX BULLETv
if makebullet=1
if object exist(bullet)
delete object bullet
else
make object box bullet,2,1,5
color object bullet,rgb(130,140,150)
position object bullet,posx#,posy#,posz#
bulletx#=object position x(bullet):bullety#=object position y(bullet):bulletz#=object position z(bullet)
bulletmade=1
endif
endif
if firebullet=1
if object exist(bullet)
bullety#=bullety#-40
bulletz#=bulletz#+80
if object hit(bullet,6)
bullethit=1
endif
if bullety#=0 or bullety#<0
`ADD SPRITE COLLSION HERE
bullethit=1
endif
endif
bullethit=0
endif
if restartbullet=1
if object exist(bullet)
delete object bullet
goto end
endif
endif
`^FIX BULLET^
if accelerate=1
posz#=posz#+8
endif
if deaccelerate=1
posz#=posz#-.1
endif
angle#=object angle z(1)
camdist#=0 : camhigh#=posy#+400.0 : camfade#=1
set camera to follow posx#,posy#,posz#,angle#,camdist#,camhigh#,camfade#,1
position object 1,posx#,posy#,posz#
if object exist(bullet) then position object bullet,bulletx#,bullety#,bulletz#
`collision handling
if object collision(1,0) > 0
center text 50,50,"You hit an object"
endif
sync
loop
end:
suspend for key
cls
Print "SUCCESS!"
Immunity and Annihalation makes Immunihalation...