This code is an old cludge I did in Dir4 a couple of years ago. Please exuse the mess but it may be useful to some of you.

on startmovie
global Hvel, Vvel,
set hvel = 0
set vvel =0
end

on exitFrame
doresistance
doedges
moveBall
go to the frame
end

on doedges
global Hvel, Vvel
if the loch of sprite 10 < 0 then set hvel = hvel*-1
--if the locv of sprite 10 < 0 then set vvel = vvel*-1
if the loch of sprite 10 > 640 then set hvel =hvel*-1
if the locv of sprite 10 > 450 then set vvel = vvel*-1
end

on doresistance
global Hvel, Vvel
set hvel = hvel*.98
set vvel = vvel*.97
end

on moveball
global Hvel, Vvel
if the locv of sprite 10 <= 449 then set vvel = vvel +1
set the loch of sprite 10 = the loch of sprite 10 + Hvel
set the locv of sprite 10 = the locv of sprite 10 + Vvel
end

on mousedown
global h1, V1
startTimer
if the clickon =10 then
repeat while the stilldown
set the loch of sprite 10 = the mouseh
set the locv of sprite 10 = the mousev
if the timer < 10 then
set the loch of sprite 10 = the mouseh
set the locv of sprite 10 = the mousev
else
set h1 = the mouseh
set v1 = the mousev
startTimer
end if
updatestage
end repeat
end if
end

on mouseup
global h1, V1, Hvel, Vvel
if the clickon = 10 then
set hvel = integer((the mouseh - h1 )/2)
set vvel = integer((the mousev - v1)/2)
end if

end