@the angry programmer
hey...don`t crash your laptop!!.
...I have understood that you want to add a gun to your game like a first person shooter.You can lock the object to the screen with command
LOCK OBJECT ON...or you can position the gun in the same x,y,z of the camera and just move the gun a little bit ahead, and rotate the gun camera angle y.
Here is an example...cheers.
autocam off:hide mouse
create bitmap 1,50,50:for i= 1 to 1550:ink rgb(30,255,55),0:line rnd(60),i,i,rnd(130)
next i:blur bitmap 1,6:get image 1,10,10,50,50:delete bitmap 1
sync on
arma= 20 //gun
bala=21 //bullet
dumy=3 //dumy
`foor
make object box 1,3000,1,3000
texture object 1,1
scale object texture 1,3,3
`gun
make object cylinder arma,1
scale object arma,100,1200,100
xrotate object arma,90
fix object pivot arma
`bullet
make object box bala,1,1,20:color object bala,rgb(200,0,0):hide object bala
`dumy
make object sphere 3,30
position object 3,600,20,600
do `************ MAIN BUCLE *************************************************
gosub _controla_camara
gosub bala
if object collision(bala,dumy)=1 then position object dumy,300+rnd(1000),10,300+rnd(1000)
sync
loop
_controla_camara:
rem UPKEY DOWNKEY ARROWS
if upkey()=1 then x#=newxvalue(x#,a#,1) : z#=newzvalue(z#,a#,1)
if downkey()=1 then x#=newxvalue(x#,a#,-1) : z#=newzvalue(z#,a#,-1)
`slide left
if leftkey()=1 THEN x#=NEWXVALUE(x#,a#-90,1):z#=NEWZVALUE(z#,a#-90,1)
`slide right
if rightkey()=1 THEN x#=NEWXVALUE(x#,a#-90,-1): z#=NEWZVALUE(z#,a#-90,-1)
`camera rotations
if cam#<=290 and cam#>180 then cam#=290
if cam#>=70 and cam#<180 then cam#=70
a#=wrapvalue(a#+mousemovex()/2)
cam#=wrapvalue(cam#+mousemovey()/2)
rotate camera cam#,a#,0 //camera rotations
rotate object arma,cam#,a#,0 //gun rotations
//positioning camera gun and bullet
position camera x#,145,z#
position object arma,x#,145,z#
move object arma,-5
position object bala,x#,145,z#
move object arma,15
move object right arma,3
move object down arma,3
move object bala,15
move object right bala,3
move object down bala,3
return
bala:
set cursor 310,235:ink rgb(255,0,0),0
print " +"
`-------------------------------------------------------------
`bullet start in gun positions
if dispara=0
set object to object orientation bala,arma
endif
if mouseclick() and dispara=0
dispara=1
show object bala
endif
if dispara=1
la=la+10
run=run+1
move object bala,la
endif
if run>200
run=0
la=0
dispara=0
hide object bala
endif
return
`-------------------------------------------------------------
I'm not a grumpy grandpa