Microsoft Small Basic

Program Listing: LNM164-0
' Roulette 0.2b
' Copyright (c) 2013 Nonki Takahashi
'
' History:
' 0.2b 18/06/2013 Rotated wheel. (LNM164-0)
' 0.11a 18/06/2013 Background color changed.
' 0.1a 12/06/2013 Created just for picture. (LNM164)
'
GraphicsWindow.Title = "Roulette 0.2b"
gw = GraphicsWindow.Width
gh = GraphicsWindow.Height
x0 = gw / 2
y0 = gh / 2
r4 = gh / 2 * 0.9
r3 = r4 * 0.8
r2 = r3 * 0.8
r1 = r3 * 0.5
rb = r1 * 0.15
fs = (r3 - r2) * 0.8
GraphicsWindow.BackgroundColor = "Green"
GraphicsWindow.BrushColor = "#331800"
GraphicsWindow.FillEllipse(x0 - r4, y0 - r4, r4 * 2, r4 * 2)
url = "http://www.nonkit.com/smallbasic.files/Roulette.png"
wheel = Shapes.AddImage(url)
Shapes.Move(wheel, x0 - r3, y0 - r3)
GraphicsWindow.PenWidth = 0
GraphicsWindow.BrushColor = "White"
ball = Shapes.AddEllipse(rb * 2, rb * 2)
angle = 0
Shapes.Animate(ball, x0 - rb , y0 - rb - (r1 + r2) / 2, 1000)
GraphicsWindow.BrushColor = "Black"
Controls.AddButton("Start", 10, 10)
Controls.ButtonClicked = OnButtonClicked
Timer.Interval = 1000/24
Sub OnButtonClicked
da0 = Math.GetRandomNumber(10) + 10
t0 = Clock.ElapsedMilliseconds
Timer.Tick = OnTick
EndSub
Sub OnTick
t1 = Clock.ElapsedMilliseconds
da = da0 - (t1 - t0) / 1000
If 0 < da Then
angle = angle + da
If 360 <= angle Then
angle = angle - 360
EndIf
Shapes.Rotate(wheel, angle)
Else
Timer.Tick = Dummy
EndIf
EndSub
Sub Dummy
EndSub