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=LMB722' /> </object>
Ang
=
45
AddLine
(
)
Sorce
=
"x=100;y=300"
Bulb
=
Shapes
.
AddImage
(
"http://sean.alyrica.net/LightBulb.png"
)
Shapes
.
Move
(
Bulb
,
Sorce
[
"x"
]
-
28
,
Sorce
[
"y"
]
+
5
)
GraphicsWindow
.
PenColor
=
"Yellow"
GraphicsWindow
.
DrawLine
(
100
,
100
,
Sorce
[
"x"
]
,
Sorce
[
"y"
]
)
GraphicsWindow
.
KeyDown
=
Kd
Angle
=
Ang
+
Ang
GetAngle
(
)
AddLine2
(
)
Sub
GetAngle
x
=
400
*
Math
.
Cos
(
Math
.
GetRadians
(
Angle
+
270
)
)
+
100
y
=
400
*
Math
.
Sin
(
Math
.
GetRadians
(
Angle
+
270
)
)
+
100
EndSub
Sub
AddLine
GraphicsWindow
.
PenColor
=
"Black"
Shapes
.
Remove
(
Line
)
x1
=
40
*
Math
.
Cos
(
Math
.
GetRadians
(
Ang
+
90
)
)
+
100
y1
=
40
*
Math
.
Sin
(
Math
.
GetRadians
(
Ang
+
90
)
)
+
100
x2
=
40
*
Math
.
Cos
(
Math
.
GetRadians
(
Ang
-
90
)
)
+
100
y2
=
40
*
Math
.
Sin
(
Math
.
GetRadians
(
Ang
-
90
)
)
+
100
Line
=
Shapes
.
AddLine
(
x1
,
y1
,
x2
,
y2
)
EndSub
Sub
Kd
If
GraphicsWindow
.
LastKey
=
"Up"
And
Ang
>
0
Then
Ang
=
Ang
-
1
AddLine
(
)
AddLine2
(
)
EndIf
If
GraphicsWindow
.
LastKey
=
"Down"
And
Ang
<
90
Then
Ang
=
Ang
+
1
AddLine
(
)
AddLine2
(
)
EndIf
EndSub
Sub
AddLine2
GraphicsWindow
.
PenColor
=
"Yellow"
Angle
=
Ang
+
Ang
GetAngle
(
)
Shapes
.
Remove
(
Line2
)
Line2
=
Shapes
.
AddLine
(
100
,
100
,
x
,
y
)
EndSub
Copyright (c) Microsoft Corporation. All rights reserved.