FBA The Creator

The True Multiplatform PC / PocketPC Opensource Development Tool - Read Only Mode - Kept only for historical purposes - Thank you all ;)
It is currently Thu Jun 04, 2026 4:09 am

All times are UTC




Post new topic  Reply to topic  [ 1 post ] 
Author Message
 Post subject: Fake 3D Stars Sample
PostPosted: Sun Mar 30, 2008 7:47 pm 
Offline
FBA Administrator
FBA Administrator
User avatar

Joined: Fri Mar 21, 2008 11:19 pm
Posts: 238
Location: Rome - Italy
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 12808 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


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Limited