Microsoft Small Basic
Program Listing:
Embed this in your website
<object id='sbapp' data='data:application/x-silverlight-2,' type='application/x-silverlight-2' width='640' height='480'> <param name='source' value='http://smallbasic.com/program/ClientBin/SBWeb.xap'/> <param name='onError' value='onSilverlightError' /> <param name='background' value='white' /> <param name='minRuntimeVersion' value='3.0.40624.0' /> <param name='autoUpgrade' value='true' /> <param name='initParams' value='programId=KVZ619-1' /> </object>
' Small Basic Challenge -- Sept. 2012 -- By Krueg -- V 1.1
'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
2
If
Key
=
"Left"
Then
yInc
=
yInc
*
.95
ElseIf
Key
=
"Right"
Then
yInc
=
yInc
*
1.05
EndIf
If
y
>
yCenter
Then
yStep
=
yStep
-
yInc
If
Key
=
"Down"
Then
yStep
=
yStep
*
.95
EndIf
Else
yStep
=
yStep
+
yInc
If
Key
=
"Up"
Then
yStep
=
yStep
*
1.05
EndIf
EndIf
Key
=
""
y
=
y
+
yStep
Shapes
.
Move
(
Dot
[
x
]
,
x
,
y
)
Program
.
Delay
(
5
)
EndFor
EndWhile
Sub
OnKeyDown
Key
=
GraphicsWindow
.
LastKey
EndSub
Sub
OnKeyUp
Key
=
""
EndSub
Sub
InitVariables
GraphicsWindow
.
PenColor
=
"Blue"
GraphicsWindow
.
BrushColor
=
"Blue"
For
x
=
0
To
800
Step
2
Dot
[
x
]
=
Shapes
.
AddEllipse
(
10
,
10
)
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
Copyright (c) Microsoft Corporation. All rights reserved.