Microsoft Small Basic

Program Listing: WWV036
'Animate Ball Recipe
'Teaches X and Y coordinates and some basic animation

'define a an ellipse shape named "ball" with a size of 30x30
ball = Shapes.AddEllipse(30,30)

'create a mouse move event named "mousemove"
GraphicsWindow.MouseMove = mousemove

'create a mouse down event named "SetXY"
GraphicsWindow.MouseDown = SetXY

'Create the SetXY subroutine

Sub SetXY
'set x=the x coordinate of the mouse click
x=GraphicsWindow.MouseX

'set y=the y coordinate of the mouse click
y=GraphicsWindow.MouseY

'create a small ellipse at the x and y coordinates click. Make the size 15x15.
GraphicsWindow.FillEllipse(x+10,y+10,15,15)

'Move the ball to the place where you clicked
Shapes.Animate(ball,x,y,800)

EndSub

Sub mousemove
x1 = GraphicsWindow.MouseX
y1 = GraphicsWindow.Mousey
GraphicsWindow.Title="x="+x1+" Y="+y1
EndSub