I think he means something else Clyde.
I am sorry if this doesnt work Hotshot, I dont have blitz any more but it shouln't need too many changes.
; 3D STARFIELD THAT GO TOWARD THE SCREEN AND MOVE AWAY FROM THE SCREEN in different directions !
; constants
Const PRESS_ESCAPE =1
Const MAX_STARS = 500
Const SCREEN_X = 800
Const SCREEN_Y = 600
Const SCREEN_CENTER_X = (SCREEN_X / 2)
Const SCREEN_CENTER_Y = (SCREEN_Y / 2)
Type TStar
Field xPos#
Field yPos#
Field zPos#
End Type
; ---------------
; -- variables --
; ---------------
Dim Stars.TStar(MAX_STARS) ; array for holding all stars
Graphics (SCREEN_X,SCREEN_Y)
SetBuffer BackBuffer()
HidePointer
dly=CreateTimer(60)
InitialiseStarField()
Global gd#
While Not KeyDown(PRESS_ESCAPE)
gd#=gd#+.5
Cls
update_Stars()
Flip:Cls
WaitTimer(dly)
Wend
End
; initialise the star variables
Function InitialiseStarField()
For i = 0 To MAX_STARS
Stars.TStar(i) = New TStar
Next
For i = 0 To MAX_STARS
InitialiseStar(i)
Next
End Function
; (re)initialise a star variable --
Function InitialiseStar(Index)
Stars(Index)\xPos# = Rnd (-500, 500) ; random number between -500 and 500
Stars(Index)\yPos# = Rnd (-500, 500) ; random number between -500 and 500
Stars(Index)\zPos# = Rnd (0, 1000) ; random number between 100 and 1000
End Function
; update and display all stars
Function Update_Stars()
mv#=4*Sin(gd)
Color 255, 255, 255
; loop through all stars in array
For i = 0 To MAX_STARS
; update star
Stars(i)\zPos# = Stars(i)\zPos# +mv#
; calculate x and y pos on 2d screen; divide x or y-vector to z-vector
; z-vector is distance to viewer, center of screen is vanishing point
x# = ((Stars(i)\xPos# / Stars(i)\zPos#) * 100) + SCREEN_CENTER_X
y# = ((Stars(i)\yPos# / Stars(i)\zPos#) * 100) + SCREEN_CENTER_Y
; star went offscreen
If mv#>0 Then
If Stars(i)\zPos# >1000 Then
; re-initialise star
; InitialiseStar(i)
Stars(i)\zPos# = Stars(i)\zPos#-1000
End If
End If
If mv#<=0 Then
If Stars(i)\zPos# <0 Then
; re-initialise star
; InitialiseStar(i)
Stars(i)\zPos# = Stars(i)\zPos#+1000
End If
End If
; draw star on 2d screen
Plot x#, y#
Next
End Function