Microsoft Small Basic

Program Listing: FKF358
GraphicsWindow.Show()
GraphicsWindow.Title = "Twister"
GraphicsWindow.Height = 200
GraphicsWindow.Width = 256
GraphicsWindow.BackgroundColor = "Black"
'Set the screen offset
o=140

'Set the initial angle
ANG = 0

'Main twister routine
Twist:

'Set the Amplitude and change it based on Y and ANG
AMP=(Math.Sin(ANG)*Y)+20

'Calculate for each row
FOR Y=0 TO 200 Step 3

'Set the coordinates
x1=((Math.Sin((Y/AMP)+ANG))*50)+o
x2=((Math.Sin((Y/AMP)+ANG+90))*50)+o
x3=((Math.Sin((Y/AMP)+ANG+180))*50)+o
x4=((math.Sin((Y/AMP)+ANG+270))*50)+o

'Draw each line
IF x1 GraphicsWindow.PenColor = "DarkRed"
GraphicsWindow.DrawLine(x1,y,x2,y)
EndIf

IF x2 GraphicsWindow.PenColor = "Red"
GraphicsWindow.DrawLine(x2,y,x3,y)
EndIf

IF x3 GraphicsWindow.PenColor = "DarkBlue"
GraphicsWindow.DrawLine(x3,y,x4,y)
EndIf

IF x4 GraphicsWindow.PenColor = "DarkRed"
GraphicsWindow.DrawLine(x4,y,x1,y)
EndIf
EndFor

'Delay before clearing the screen
Program.Delay(110)
GraphicsWindow.Clear()

'Increase the Angle
ANG=ANG+1

' Do it again!
GOTO TWIST