Microsoft Small Basic

Program Listing:
Embed this in your website
'Setup the Graphics Window
GraphicsWindow.Width = Desktop.Width /2
GraphicsWindow.Height = Desktop.Height /2
GraphicsWindow.BackgroundColor = "Black"
GraphicsWindow.MouseMove = OnMouseMove
GraphicsWindow.KeyDown = OnKeyDown
GraphicsWindow.MouseDown = SetBackground

'Initialize Variables
continue = 1
x = 0
y = 0
deltaX = 1
deltaY = 1
paddleWidth = 120
paddleHeight = 20
ballDiameter = 16
slowdownFactor = 5
tags = "Landscape"

SetBackground()
GraphicsWindow.BrushColor = "Green"
paddle = Shapes.AddRectangle(paddleWidth, paddleHeight)
GraphicsWindow.BrushColor = "Yellow"
ball = Shapes.AddEllipse(ballDiameter, ballDiameter)

OnMouseMove()

While continue > 0

  x = x + deltaX
  y = y + deltaY

  gw = GraphicsWindow.Width
  gh = GraphicsWindow.Height

  If (x >= gw - ballDiameter or x <= 0) Then
    deltaX = -deltaX
  EndIf

  If (y <= 0) Then
    deltaY = -deltaY
  EndIf

  padX = Shapes.GetLeft (paddle)

  If y = (gh - (ballDiameter + paddleHeight)) And x >= padX and x <= (padX + paddleWidth) Then
    deltaY = -deltaY
  EndIf

  Shapes.Move(ball, x, y)
  Program.Delay(slowdownFactor)

  If (y >= gh) Then
    continue = -1
  EndIf
Endwhile

If continue < 0 Then
  GraphicsWindow.ShowMessage("You Lose", "Paddle")
Else
  GraphicsWindow.ShowMessage("Goodbye!", "Paddle")
EndIf
Program.End()


Sub OnMouseMove
  paddleX = GraphicsWindow.MouseX
  Shapes.Move(paddle, paddleX - (paddleWidth/2), GraphicsWindow.Height - paddleHeight)
EndSub

Sub OnKeyDown
  If GraphicsWindow.LastKey = "Escape" Then
  continue = 0
  EndIf
EndSub

Sub SetBackground
  path = Flickr.GetRandomPicture(tags)
  GraphicsWindow.DrawResizedImage(path, 0, 0, GraphicsWindow.Width, GraphicsWindow.Height)
EndSub
Copyright (c) Microsoft Corporation. All rights reserved.