done tidying up...

here it is:
/////////////////////////////////////////
//OpenFPS Level Editor Version 1.1
//made by: thenerd
//last modified: today, august 26th 2059 :)
/////////////////////////////////////////
/////////////////////////////////////////
//INIT STUFF
sync on
sync rate 0
sync
cls 0
/////////////////////////////////////////
/////////////////////////////////////////
//set the window title (not really needed in fullscreen, but whatever)
set window title "OpenFPS Level Editor"
/////////////////////////////////////////
//load static gui elements
//E.G. Title bar w/ logo, Status bar...
//these are pre-rendered to save speed
load image "back.png",1
//turn them into a sprite
sprite 1,0,0,1
//hide the sprite, we will use "paste sprite" later
hide sprite 1
/////////////////////////////////////////
/////////////////////////////////////////
//Load some gui elements
load image "glow1.png",2
load image "glow2.png",3
//these will come later...
`load image "glow1.png",2
`load image "glow1.png",2
//turn them into a sprite
sprite 2,0,0,2
//hide it to be "pasted"
hide sprite 2
/////////////////////////////////////////
/////////////////////////////////////////
//MORE SETUP
//Set the text size to 26 points
set text size 26
//set the camera viewport
set camera view 0,58,47,867,741
//color the backdrop black
color backdrop 0
//change the mouse to the "Vista" theme
change mouse 2
//turn off autocam (needed for skybox)
autocam off
//set the camera range to far away (for skybox)
set camera range 1,100000000
//make the skybox
assembleSkybox(9999, "skybox")
/////////////////////////////////////////
/////////////////////////////////////////
//WATER SETUP
///make the water plain
make object plain 777,10000,10000
position object 777,5000,0,5000
xrotate object 777,90
load effect "GGWaterV9.fx", 1, 0
load image "plainWater.png", 777
load image "perlin waves nmp.png", 888
texture object 777, 0, 777
texture object 777, 1, 888
set object effect 777, 1
SCALE OBJECT TEXTURE 777, 10,10
// setup the shader
null = make vector4(1)
set vector4 1, 5000, 3000, 5000, 1.0
set effect constant vector 1, "lightPos", 1
waterDiffuse# = 0.5
set effect constant float 1, "waterDiffuse", waterDiffuse#
/////////////////////////////////////////
/////////////////////////////////////////
//MAIN LOOP//////////////////////////////
/////////////////////////////////////////
do
`start of loop
`make sure the mouse is on the correct cursor
change mouse 2
`position the skybox relative to the player
position object 9999,camera position x(),camera position y(),camera position z()
`handle the 3d view and moving, and then gui elements
gosub _handle_3dmove1
`paste the pre-rendered gui elements
paste sprite 1,0,0
`show the screen fps and mouse position for debug
text 120,747,str$(screen fps())
text 200,747,"Mouse x: " + str$(Mousex()) + ", Mouse y: " + str$(mousey())
`update the screen
SYNC
`end of loop
loop
/////////////////////////////////////////
//GOSUBS/////////////////////////////////
/////////////////////////////////////////
/////////////////////////////////////////
//handle 3d moving and rendering gui
_handle_3dmove1:
`not moving
if shiftkey()=0:
`clear mousemove
null=mousemovex()
null=mousemovey()
`render gui
gosub _handle_gui
endif
`moving
if shiftkey()=1:
`control the camera with the arrowkeys and wsad
cr#=0:cf#=0
if rightkey()=1 or KEYSTATE(32)=1 then cr#=-6
if leftkey()=1 or KEYSTATE(30)=1 then cr#=6
if upkey()=1 or KEYSTATE(17)=1 then cf#=6
if downkey()=1 or KEYSTATE(31)=1 then cf#=-6
ncr#=curvevalue(cr#,ncr#,5)
ncf#=curvevalue(cf#,ncf#,5)
`mouselook
cx#=cx#+mousemovey()*0.2
cy#=cy#+mousemovex()*0.2
if cx#>80 then cx#=80
if cx#<-80 then cx#=-80
ncx#=curveangle(cx#,ncx#,2)
ncy#=curveangle(cy#,ncy#,2)
move camera ncf#
rotate camera 0,wrapvalue(ncy#-90),0
move camera ncr#
rotate camera 0,wrapvalue(ncy#+90),0
rotate camera ncx#,ncy#,0
change mouse 3
endif
return
/////////////////////////////////////////
/////////////////////////////////////////
//handle gui elements (dynamic)
_handle_gui:
mx=mousex()
my=mousey()
hide sprite 2
if mousezone(0,93,70,150)>0 then show sprite 2:sprite 2,0,0,2
if mousezone(0,176,66,246)>0 then show sprite 2:sprite 2,0,0,3
return
/////////////////////////////////////////
/////////////////////////////////////////
//FUNCTIONS//////////////////////////////
/////////////////////////////////////////
//FUNCTION MOUSEZONE(x1,y1,x2,y2)
//a function to detect if the mouse is in a zone of the screen
function mousezone(x1,y1,x2,y2):
hit=0
mx=mousex()
my=mousey()
if mx>x1:
if my>y1:
if mx<x2:
if my<y2:
hit=1
endif
endif
endif
endif
endfunction hit
/////////////////////////////////////////
//FUNCTION assembleSkybox(obj as dword, path as string)
//this function assembles the skybox.
function assembleSkybox(obj as dword, path as string)
set dir path
SKYBOX_TEX_START=800
make object plain obj, 0, 0 `Base object
position object obj, 0, 0, 0
make object plain obj + 1, 10000, 10000 ` The skybox will have the volume 10000^3 units by default
make mesh from object obj + 1, obj + 1
add limb obj, 1, obj + 1
offset limb obj, 1, 0, 5000, 0
rotate limb obj, 1, 90, 0, 0
add limb obj, 2, obj + 1
offset limb obj, 2, 0, 0, 5000
add limb obj, 3, obj + 1
offset limb obj, 3, 5000, 0, 0
rotate limb obj, 3, 0, 270, 0
add limb obj, 4, obj + 1
offset limb obj, 4, 0, 0, -5000
rotate limb obj, 2, 0, 180, 0
add limb obj, 5, obj + 1
offset limb obj, 5, -5000, 0, 0
rotate limb obj, 5, 0, 90, 0
add limb obj, 6, obj + 1
offset limb obj, 6, 0, -5000, 0
rotate limb obj, 6, 270, 0, 0
`message path + "pos_y." + ext + " exists: " + str$(file exist(path + "pos_y." + ext))
load image "pos_y.bmp", SKYBOX_TEX_START
texture limb obj, 1, SKYBOX_TEX_START
load image "pos_x.bmp", SKYBOX_TEX_START + 1
texture limb obj, 2, SKYBOX_TEX_START + 1
load image "pos_z.bmp", SKYBOX_TEX_START + 2
texture limb obj, 3, SKYBOX_TEX_START + 2
load image "neg_x.bmp", SKYBOX_TEX_START + 3
texture limb obj, 4, SKYBOX_TEX_START + 3
load image "neg_z.bmp", SKYBOX_TEX_START + 4
texture limb obj, 5, SKYBOX_TEX_START + 4
load image "neg_y.bmp", SKYBOX_TEX_START + 5
texture limb obj, 6, SKYBOX_TEX_START + 5
delete mesh obj + 1
delete object obj + 1
set object texture obj, 2, 0
set object light obj, false
set dir ".."
endfunction
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//END OF PROGRAM

forever loading...