Moving Object by Skywriter18th May 2011 6:17
|
---|
Summary Object movement with mouse Description Moves object on x axis at the mouse pointer position. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com backdrop on make object cube 1,100 make object cube 2,100 color object 2,rgb(255,0,0) set camera range 0,1,100000 do control camera using arrowkeys 0,1,0.1 x=mousex() y=mousey() pick screen x,y,1000 scrx2#=camera position x(0)+get pick vector x() scry2#=camera position y(0)+get pick vector y() scrz2#=camera position z(0)+get pick vector z() x1#=0.0 y1#=0.0 z1#=0.0-10.0 x2#=scrx2#-camera position x(0) y2#=0.0 z2#=scrz2#-camera position z(0) cos_angle#=((x1#*x2#)+(y1#*y2#)+(z1#*z2#))/((sqrt((x1#*x1#)+(y1#*y1#)+(z1#*z1#)))*(sqrt((x2#*x2#)+(y2#*y2#)+(z2#*z2#)))) angle#=acos(cos_angle#) if x2#<x1# angle#=angle#*(-1) ENDIF xp#=camera position x(0)+(tan(angle#)*camera position z(0)) `not fully.... position object 2,xp#,0,0 LOOP |