\\ is not C++ syntax for REM, this is --> //
In any case, this language is BASIC, and the keyword REM should be used because that's the standard for BASIC.
@ MrValentine
Setting Vsync is not going to solve this problem in any way at all, because mouse input isn't dependent on the screen refresh rate.
@ Dimension
I've simplified your code to use absolute movement rather than relative movement. The theory behind it is to store the current camera and mouse positions as soon as the button is clicked (I used storex# and storez#), and then you subtract the new coordinates from the stored ones. Here's the code:
set display mode 1280, 720, 32
sync on
sync rate 0
autocam on
make object cube 1, 1
hide object 1
make matrix 1, 12, 12, 12, 12
autocam off
position camera 0, 25, 0
point camera camera position x(), 0, camera position z()
make object cube 25, 1
position object 25, 0, 0, 5
do
text 0, 100, "x :\" + str$(fun2Dto3D_x(0, 0, camera position y()))
text 0, 110, "y :\" + str$(camera position y())
text 0, 120, "z :\" + str$(fun2Dto3D_z(0, 0, camera position y()))
ink rgb(255, 0, 0), rgb(0, 0, 0)
circle fun3Dto2D_x(0, 0, 0), fun3Dto2D_y(0, 0, 0), 2
dot fun3Dto2D_x(0, 0, 0), fun3Dto2D_y(0, 0, 0), rgb(255, 0, 0)
rem pan
if mouseclick() = 4
x = mousex()
y = mousey()
yy# = camera position y()
position object 25, camera position x(), 0, camera position z()
rem mouse was just clicked, store original positions
if drag_click_flag = 0
storex# = camera position x() + fun2Dto3D_x(x, y, yy#)
storez# = camera position z() + fun2Dto3D_z(x, y, yy#)
drag_click_flag = 1
endif
rem subtract mouse coordinates from from original positions to get new positions
cam_x# = storex# - fun2Dto3D_x(x, y, yy#)
cam_z# = storez# - fun2Dto3D_z(x, y, yy#)
rem update camera
position camera cam_x#, camera position y(), cam_z#
point camera cam_x#, 0, cam_z#
text 0, 00, "xp :\" + str$(xp)
text 0, 20, "yp :\" + str$(yp)
text 0, 40, "x :\" + str$(x)
text 0, 60, "y :\" + str$(y)
else
rem reset flag
drag_click_flag = 0
endif
sync
loop
function fun2Dto3D_x(x, y, dis#)
pick screen x, y, dis#
value# = get pick vector x()
endfunction value#
function fun2Dto3D_y(x, y, dis#)
pick screen x, y, dis#
value# = get pick vector y()
endfunction value#
function fun2Dto3D_z(x, y, dis#)
pick screen x, y, dis#
value# = get pick vector z()
endfunction value#
function fun3Dto2D_x(x#, y#, z#)
position object 1, x#, y#, z#
value# = object screen x(1)
endfunction value#
function fun3Dto2D_y(x#, y#, z#)
position object 1, x#, y#, z#
value# = object screen y(1)
endfunction value#
function distance3D(x1#, y1#, z1#, x2#, y2#, z2#)
x# = dif(x1#, x2#)
y# = dif(y1#, y2#)
z# = dif(z1#, z2#)
dis# = sqrt((x#^2) + (y#^2) + (z#^2))
endfunction dis#
function dif(v1#, v2#)
value# = 0
if v1# > v2#
value# = v1# - v2#
endif
if v2# > v1#
value# = v2# - v1#
endif
endfunction value#
TheComet