'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim time As Timer
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim cnv As Canvas
Dim stpanel As Panel
Dim xitbtn As Button
Dim starx(150) As Int 'xpos
Dim stary(150) As Int 'ypos
Dim starspeed(150) As Int 'stars
Dim nbstar(150) As Int 'numstars
' Ok let's add more fun, bouncing logo
Dim sintable(128) As Int
Dim numpos(128) As Int
Dim barpos As Int
Dim barre1 As ImageView ' For logo
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("starscroll") 'nothing special just stpanel + exitbtn + 1 imageView in layout
cnv.Initialize(stpanel)
' For starfield tables
For i=0 To nbstar.Length-1
starx(i)=Rnd(1,460) 'store xpos in table 100 xpos
stary(i)=Rnd(1,850) 'store ypos ..100 ypos
starspeed(i)=Rnd(1,8) 'store starspeed .. 100 speed
Next
'
' Create sintable 128 values of logo position
For i=0 To sintable.Length-1
sintable(i)=450-Sin(i*3.14159265/128)*550 'formula from Brian Postma , creator if BP soundmon on AMIGA
numpos(i)=sintable(i) ' Copie de sintable vers numpos
Next
barpos=0
time.Initialize("time",5)
time.Enabled=True
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub time_Tick
drawstars
drawlogo ' Dessin du LOGO.. Logo drawing
End Sub
Sub DrawStars
' nothing HARD here :) just clear stars ypos -starspeed(i) from table...
Dim clr As Int
For i=0 To nbstar.Length-1
cnv.DrawCircle(starx(i),stary(i)-starspeed(i),2,Colors.black,True,2dip)
cnv.DrawCircle(starx(i),stary(i),2,Clr,True,2dip)
stary(i)=stary(i)+starspeed(i)
If starspeed(i)=1 Then clr=Colors.RGB(100,100,100)
If starspeed(i)=2 Then clr=Colors.RGB(120,120,120)
If starspeed(i)=3 Then clr=Colors.RGB(140,140,140)
If starspeed(i)=4 Then clr=Colors.RGB(160,160,160)
If starspeed(i)=5 Then clr=Colors.RGB(180,180,180)
If starspeed(i)=6 Then clr=Colors.RGB(200,200,200)
If starspeed(i)=7 Then clr=Colors.RGB(220,220,220)
If starspeed(i)=8 Then clr=Colors.RGB(255,255,255)
If stary(i)>860 Then stary(i)=-10
stpanel.Invalidate
Next
End Sub
Sub drawlogo
'bouncing LOGO
Dim pos,y As Int
barpos=barpos+2 Mod 128
pos=barpos
For i=0 To 1
y=sintable(pos)
barre1.Top=y
pos=pos+(128/24)
pos=pos Mod 128
If barpos>124 Then barpos=0
stpanel.Invalidate
Next
End Sub
Sub xitbtn_Click
activity.Finish
End Sub