Microsoft Small Basic

Program Listing: CVK888
' Scrolling Background -- By Krueg -- June 2012
' Use ARROWS to move
' ESCAPE to quit

gw = 640 'Window width
gh = 480 'Window Height
GraphicsWindow.Height = gh
GraphicsWindow.Width = gw
GraphicsWindow.Top = 5
GraphicsWindow.Left = 5
GraphicsWindow.BackgroundColor = "Black"
GraphicsWindow.Show()
sea = Shapes.AddImage(ImageList.LoadImage("http://krueg.com/sb/samples/sea.png"))
GraphicsWindow.KeyDown = OnKeyDown
GraphicsWindow.KeyUp = OnKeyUp

While ("true")
If key = "Left" Then
x = x + 1
ElseIf key = "Right" Then
x = x - 1
ElseIf key = "Up" Then
y = y + 1
ElseIf key = "Down" Then
y = y - 1
ElseIf key = "Escape" Then
Program.End()
EndIf

If x < -32 Then
x = x + 32
ElseIf x > 0 Then
x = x -32
EndIf
If y < -32 Then
y = y + 32
ElseIf y > 0 Then
y = y -32
EndIf
Shapes.Move(sea,x,y)
Program.Delay(5)
EndWhile

Sub OnKeyDown
key = GraphicsWindow.LastKey
EndSub

Sub OnKeyUp
key = ""
EndSub