#constant imgTile 1
#constant objSky 1
#constant MatID 1
` Seed randomizer
randomize timer()
initDisplayProperties()
initMedia()
` Main loop.
do
` Set cursor and display frame per second.
set cursor 0, 0
print "FPS: "; screen fps()
` Control camera
control camera using arrowkeys 0, 2, 1
` Position skybox to camera position.
position object objSky, camera position x(), 72, camera position z()
` Update display.
sync
loop
end
function freeObj()
local ID as integer
ID = 0
repeat
inc ID
until object exist(ID) = 0
endfunction ID
function initDisplayProperties()
` Turn vertical sync on.
` Gives a more consistent frame rate then setting the frame rate
` to the monitor refresh rate by using - Sync Rate.
set display mode screen width(), screen height(), screen depth(), 1
` Turn sync and the backdrop on.
sync on
backdrop on
` Disable automatic camera positioning. Set camera range and position.
autocam off
set camera range 1, 1000
position camera 0, 72, 0
` Enable fog. Set fog distance and color.
fog on
fog distance 250, 750
fog color 0x40202020
endfunction
function initMedia()
local objID as integer
local objSize as float
` Load resources.
load image "tiles.png", imgTile
load object "sky.x", objSky
` Set skybox properties.
set object collision off objSky
set object texture objSky, 2, 0
set object light objSky, 0
set object fog objSky, 0
disable object zwrite objSky
make matrix matID, 10000, 10000, 64, 64
set matrix matID, 0, 0, 1, 0, 1, 1, 1
set matrix texture matID, 1, 0
prepare matrix texture matID, 1, 4, 4
position matrix matID, -5000, 0, -5000
update matrix matID
set matrix priority matID, 1
for i=0 to 999
objID = freeObj()
objSize = rnd(44)+5
make object sphere objID, objSize, 16, 16
set object cull objID, 1
position object objID, -5000+rnd(10000), objSize/2.0, -5000+rnd(10000)
color object objID, rgb(rnd(255), rnd(255), rnd(255))
next i
endfunction
Media included in download.