Microsoft Small Basic

Program Listing: HVF266
' Flying Carpet
' Copyright © 2017 Nonki Takahashi. The MIT License.
' Last update 2017-10-18

GraphicsWindow.Title = "Flying Carpet"
gw = 598
gh = 428
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
' sky
GraphicsWindow.BackgroundColor = "SkyBlue"
' ground
GraphicsWindow.BrushColor = "Gray"
GraphicsWindow.FillRectangle(0, 400, gw, gh - 400)
' carpet
len = 280 ' link length
GraphicsWindow.PenWidth = 10
GraphicsWindow.PenColor = "#CC0000"
c[1] = Shapes.AddLine(0, 0, 400, 0)
x = 100
y = 220 + len / 2
Shapes.Move(c[1], x, y)
GraphicsWindow.PenWidth = 0
GraphicsWindow.BrushColor = "#CC0000"
dx[2] = -10
dy[2] = -15
dx[3] = 390
dy[3] = -15
For i = 2 To 3
c[i] = Shapes.AddEllipse(20, 20)
Shapes.Move(c[i], x + dx[i], y + dy[i])
EndFor
GraphicsWindow.BrushColor = "#FFFFFF"
For i = 4 To 5
c[i] = Shapes.AddEllipse(20, 20)
dx[i] = 50 + (i - 4) * 300 - 10
dy[i] = -15
Shapes.Move(c[i], x + dx[i], y + dy[i])
EndFor
' link
For i = 1 To 2
l[i] = Shapes.AddRectangle(20, len)
Shapes.Move(l[i], 150 + (i - 1) * 300 - 10, 215 - len / 2)
EndFor
' pole
GraphicsWindow.PenWidth = 0
GraphicsWindow.BrushColor = "#00CCCC"
For i = 1 To 2
p[i] = Shapes.AddRectangle(40, 200)
Shapes.Move(p[i], 150 + (i - 1) * 300 - 20, 220 - 20)
EndFor
angle = 0
While "True"
angle = angle + 5
If 360 <= angle Then
angle = angle - 360
EndIf
MoveCarpet()
ms = 100 - 40 * (Math.Cos(_angle) + 1)
Program.Delay(ms)
EndWhile

Sub MoveCarpet
_angle = Math.GetRadians(angle)
x = 100 - len / 2 * Math.Sin(_angle)
y = 220 + len / 2 * Math.Cos(_angle)
For i = 1 To 5
Shapes.Move(c[i], x + dx[i], y + dy[i])
EndFor
For i = 1 To 2
Shapes.Rotate(l[i], angle)
EndFor
EndSub