This example shows how arrays can be used to stock pile the position of an object (in this case the mouse pointer) so that it's movement can be replayed later.
[pbcode]
Do
; Set the App to run at 60Frames per second or slower
SetFps 60
; CReate some arrays to hold (10000 movements of the mouse)
Movements=10000
Dim ReplayMouseX(Movements)
Dim ReplayMouseY(Movements)
Dim ReplayMouseRadius(Movements)
Dim ReplayMouseColour(Movements)
CapturedFrames=0
MyColour=Rndrgb()
; This loop is drawing a circle at the mouses positions
repeat
Cls 0
Print "Capturing the Mouses position and draw colours)"
print "press the left mouse button to replay)"
angle#=angle#+1
if angle#>359
Angle#=0:
MyColour=Rndrgb()
endif
; Get the mouses position
x=mousex()
y=mousey()
; zoom the radius in/out
Radius=100+cos(angle#)*50
Colour= rgbfade(MyColour,70+cosradius(angle#,40))
; Store the replay Infomation for this object this frame
ReplayMouseX(CapturedFrames)=x
ReplayMouseY(CapturedFrames)=y
ReplayMouseRadius(CapturedFrames)=Radius
ReplayMouseColour(CapturedFrames)=COlour
; Bump The captured frames counter
CapturedFrames=CapturedFrames+1
; DRaw the mouses circle
Circlec X,y,Radius,1,Colour
Sync
until mousebutton()=1
SlowMotion=False
; This loop is drawing a circle at the mouses positions
ThisFrame=0
repeat
Cls 0
Print "Replaying Mouse Movements"
print "Press Mouse BUttons for Slow or Full Motion"
if Mousebutton()=1
SetFps 60
SlowMotion=False
endif
if Mousebutton()=2
; Set the App to run at 20 frames for a SLOW motion replay
SetFps 20
SlowMotion=True
endif
if SlowMotion=True
print "Slow Motion {ON}"
else
print "Slow Motion (OFF}"
endif
print "Replaying Frame:"+str$(ThisFrame)
print "Captured Frames:"+str$(CapturedFrames)
print "Seconds Captured:"+str$(CapturedFrames/60.0)
; Read the Position/Colour and Sze of this object
x=ReplayMouseX(ThisFrame)
y=ReplayMouseY(ThisFrame)
Radius=ReplayMouseRadius(ThisFrame)
Colour=ReplayMouseColour(ThisFrame)
; DRaw the mouses circle
Circlec X,y,Radius,1,Colour
; Bump the Frame counter
ThisFrame=ThisFrame+1
Sync
until ThisFrame=CapturedFrames
print "DONE...Press any key to start again"
sync
waitkey
loop
[/pbcode]
Related Examples:
* Storing User Input In Global Types (http://www.underwaredesign.com/forums/index.php?topic=3644.0)