Microsoft Small Basic

Program Listing: HHF879
' Make-A-Face Game 0.1
' Copyright (c) 2014 Nonki Takahashi. MIT License.
' History:
' 0.1 2014-06-15 Created. ()
'
GraphicsWindow.Title = "Make-A-Face Game 0.1"
GraphicsWindow.BackgroundColor = "LightGray"
GraphicsWindow.Width = 600
GraphicsWindow.Height = 600
GraphicsWindow.BrushColor = "Ivory"
GraphicsWindow.FillEllipse(100, 50, 400, 500)
GraphicsWindow.FillEllipse(20, 200, 100, 200)
GraphicsWindow.FillEllipse(480, 200, 100, 200)
url = "http://www.nonkit.com/smallbasic.files/"
part = "1=eye1.png;2=eye2.png;3=nose.png;4=mouth.png;"
x = 10
y = 10
For i = 1 To 4
img = ImageList.LoadImage(url + part[i])
obj[i]["height"] = ImageList.GetHeightOfImage(img)
obj[i]["width"] = ImageList.GetWidthOfImage(img)
obj[i]["obj"] = Shapes.AddImage(img)
obj[i]["x"] = x
obj[i]["y"] = y
Shapes.Move(obj[i]["obj"], x, y)
y = y + obj[i]["height"] + 10
EndFor
picked = 0
GraphicsWindow.MouseDown = OnMouseDown
GraphicsWindow.MouseUp = OnMouseUp
GraphicsWindow.MouseMove = OnMouseMove
While "True"
If mouseDown And (picked = 0) Then
Pick()
ElseIf mouseMove And (0 < picked) Then
obj[picked]["x"] = mx - obj[picked]["dx"]
obj[picked]["y"] = my - obj[picked]["dy"]
Shapes.Move(obj[picked]["obj"], obj[picked]["x"], obj[picked]["y"])
mouseMove = "False"
EndIf
EndWhile
Sub OnMouseDown
mx = GraphicsWindow.MouseX
my = GraphicsWindow.MouseY
mouseDown = "True"
EndSub
Sub OnMouseUp
picked = 0
mouseDown = "False"
EndSub
Sub OnMouseMove
mx = GraphicsWindow.MouseX
my = GraphicsWindow.MouseY
mouseMove = "True"
EndSub
Sub Pick
For picked = 4 To 1 Step -1
x1 = obj[picked]["x"]
x2 = x1 + obj[picked]["width"]
y1 = obj[picked]["y"]
y2 = y1 + obj[picked]["height"]
If x1 <= mx And mx <= x2 And y1 <= my And my <= y2 Then
obj[picked]["dx"] = mx - x1
obj[picked]["dy"] = my - y1
Goto break
EndIf
EndFor
break:
EndSub