Microsoft Small Basic

Program Listing: KVZ619
' Small Basic Challenge -- Sept. 2012 -- By Krueg
'http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/88d814da-7691-4103-9785-6886f5cb9105

'Tap the arrow keys to adjust the wave

yCenter = 300
yStep = 0
yInc = .2
y = 400

SetupWindow()
InitVariables()
GraphicsWindow.KeyDown = OnKeyDown
GraphicsWindow.KeyUp = OnKeyUp

While ("True")
For x = 0 To 800 Step 4
If Key = "Left" Then
yInc = yInc * .9
ElseIf Key = "Right" Then
yInc = yInc * 1.1
EndIf
If y > yCenter Then
yStep = yStep - yInc
If Key = "Down" Then
yStep = yStep * .9
EndIf
Else
yStep = yStep + yInc
If Key = "Up" Then
yStep = yStep * 1.1
EndIf
EndIf
y = y + yStep
Shapes.Move(Dot[x],x,y)
Program.Delay(10)
EndFor
EndWhile

Sub OnKeyDown
Key = GraphicsWindow.LastKey
EndSub

Sub OnKeyUp
Key = ""
EndSub

Sub InitVariables
GraphicsWindow.PenColor = "Blue"
For x = 0 To 800 Step 4
Dot[x] = Shapes.AddEllipse(6,6)
Shapes.Move(Dot[x],x,yCenter)
EndFor
GraphicsWindow.BrushColor = "Red"
Note = Shapes.AddText("Tap the ARROW keys to affect the wave!")
Shapes.Move(Note,50,20)
EndSub

Sub SetupWindow
GraphicsWindow.Width = 800
GraphicsWindow.Height = 600
GraphicsWindow.BackgroundColor = "Black"
GraphicsWindow.Title = "Krueg -- Wave Simulator -- Sept. 2012"
GraphicsWindow.Show()
EndSub