Microsoft Small Basic

Program Listing: FGM769
' Simple Donkey Kong 0.1a
' Small Basic version written by Nonki Takahashi.
'
' History:
' 0.1a 2014-03-08 Created only for graphics. ()
'
GraphicsWindow.Title = "Simple Donkey Kong 0.1a"
Init()
param = "x1=20;y1=40;x2=578;y2=60;height=20;pitch=10;color=DeepPink;"
Slope_Add()
param = "x=30;y=100;width=300;height=300;pw=20;"
Barrel_Add()
Sub Barrel_Add
' param["x"]
' param["y"]
' param["width"]
' param["height"]
' param["pw"]
x = param["x"] - param["pw"] / 2
y = param["y"] - param["pw"] / 2
width = param["width"] + param["pw"]
height = param["height"] + param["pw"]
GraphicsWindow.BrushColor = "DimGray"
GraphicsWindow.FillRectangle(x, y, width, height)
_pw = GraphicsWindow.PenWidth
GraphicsWindow.PenWidth = param["pw"]
x = param["x"]
y = param["y"]
width = param["width"]
height = param["height"]
rx = width / 2
ry = height / 2
xo = x + rx
yo = y + ry
FillPies()
GraphicsWindow.PenColor = "Peru"
GraphicsWindow.DrawEllipse(x, y, width, height)
percent = 75
GraphicsWindow.BrushColor = "Black"
FillInnerEllipse()
percent = 55
GraphicsWindow.BrushColor = "Peru"
FillInnerEllipseSlice()
p1 = 80
p2 = 60
DrawRivets()
GraphicsWindow.PenWidth = _pw
EndSub
Sub DrawRivets
' param xo, yo
' param rx, ry
' param p1, p2
GraphicsWindow.BrushColor = "DimGray"
For a = 22.5 To 337.5 Step 45
_a = Math.GetRadians(a)
rx2 = rx * (p1 + p2) / 200
ry2 = ry * (p1 + p2) / 200
xo2 = xo + rx2 * Math.Cos(_a)
yo2 = yo + ry2 * Math.Sin(_a)
rx3 = rx * (p1 - p2) / 400
ry3 = ry * (p1 - p2) / 400
GraphicsWindow.FillEllipse(xo2 - rx3 * 0.8, yo2 - ry3 * 0.8, rx3 * 1.6, ry3 * 1.6)
EndFor
EndSub
Sub FillPies
' param xo, yo
' param rx, ry
x1 = xo
y1 = yo
da = 5
For a = 0 To 360 Step da
p = Math.Ceiling(a / 45)
If Math.Remainder(p, 2) = 0 Then
GraphicsWindow.BrushColor = "Chocolate"
Else
GraphicsWindow.BrushColor = "Sienna"
EndIf
_a = Math.GetRadians(a)
x3 = xo + rx * Math.Cos(_a)
y3 = yo + ry * Math.Sin(_a)
If 0 < a Then
GraphicsWindow.FillTriangle(x1, y1, x2, y2, x3, y3)
EndIf
x2 = x3
y2 = y3
EndFor
EndSub
Sub FillInnerEllipse
width2 = width * percent / 100
height2 = height * percent / 100
x2 = xo - width2 / 2
y2 = yo - height2 / 2
GraphicsWindow.FillEllipse(x2, y2, width2, height2)
EndSub
Sub FillInnerEllipseSlice
width2 = width * percent / 100
height2 = height * percent / 100
_x2 = xo - width2 / 2
ry2 = height2 / 2
_y2 = yo - ry2
For y = yo - ry2 To yo + ry2 Step ry2 / 4
s = Math.Ceiling((y - (yo - ry2)) / (ry2 / 2))
If Math.Remainder(s, 2) = 0 Then
GraphicsWindow.BrushColor = "Chocolate"
Else
GraphicsWindow.BrushColor = "Sienna"
EndIf
y3 = y
y4 = y
dx = Math.SquareRoot(ry2 * ry2 - (yo - y) * (yo - y))
x3 = xo - dx
x4 = xo + dx
If yo - ry2 < y Then
GraphicsWindow.FillTriangle(x1, y1, x2, y2, x3, y3)
GraphicsWindow.FillTriangle(x2, y2, x3, y3, x4, y4)
EndIf
x1 = x3
y1 = y
x2 = x4
y2 = y
EndFor
GraphicsWindow.DrawEllipse(_x2, _y2, width2, height2)
EndSub
Sub Slope_Add
' param["x1"]
' param["y1"]
' param["x2"]
' param["y2"]
' param["height"]
' param["pitch"]
' param["color"]
GraphicsWindow.PenColor = param["color"]
x1 = param["x1"]
y1 = param["y1"]
x2 = param["x2"]
y2 = param["y2"]
GraphicsWindow.DrawLine(x1, y1, x2, y2)
x3 = x1
y3 = y1 + param["height"]
x4 = x2
y4 = y2 + param["height"]
GraphicsWindow.DrawLine(x3, y3, x4, y4)
pitch = param["pitch"]
up = "False"
For x5 = x1 To x2 - pitch Step pitch
x6 = x5 + pitch
If up Then
y5 = y3 + (y4 - y3) * (x5 - x3) / (x4 - x3)
y6 = y1 + (y2 - y1) * (x6 - x1) / (x2 - x1)
Else
y5 = y1 + (y2 - y1) * (x5 - x1) / (x2 - x1)
y6 = y3 + (y4 - y3) * (x6 - x3) / (x4 - x3)
EndIf
GraphicsWindow.DrawLine(x5, y5, x6, y6)
up = Not[up]
EndFor
EndSub
Sub Init
gw = 598
gh = 428
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
GraphicsWindow.BackgroundColor = "Black"
Not = "True=False;False=True;"
EndSub