Microsoft Small Basic
Program Listing: NWH922
' The Turtle says Happy New Year
' http://blogs.msdn.com/smallbasic/archive/2009/01/04/the-turtle-says-happy-new-year.aspx
PrepareWindow()
Turtle.Show()
turtleBaseSpeed = 9
START:
GreetByTurtle()
Draw2009()
ChangeBackgroundImage()
Draw2009()
Program.Delay(3000)
turtleBaseSpeed = Math.GetRandomNumber(7) + 3
Goto START
END:
Sub PrepareWindow
GraphicsWindow.BackgroundColor = "SteelBlue"
GraphicsWindow.Title = "あけまして おめでとう By Small Basic"
GraphicsWindow.Width = 640
GraphicsWindow.Height = 480
GraphicsWindow.MouseUp = ChangeBackgroundImage
GraphicsWindow.Show()
EndSub
Sub ChangeBackgroundImage
pic = Flickr.GetRandomPicture("happy new year 2009")
GraphicsWindow.DrawResizedImage(pic, 0, 0, 640, 480)
EndSub
Sub GreetByTurtle
Turtle.X = 50
Turtle.Y = 50
'"H"
angle = 180
dist = 50
DrawLine()
angle = 0
dist = 25
MoveNoLine()
angle = 90
dist = 25
DrawLine()
angle = 0
dist = 25
MoveNoLine()
angle = 180
dist = 50
DrawLine()
'"A"
DrawA()
'"P"
DrawP()
angle = 90
dist = 20
MoveNoLine()
angle = 180
dist = 50
MoveNoLine()
'"P"
DrawP()
angle = 90
dist = 20
MoveNoLine()
'"Y"
DrawY()
angle = 90
dist = 20
MoveNoLine()
angle = 180
dist = 50
MoveNoLine()
'"N"
angle = 0
dist = 50
DrawLine()
angle = (180 - 25)
dist = 50
DrawLine()
dist = -50
MoveNoLine()
angle = 90
dist = 25
MoveNoLine()
angle = 180
dist = 50
DrawLine()
angle = 90
dist = 15
MoveNoLine()
angle = 0
dist = 50
MoveNoLine()
'"E"
DrawE()
angle = 0
dist = 50
MoveNoLine()
'"W"
angle = (180 - 15)
dist = 52
DrawLine()
angle = 15
DrawLine()
angle = (180 - 15)
DrawLine()
angle = 15
DrawLine()
angle = 90
dist = 20
MoveNoLine()
'"Y"
DrawY()
'"E"
DrawE()
'"A"
DrawA()
'"R"
DrawP()
angle = 180
dist = 25
MoveNoLine()
angle = 90 + 45
dist = 35
DrawLine()
dist = -35
MoveNoLine()
angle = 0
dist = 25
MoveNoLine()
angle = 90
dist = 40
MoveNoLine()
'"!"
angle = 180
dist = 35
DrawLine()
dist = 15
MoveNoLine()
For i=1 to 18
Turtle.Turn(10)
EndFor
EndSub
Sub DrawLine
Turtle.Speed = turtleBaseSpeed
GraphicsWindow.PenColor = "White"
GraphicsWindow.PenWidth = 8
Turtle.PenDown()
Turtle.Angle = angle
Turtle.Turn(0)
Turtle.Move(dist)
Turtle.PenUp()
Turtle.Angle = angle + 180
Turtle.Move(dist)
GraphicsWindow.PenColor = GraphicsWindow.GetRandomColor()
GraphicsWindow.PenWidth = 4
Turtle.PenDown()
Turtle.Angle = angle
Turtle.Move(dist)
EndSub
Sub MoveNoLine
Turtle.Speed = turtleBaseSpeed
Turtle.PenUp()
Turtle.Angle = angle
Turtle.Turn(0)
Turtle.Move(dist)
EndSub
Sub DrawRightHalfCircle
Turtle.Speed = 10
GraphicsWindow.PenColor = "White"
GraphicsWindow.PenWidth = 8
Turtle.Angle = 90
Turtle.PenDown()
MoveHalfCircle()
Turtle.PenUp()
MoveHalfCircle()
GraphicsWindow.PenColor = GraphicsWindow.GetRandomColor()
GraphicsWindow.PenWidth = 4
Turtle.PenDown()
MoveHalfCircle()
Turtle.PenUp()
MoveHalfCircle()
EndSUb
Sub MoveHalfCircle
For i=1 to 9
Turtle.Move(5)
Turtle.Turn(20)
EndFor
EndSub
Sub DrawA
angle = 15
dist = 50
DrawLine()
angle = (180 - 15)
dist = 50
DrawLine()
'angle = (180 - 15)
dist = -20
MoveNoLine()
angle = 90
dist = -15
MoveNoLine()
dist = 15
DrawLine()
angle = (180 - 15)
dist = 20
MoveNoLine()
EndSub
Sub DrawE
angle = 90
dist = 20
MoveNoLine()
dist = -20
DrawLine()
angle = 180
dist = 50
DrawLine()
dist = -25
MoveNoLine()
angle = 90
dist = 18
DrawLine()
dist = -18
MoveNoLine()
angle = 180
dist = 25
MoveNoLine()
angle = 90
dist = 20
DrawLine()
EndSub
Sub DrawP
angle = 90
dist = 3
MoveNoLine()
angle = 0
dist = 50
DrawLine()
DrawRightHalfCircle()
EndSub
Sub DrawY
angle = (180 - 30)
dist = 30
DrawLine()
angle = 30
dist = -30
MoveNoLine()
dist = 60
DrawLine()
EndSub
Sub Draw2009
GraphicsWindow.BrushColor = "White"
GraphicsWindow.FontSize = 50
GraphicsWindow.DrawText(480, 50, "2009")
EndSub