Wow! Great feedback guys... thank you very much...
I'm still having some issues applying all of this into 3D. Here's an upload of the code I'm working on:
sync on
sync rate 50
autocam off
randomize timer()
hide mouse
`Get the center of the screen
set display mode 800,600,32
cx# = screen width() / 2.0
cy# = screen height() / 2.0
`make the 'mouse'
make object box 1,2,2,2
color object 1,rgb(255,10,10)
`make base
Make object sphere 2,15
basex#=0
basey#=0
basez#=0
position object 2,basex#,basey#,basez#
`make crosshair
make object plain 3,10,10
xrotate object 3,90
hide object 3
fade object 3,2000
ghost object on 3
`make bullet
make object cube 4,5
`make target
make object cube 5,2
hide object 5
position camera 0,500,-10
point camera 0,0,0
position mouse cx#,cy#
`declare a few variables
speed# = 10
fire = 0
load = 0
do
`control the 3d mouse
position object 1,mousex()-400,0,-mousey()+300
` detect if mouseclick on base
pick = pick object (mousex(),mousey(),2,2)
`if you click the base get ready to fire
if pick = 2 and mouseclick() = 1 and fire = 0
load = 1
endif
`draw the line while holding the mouse button after clicking the base
if load = 1 and mouseclick() = 1
line cx#,cy#,mousex(),mousey()
targetx#=(mousex()-cx#)*-1
targety#=(mousey()-cy#)
position object 3,targetx#,0,targety#
show object 3
endif
`fire if user releases mouse
` position the target at the spot where the bullet will land
if load = 1 and mouseclick() = 0
fire = 1
load = 0
firex#=object position x(1)
firez#=object position z(1)
hitx#=object position x(3)
hitz#=object position z(3)
position object 5,hitx#,0,hitz#
targetx#=cx#
targety#=cy#
endif
`position bullet at 3d mouse and show it
if fire = 1
position object 4,firex#,0,firez#
show object 4
fire = 2
endif
` point the bullet at the target and move it forward
` check for dist between bullet and target and kill bullet when close enough
if fire = 2
point object 4,hitx#,0,hitz#
move object 4,speed#
firex#=object position x(4)
firez#=object position z(4)
dist#= sqrt(((firex#-hitx#)*(firex#-hitx#)) + ((firez#-hitz#)*(firez#-hitz#)))
if dist# <= speed# then dist#=0:fire = 3
endif
`kill bullet and cleanup for next shot
if fire = 3
hide object 4
hide object 3
position object 4, basex#,basey#,basez#
position object 3, basex#,basey#,basez#
position object 5, basex#,basey#,basez#
hide object 5
fire = 0
endif
sync
loop
The angles involved are of the line formed between the 3D mouse and base...(top down view so there really isn't a y axis defined by the user).
[img]null[/img]
In the end, what I'm hoping to accomplish is: the bullet shoots from the 3D mouse and lands right on the target, but by following a curve up in the air rather than bee-lining right at it. Does that make sense?
Every absurdity has a champion to defend it.