MXS Catch Object

Hi,
I have made a small script of catchme game where you have to catch an object by clicking on it. The script is ready but am unable to complete two things. they are:

  1. When the object is selected the gameWin() fn has to run.
  2. When the object touches the boundaries of persp viewport, the view port has to pan. I have tried doing this by getViewSize() but dint actually got succeeded as i dint know how to get the x and y of viewport size into two variable seperately. I actually have no idea if this is the right way.

Thanks in advance for the help.

Here’s the code:


Rollout movegame "Catch it if u can" 
(
	local minval = -100
	local maxval = 100
	
	timer ryTime "RayTime" interval:100
	label msg "Try catchin' the sphere"
	
	on movegame open do
	(
		local mysphere = sphere radius:30 segs:30 
		max tool maximize
		viewport.SetGridVisibility #all off
		viewport.zoom 2.0
		)
	fn MovIt = 
	(
		local ry = mapScreenToWorldRay mouse.pos
		local myray = ray ry.pos ry.dir
		local interRay= intersectRayScene myray
		if (interRay.count > 0 ) then
		(
			movObj = for o in objects collect o
			move movObj [random minval maxval,random minval maxval,random minval maxval]
			)
		)
	fn gameWin = 
	(
		delete $*
		messagebox "You Win. Congrats"
		destroyDialog movegame
		resetMaxFile #noprompt
		)
	on ryTime tick do (	MovIt()	)
	)
CreateDialog movegame