Code: Select all
Structure PT3
x.f
y.f
z.f
EndStructure
Structure iPT2
x.i
y.i
EndStructure
Global Eye.PT3
Eye\x = 512
Eye\y = 384
Eye\z = 30
Procedure Cam2Scr(*Cam.PT3, *Scr.iPT2)
If *Cam\z > 0
; These two lines works wonders, and how/why is a complete mystery to me.
*Scr\x = eye\x + *Cam\x * eye\z / (*Cam\z + eye\z)
*Scr\y = eye\y - *Cam\y * eye\z / (*Cam\z + eye\z)
ProcedureReturn 1
EndIf
*Scr\x = -1
*Scr\y = -1
EndProcedure
If InitSprite() = 0
MessageRequester("Error", "Can't open screen & sprite enviroment!", 0)
End
EndIf
OpenWindow(0, 0, 0, 1024, 768, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_Invisible)
OpenWindowedScreen(WindowID(0), 0, 0, 1024, 768, 0, 0, 0)
HideWindow(0, 0)
NewList Stars.PT3()
Macro sxy
Stars()\x = -1000+Random(2000)
Stars()\y = -1000+Random(2000)
EndMacro
For I = 0 To 400
AddElement(Stars())
Stars()\z = Random(255)
sxy
Next
Repeat
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_CloseWindow
End
EndSelect
Until Event = 0
FlipBuffers()
ClearScreen(RGB(0, 0, 0))
StartDrawing(ScreenOutput())
ForEach Stars()
Cam2Scr(@Stars()\x, @p.iPT2)
If p\x >= 0 And p\x < 1024 And p\y >= 0 And p\y < 768
Col = 255-(Stars()\z)
Col = RGB(col, col, col)
Plot(p\x, p\y, Col)
Stars()\z - 1
Else
DeleteElement(Stars())
AddElement(Stars())
Stars()\z = 255
sxy
EndIf
Next
StopDrawing()
Delay(10)
ForEver
