It's hardly "game programming" material, but there is no "Demo" section, so...
Edit: I corrected the code, it's way better now. Modify #Res to make the screen wider and add circles...
Code: Select all
#Res=600
#radius=30
#space=#radius*2+10
#nb=#Res/#space-1
;{ Screen init
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0:MessageRequester("Error", "Can't open the sprite system", 0):End:EndIf
If OpenWindow(0, 0, 0,#Res, #Res, "Lissajous Curve", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)=0:MessageRequester("Error", "Can't open windowed screen!", 0):EndIf
If OpenWindowedScreen(WindowID(0), 0, 0, #Res, #Res, 0, 0, 0)=0:MessageRequester("Error", "Can't open windowed screen!", 0):EndIf
;}
Structure angle
angle.f
anglestep.f
x.i
y.i
color.i
EndStructure
NewList angle.angle()
For i=1 To #nb
AddElement(angle())
angle()\angle=-#PI/2
angle()\anglestep=0.01*i
angle()\x=#radius
angle()\y=#radius
angle()\color=RGB(Random(255),Random(255),Random(255))
Next i
Structure pt
x.i
y.i
color.i
EndStructure
NewList pt.pt()
CreateSprite(0,#Res,#Res)
StartDrawing(SpriteOutput(0))
i=1
ForEach angle()
Circle(angle()\x+i*#space,angle()\y,#radius,angle()\color)
Circle(angle()\x+i*#space,angle()\y,#radius-2,#Black)
Circle(angle()\x,angle()\y+i*#space,#radius,angle()\color)
Circle(angle()\x,angle()\y+i*#space,#radius-2,#Black)
i+1
Next
StopDrawing()
CopySprite(0,1)
CopySprite(1,2)
Repeat
FlipBuffers()
Repeat
Event = WindowEvent()
If event=#PB_Event_CloseWindow:End:EndIf
Until Event = 0
ExamineKeyboard()
DisplaySprite(0,0,0)
CopySprite(1,0)
StartDrawing(SpriteOutput(0))
i=1
ForEach angle()
x.f=#radius*Cos(angle()\angle)
y.f=#radius*Sin(angle()\angle)
angle()\x=x
angle()\y=y
Circle(x+#radius,#radius+y+i*#space,3,#White)
Circle(#radius+x+i*#space,#radius+y,3,#White)
LineXY(x+#radius,#radius+y+i*#space,#Res,#radius+y+i*#space,RGB(100,100,100))
LineXY(#radius+x+i*#space,#radius+y,#radius+x+i*#space,#Res,RGB(100,100,100))
angle()\angle+angle()\anglestep
i+1
Next
j=1
ForEach angle()
x=angle()\x
Color.i=angle()\color
PushListPosition(angle())
i=1
ForEach angle()
y=angle()\y
AddElement(pt())
pt()\x=x+#radius+j*#space
pt()\y=y+#radius+i*#space
pt()\color=RGB((Red(angle()\color)+Red(color))/2,(Green(angle()\color)+Green(color))/2,(Blue(angle()\color)+Blue(color))/2)
Circle(pt()\x,pt()\y,3,#White)
i+1
Next
PopListPosition(angle())
j+1
Next
StopDrawing()
StartDrawing(SpriteOutput(1))
ForEach(pt())
;Plot(pt()\x,pt()\y,pt()\color)
Circle(pt()\x,pt()\y,1,pt()\color)
Next
StopDrawing()
ClearList(pt())
FirstElement(angle())
If angle()\angle>2*#PI-#PI/2:angle()\angle=-#PI/2:CopySprite(2,1):EndIf
Until KeyboardPushed(#PB_Key_Escape)