Microsoft Small Basic
Program Listing: RPC846-4
' Sonic Animation Example
' by Mainchip (2012/Oct)
' modded by GoToLoop
' RPC846-4
' http://social.msdn.microsoft.com/Forums/en-US/smallbasic
'/thread/94015515-5579-4463-b885-9d77ec11b2cb
'VarInit
gw = 320
gh = 240
gwH = Math.Round(gw/2)
ghH = Math.Round(gh/2)
fps = 30
zoom = 5
isLocal = "False"
'Set GFX window
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
GraphicsWindow.BackgroundColor = "White"
'Load & create shapes
ImagePath()
LoadImages()
CreateShapes()
'Set timer
Timer.Interval = Math.Round( 1000/fps )
Timer.Tick = Animation
'Pause & exit
GraphicsWindow.TextInput = KeyPressed
GraphicsWindow.MouseDown = KeyPressed
'Timer
Sub Animation
idx = idx + 1
Shapes.ShowShape( sonic[idx] )
If idx > hashIdx Then
idx = 1
Shapes.ShowShape( sonic[1] )
Shapes.HideShape( sonic[hashIdx] )
Else
Shapes.HideShape( sonic[idx-1] )
EndIf
GraphicsWindow.Title = "Sonic " + idx
EndSub
'Load all frames as images
Sub LoadImages
For idx = 1 To hashIdx
GraphicsWindow.Title = "Loading " + idx
If isLocal Then
sonicImg[idx] = ImageList.LoadImage(local + file + idx + ext)
Else
sonicImg[idx] = ImageList.LoadImage(http + code[idx] + path + hash[idx] + file + idx + ext)
EndIf
Sound.PlayClick()
EndFor
sonicWdhSzH = Math.Round( ImageList.GetWidthOfImage ( sonicImg[1] ) / 2 )
sonicHgtSzH = Math.Round( ImageList.GetHeightOfImage( sonicImg[1] ) / 2 )
If sonicWdhSzH < 5 Or sonicHgtSzH < 5 Then
sonicWdhSzH = 14
sonicHgtSzH = 18
EndIf
EndSub
'Load all images as shapes
Sub CreateShapes
For idx = 1 To hashIdx
sonic[idx] = Shapes.AddImage( sonicImg[idx] )
Shapes.HideShape( sonic[idx] )
Shapes.Zoom( sonic[idx] zoom,zoom )
Shapes.Move( sonic[idx] gwH - sonicWdhSzH*zoom, ghH - sonicHgtSzH*zoom )
EndFor
EndSub
'Pause or exit by key press
Sub KeyPressed
If GraphicsWindow.LastKey = "Escape" Then
Sound.PlayChimeAndWait()
Program.End()
ElseIf isPaused Then
isPaused = "False"
Timer.Resume()
Else
isPaused = "True"
Timer.Pause()
EndIf
Sound.PlayClick()
EndSub
'Image URLs
Sub ImagePath
http = "http://"
path = ".blu.livefilestore.com/"
local = Program.Directory + "\Images\"
file = "sonic"
ext = ".png"
code = "1=msglqg;2=njztla;3=njypvw;4=njbzyw;5=msfvwq;6=msekzg;"
hash[1] = "y1mYVkmzkFIPUoi7nKSow1rLyiuML_0aN7-ysRFQoGHrn9ejyFwLcHmdyLswYr2mmmolISlSFanje5NzvUYZCychfMqGHRT3KWRRDqdPjoq7vdYSlD6JWpcWA/"
hash[2] = "y1m_9F2M6eVmDSTtZVOy2A5pqnla06BlAJRq_PYJNu8coxiJoCS-lJQLfdDa47NY33Y4Oi7xi6vd7JU4Fzw6SwiwqV1nheRkbwrzeYq7aawvxKtPO_6dBgV8Q/"
hash[3] = "y1m_9F2M6eVmDQsdJoGSefI_dFeHO0ZeU-JQK1eiXmAo53riD6zTAdgjz4U_nPdm6e9zJPHlei1N5SfFEW1phRCgt90Ni6uv92NLXM3gBH-hiljvdCgMi3fPQ/"
hash[4] = "y1m_9F2M6eVmDRzEKv8Ui0GD00DVoW91q48S83o_K9HwoOcR2Ik2TtHJa8-cUmqv0nWQCDBBa_vqmu44AZF-2UNM7Kk6tAPOacU2z25TfZley1gA4WLzz3P0A/"
hash[5] = "y1mTcPX35zs_Yk_-KZPvNDUJ7CMKxEHc84tuAaap1fi1oYgby2Qx-g8Y9WtFf_-P220SPg1d5WVdp_VAZwKHx-o-NZb8xKMvAQwgEI5q5HkHq5kwCnc6Z64ow/"
hash[5] = "y1mTcPX35zs_Yk_-KZPvNDUJ7CMKxEHc84tuAaap1fi1oYgby2Qx-g8Y9WtFf_-P220SPg1d5WVdp_VAZwKHx-o-NZb8xKMvAQwgEI5q5HkHq5kwCnc6Z64ow/"
hash[6] = "y1mTcPX35zs_Ylfl3bRoMzOa5UuWSRmKeWJ5Fp7IB2RFjMQfVEpugSLc0lCf31Y2oDtigVPMUCbg7J1TpizCaMopRuIewYlPRD8i_RX07b6_IYXt--xTvyrbw/"
hashIdx = Array.GetItemCount(hash)
EndSub