FBA The Creator
http://www.fbacreator.com/fbaforum/

Fake 3D Stars Sample
http://www.fbacreator.com/fbaforum/viewtopic.php?f=10&t=13
Page 1 of 1

Author:  evilmaio [ Sun Mar 30, 2008 7:47 pm ]
Post subject:  Fake 3D Stars Sample

Screenshoot is not very cool ;)
Btw, this just simulates a 3d starfield ;)

Attachment:
fake_3d_stars.png
fake_3d_stars.png [ 2.62 KiB | Viewed 12810 times ]


Just copy and paste this code in a new FBA project:

Code:
-- Config costants
MAXSTARS=60
SPEED=1.07

-- precalculated values
SCREEN_HEIGHT = screenheight()
SCREEN_WIDTH = screenwidth()
SCREEN_H2 = SCREEN_HEIGHT/2
SCREEN_W2 = SCREEN_WIDTH/2

X_ORIG=SCREEN_W2
Y_ORIG=SCREEN_H2

MAXSTARS1 = MAXSTARS-1

local X={}
local Y={}

for F=0, MAXSTARS1 do
        X[F]=math.random(0,SCREEN_WIDTH)-SCREEN_W2
        Y[F]=math.random(0,SCREEN_HEIGHT)-SCREEN_H2
end

function onmainloop()

        clear(0,0,0)
        for F=0, MAXSTARS1 do
       
                D=math.abs(X[F])+40
                C=math.min(255, D*(255/SCREEN_W2))
               
                point(X[F]+X_ORIG, Y[F]+Y_ORIG, C, C, C)
               
                X[F]=X[F]*SPEED
                Y[F]=Y[F]*SPEED
               
                if X[F]>SCREEN_W2 then X[F]=X[F]-SCREEN_W2 end
                if Y[F]>SCREEN_H2 then Y[F]=Y[F]-SCREEN_H2 end
                if X[F]<-SCREEN_W2 then X[F]=X[F]+SCREEN_W2 end
                if Y[F]<-SCREEN_H2 then Y[F]=Y[F]+SCREEN_H2 end
        end
end

-- quit on stylus
function onstylusdown(x, y)
        quit()
end

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/