```
Sub Process_Globals
Type TargetType(P As B4XView, X As Float, Y As Float, VX As Float, VY As Float)
Private fx As JFX
Private MainForm As Form
Dim NumTargets As Int = 50
Dim Target() As TargetType
Dim tmr As Timer
Dim ThisFrameTime As Long
Dim LastFrameTime As Long
Dim xu As XUI
Dim TestPanel As B4XView
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.Show
TestPanel = xu.CreatePanel("pnlGauge")
Form1.RootPane.AddNode(TestPanel, 10, 10, 100, 100)
Dim Target(NumTargets) As TargetType
For I = 0 To NumTargets -1
Target(I).P = xu.CreatePanel("")
Target(I).X = 300
Target(I).Y = 300
Target(I).VX = Rnd(-100, 100)
Target(I).VY = Rnd(-50, 150)
Dim RandomColor As Int = xu.Color_RGB(Rnd(0,255), Rnd(0, 255), Rnd(0, 255))
Target(I).P.SetColorAndBorder(RandomColor, 1, xu.Color_Black, 3)
Form1.RootPane.AddNode(Target(I).P,300, 300, 30, 30)
Next
LastFrameTime = DateTime.Now
tmr.Initialize("tmr", 16) '16 ms = 60 frames per second (if all goes well ;-)
tmr.Enabled = True
End Sub
Sub tmr_Tick
'first attempt - rotating test panel, changing color, changing border corner radius
Dim T As Float = (DateTime.Now Mod 3000) / 3000 * 2 * cPI
Dim TempColor As Int = xu.Color_ARGB(255, 128 + Sin(T) * 127, 128 + Cos(T) * 127, 0)
TestPanel.SetColorAndBorder(TempColor, 5, xu.Color_Black, 25 + Sin(T * 2) * 24)
TestPanel.Rotation = T / cPI * 360
TestPanel.Left = Sin(T) * 200 + 300 - 50
TestPanel.Top = Cos(T) * 200 + 300 - 50
'second attempt - multiple objects
ThisFrameTime = DateTime.Now
Dim ElapsedTime As Float = (ThisFrameTime - LastFrameTime) / 1000
For I = 0 To NumTargets - 1
MoveTarget(Target(I), ElapsedTime)
Next
LastFrameTime = ThisFrameTime
End Sub
Sub MoveTarget(T As TargetType, ElapsedTime As Float)
T.VY = T.VY - 10 * ElapsedTime 'gravity
T.X = T.X + T.VX * ElapsedTime 'move X
If T.X < 0 Then
T.X = -T.X
T.VX = -T.VX
else if T.X > 600 - T.P.Width Then
T.X = (600 - T.P.Width) * 2 - T.X
T.VX = -T.VX
End If
T.Y = T.Y + T.VY * ElapsedTime 'move Y
If T.Y < 0 Then
T.Y = -T.Y
T.VY = -T.VY
else if T.Y > 600 - T.P.Height Then
T.Y = (600 - T.P.Height) * 2 - T.Y
T.VY = -T.VY
End If
T.P.Left = T.X
T.P.Top = 600 - (T.Y + T.P.Height) 'in gravity world, increasing Y means up
End Sub
```