Here's an adaption of Thygrions BB source example of "Stars With Camera" converted to Freebasic using GFXLib.
And Im quite suprised in the difference in executable sizes. Over TinyPtc / gfx lib. Later I will modify and post serperately a tinyPTC version. Im guessing that gfx lib has more functionality included with it, to be producing the larger compiled exe size. UPXing results in compressing to half what ever the end result is.
Another thing it shows how simplish it is to convert over your BB source codes to FB.
Hope its of some benefit and use, so here goes:
'
' Stars with Camera
' Original BB Source by Thrygrion..
' FB adaption by Clyde Radcliffe April 06.
'
Chdir Exepath
Option Static
Option Explicit
Const XRES=640
Const YRES=480
Randomize Timer
Const PI = 3.141593
Const MAXSTARS=25000
Dim Shared ScreenBuffer As UByte Ptr
Dim Shared As Double StarX( MAXSTARS ), StarY( MAXSTARS ), StarZ( MAXSTARS ), StarZV( MAXSTARS )
Dim Shared RGBScreen( XRES, YRES )
Dim Shared move As Double = .05
Dim Shared damping As Double = .99
Dim Shared zoom As Double = 5
Dim Shared camx As Double= 0
Dim Shared camy As Double= 0
Dim Shared camz As Double= 0
Dim Shared camxv As Double= 0
Dim Shared camyv As Double= 0
Declare Sub InitializeStars()
Declare Sub StarPositions( ByVal StarNo )
Declare Sub RunStars()
Declare Sub RenderScreen( Buffer As UByte Ptr )
Declare Sub UpdateStars()
InitializeStars()
RunStars()
End
Sub InitializeStars()
Dim i
ScreenRes XRES,YRES,32,1,1
ScreenSet 1,0
SetMouse ,,0
ScreenBuffer = screenptr()
For i = 1 To MAXSTARS
StarPositions(i)
Next
End Sub
Sub RunStars()
Dim Key As String
While Key<>Chr(27)
Key=Inkey()
UpdateStars()
ScreenLock()
RenderScreen( ScreenBuffer )
ScreenUnlock()
'ScreenCopy()
Wend
End Sub
Sub StarPositions( ByVal StarNo )
StarX( StarNo ) = (Rnd(1)*2000)-1000 ')
StarY( StarNo ) = (Rnd(1)*2000)-1000 ')
StarZ( StarNo ) = (Rnd(1)*2000)-1000 ')
StarZV( StarNo ) = Rnd(1)*5.0
End Sub
Sub RenderScreen( Buffer As UByte Ptr)
Dim PosX, PosY
For PosY=1 to YRES-1
for PosX=1 to XRES-1
Poke Integer, Buffer+( (PosY)*XRES+(PosX)) Shl 2, RGBScreen( PosX, PosY )
RGBScreen( PosX, PosY )=0
Next
Next
End Sub
Sub UpdateStars()
Dim i
Dim As Double cx,sx,cy,sy,cz,sz
Dim As Double sxsx, sxsy
Dim As Double m00,m01,m02
Dim As Double m10,m11,m12
Dim As Double m20,m21,m22
Dim As Double cxsx, cxsy
Dim As Double tx, ty, tz
Dim As Double rx,ry,rz
Dim As Double nx,ny
Dim As Double c,c2,c3
Dim As Double ARGB2, ARGB3
cx = Cos(camx * PI/180.00 )
sx = Sin(camx * PI/180.00 )
cy = Cos(camy * PI/180.00 )
sy = Sin(camy * PI/180.00 )
cz = Cos(camz * PI/180.00 )
sz = Sin(camz * PI/180.00 )
sxsy = cdbl(sx * sy)
cxsy = cdbl(cx * sy)
m00 = cdbl( cy * cz)
m01 = cdbl(-cy * sz)
m02 = sy
m10 = cdbl(cx * sz) + cdbl(sxsy * cz)
m11 = cdbl(cx * cz) - cdbl(sxsy * sz)
m12 = cdbl(-sx * cy)
m20 = cdbl(sx * sz) - cdbl(cxsy * cz)
m21 = cdbl(sx * cz) + cdbl(cxsy * sz)
m22 = cdbl(cx * cy)
For i = 1 To MAXSTARS
starz(i) = starz(i) - starzv(i)
tx = starx(i)
ty = stary(i)
tz = starz(i)
rx = cdbl(tx * m00) + cdbl(ty * m10) + cdbl(tz * m20)
ry = cdbl(tx * m01) + cdbl(ty * m11) + cdbl(tz * m21)
rz = cdbl(tx * m02) + cdbl(ty * m12) + cdbl(tz * m22)
nx = (( cdbl(rx / rz) * 100) * zoom) + (XRES Shr 1)
ny = ((-cdbl(ry / rz) * 100) * zoom) + (YRES Shr 1)
If starz(i) <= -1000 then
starpositions(i)
starz(i) = 1000
ElseIf nx> 1 And nx <XRES - 2 And ny > 1 And ny < YRES - 2 And rz > 0 And rz <= 1000 then
c = 255 * csng(1.0 - csng(rz / 1000.0))
c2 = c * .66
c3 = c * .33
argb2 = (c2 Shl 16) + (c2 Shl 8) + c2
argb3 = (c3 Shl 16) + (c3 Shl 8) + c3
RGBScreen( nx, ny )=( c shl 16 ) or ( c shl 8 ) or c
RGBScreen( nx-1,ny) =argb2
RGBScreen( nx+1,ny) =argb2
RGBScreen( nx,ny-1)=argb2
RGBScreen( nx,ny+1)=argb2
RGBScreen( nx-2,ny)=argb3
RGBScreen( nx+2,ny)=argb3
RGBScreen( nx,ny-2)=argb3
RGBScreen( nx,ny+2)=argb3
EndIf
Next
camx = camx + .25
camy = camy + .5
camz = camz + .25
End Sub
Cheers Clyde