GraphicsWindow.Title = "Bowling Anime 0.21 - Hit arrow keys."
Init()
path = "http://www.nonkit.com/smallbasic.files/Ball.png"
GraphicsWindow.KeyDown = OnKeyDown
While "True"
x = gw / 2
y = gh + 120
a = 120
DrawBall()
positioning = "True"
While positioning
If keyDown Then
If GraphicsWindow.LastKey = "Up" Then
positioning = "False"
ElseIf GraphicsWindow.LastKey = "Left" Then
If 0 <= x - 10 Then
x = x - 10
DrawBall()
EndIf
ElseIf GraphicsWindow.LastKey = "Right" Then
If x + 10 <= gw Then
x = x + 10
DrawBall()
EndIf
EndIf
keyDown = "False"
EndIf
EndWhile
x0 = x
For y = gh - 1 To 212 Step -1
x = (gw / 2) * (1 - y / gh) + x0 * y / gh
a = a - 2
DrawBall()
Program.Delay(10)
EndFor
Program.Delay(1000)
EndWhile
Sub DrawBall
scale = y / 212
If shadow = "" Then
shadow = Shapes.AddEllipse(78, 20)
Shapes.SetOpacity(shadow, 50)
EndIf
Shapes.Move(shadow, x - 39, y - 10)
Shapes.Zoom(shadow, scale, scale)
If ball = "" Then
ball = Shapes.AddImage(path)
EndIf
Shapes.Move(ball, x - 39, y - 33 * scale - 39)
Shapes.Zoom(ball, scale, scale)
Shapes.Rotate(ball, a)
EndSub
Sub Color_Blacken
' Color | Blacken given color
' param color - given color
' param rate - 0..1
' return color - color blackened
Color_NameToColor()
Color_ColorToRGB()
r = Math.Floor(r * (1 - rate))
g = Math.Floor(g * (1 - rate))
b = Math.Floor(b * (1 - rate))
color = GraphicsWindow.GetColorFromRGB(r, g, b)
EndSub
Sub Color_ColorToRGB
' Color | Convert color to RGB values
' param color - "#rrggbb" (hexadecimal values)
' return r, g, b - RGB values 0..255
sR = Text.GetSubText(color, 2, 2)
sG = Text.GetSubText(color, 4, 2)
sB = Text.GetSubText(color, 6, 2)
hex = sR
Math_Hex2Dec()
r = dec
hex = sG
Math_Hex2Dec()
g = dec
hex = sB
Math_Hex2Dec()
b = dec
EndSub
Sub Color_NameToColor
' Color | Convert color name to color
' param color - color name
' returns color -"#rrggbb"
If Text.StartsWith(color, "#") Then
color = Text.ConvertToUpperCase(color)
Else
color = Text.ConvertToLowerCase(color)
color = colors[color]
EndIf
EndSub
Sub Math_Hex2Dec
' Math | Convert hexadecimal to decimal
' param hex
' return dec
dec = 0
len = Text.GetLength(hex)
For ptr = 1 To len
dec = dec * 16 + Text.GetIndexOf("123456789ABCDEF", Text.GetSubText(hex, ptr, 1))
EndFor
EndSub