Level editor?

Blitz3D Forums/Blitz3D Programming/Level editor?

elseano(Posted 2003) [#1]
How would I go about making a leve-editor in blitz 3d?
Can somebody give me some sort of useful commands or a pre-made editr that I can study? Im just curious, really, so dont go out of your way to help me.
Thanks.


Caff(Posted 2003) [#2]
There are a couple of 3d editors you could take a look at if you're new to mapping. Both of these were written in Blitz and are very high quality:

Cartography Shop -
http://cartographyshop.thegamecreators.com/?f=trial

Quill 3d (includes other modelling)
http://www.shareup.com/Quill_3d-download-5947.html

If you're looking for functions, try doing some searches on Google for tutorials on CSG (Constructive Solid Geometry). When you have an understanding of what it is, take a look at these functions on the code archives:

http://www.blitzbasic.com/codearcs/codearcs.php?code=560

http://www.blitzbasic.com/codearcs/codearcs.php?code=552


Jeroen(Posted 2003) [#3]
as for "entity editors" (placing objects in space) I strongly recommend writing your own editor; it will allow you to use YOUR structure, instead of someone else's


Doggie(Posted 2003) [#4]
In a couple of days I'll have my world creator,HomeSpun
back on line available for download.
In the meantime here's
a very early development version of it.
You'll have to dig up Jeppe Nielsons'
BBGUI include code and supply your own
textures and stuff,but it shows how to
setup the GUI and how to do basic commands
from within an editor including how to
produce BB code from the editor. It should
get you started. Hope this helps.

;         HomeSpun - World Designer         *
;         David Inman - May 8,2002           *
;        Doggie at BlitzBasic Forums         *
;                                            *
;       BBGUI courtesy of Jeppe Nielsen      *
;                                            *
;                  2001-2002                 *    
;                                            *
;*********************************************

; Set The Graphic Mode
Graphics3D 800,600,16,2
AppTitle "HomeSpun" 
Include "BBGui_include.bb"
Global font=LoadFont("Times new roman",12)
Global guidesignvar.guidesign=guidesigndefault(0) ; our guidesign
Dim gad.gadget( 71 ) ; A dim to hold our gadgets

win.window=window( 604 , 8 , 195 , 595 , guidesignvar , font , 1 , "THE GOODIES " , 1 , 1 , 0 , 0 , 1 )
win1.window=window( 10 , 505 , 590 , 90 , guidesignvar , font , 1 , "MORE GOODIES " , 1 , 1 , 0 , 0 , 1 )

gad(0)=gadgetbutton( win , 6 , 6 , 80 , 15 , "HeightMap" , 0 , guidesignvar , font  )
gad(1)=gadgetbutton( win , 110 , 6 ,80 , 15 , "Terrain " , 0 , guidesignvar , font  )
gad(2)=gadgetbutton( win , 6 , 125 , 50 , 15 , "Sky" , 0 , guidesignvar , font  )
gad(3)=gadgetbutton( win , 73 , 125 , 50 , 15 , "Ground" , 0 , guidesignvar , font  )
gad(4)=gadgetbutton( win , 140 , 125 , 50 , 15 , "Water" , 0 , guidesignvar , font  )
gad(5)=gadgetbutton( win , 6 , 144 , 162 , 15 , "Create Light" , 0 , guidesignvar , font  )
gad(6)=gadgetbutton( win , 6 , 216 , 182 , 15 , "Load 3D Object" , 0 , guidesignvar , font  )
gad(7)=gadgetbutton( win , 7 , 238 , 75 , 15 , "Cycle Up" , 0 , guidesignvar , font  )
gad(8)=gadgetbutton( win , 112 , 238 , 75 , 15 , "Cycle Down" , 0 , guidesignvar , font  )
gad(9)=gadgetbutton( win , 6 , 264 , 52 , 15 , "Pos(X)" , 0 , guidesignvar , font  )
gad(10)=gadgetbutton( win , 67 , 264 , 52 , 15 , "Pos(Y)" , 0 , guidesignvar , font  )
gad(11)=gadgetbutton( win , 130 , 264 , 52 , 15 , "Pos(Z)" , 0 , guidesignvar , font  )
gad(12)=gadgetbutton( win , 6 , 288 , 52 , 15 , "Rot(X)" , 0 , guidesignvar , font  )
gad(13)=gadgetbutton( win , 67 , 288 , 52 , 15 , "Rot(Y)" , 0 , guidesignvar , font  )
gad(14)=gadgetbutton( win , 130 , 288 , 52 , 15 , "Rot(Z)" , 0 , guidesignvar , font  )
gad(15)=gadgetbutton( win , 6 , 312 , 52 , 15 , "Scale" , 0 , guidesignvar , font  )
gad(16)=gadgetbutton( win , 6 , 25 , 80 , 15 , "T-Scale(U)-UP" , 0 , guidesignvar , font  )
gad(17)=gadgetbutton( win , 110 , 25 , 80 , 15 , "T-Scale(U)-DN" , 0 , guidesignvar , font  )
gad(18)=gadgetbutton( win , 6 , 555 , 182 , 15 , "Produce BB Code" , 0 , guidesignvar , font  )
gad(19)=gadgetbutton( win , 6 , 45 , 80 , 15 , "T-Scale(V)-UP" , 0 , guidesignvar , font  )
gad(20)=gadgetbutton( win , 110 , 45 , 80 , 15 , "T-Scale(V)-DN" , 0 , guidesignvar , font  )
gad(21)=gadgetbutton( win , 10 , 360 , 52 , 15 , "R - Up" , 0 , guidesignvar , font  )
gad(22)=gadgetbutton( win , 71 , 360 , 52 , 15 , "G - Up" , 0 , guidesignvar , font  )
gad(23)=gadgetbutton( win , 134 , 360 , 52 , 15 , "B - Up" , 0 , guidesignvar , font  )
gad(24)=gadgetbutton( win , 10 , 380 , 52 , 15 , "R - Down" , 0 , guidesignvar , font  )
gad(25)=gadgetbutton( win , 71 , 380 , 52 , 15 , "G - Down" , 0 , guidesignvar , font  )
gad(26)=gadgetbutton( win , 134 , 380 , 52 , 15 , "B - Down" , 0 , guidesignvar , font  )
gad(27)=gadgetbutton( win , 7 , 435 , 85 , 15 , "Near In" , 0 , guidesignvar , font  )
gad(28)=gadgetbutton( win , 102 , 435 , 85 , 15 , "Near Out" , 0 , guidesignvar , font  )
gad(29)=gadgetbutton( win , 7 , 455 , 85 , 15 , "Far In" , 0 , guidesignvar , font  )
gad(30)=gadgetbutton( win , 102 , 455 , 85 , 15 , "Far Out" , 0 , guidesignvar , font  )
gad(31)=gadgetbutton( win , 10 , 490 , 52 , 15 , "R - Up" , 0 , guidesignvar , font  )
gad(32)=gadgetbutton( win , 71 , 490 , 52 , 15 , "G - Up" , 0 , guidesignvar , font  )
gad(33)=gadgetbutton( win , 134 , 490 , 52 , 15 , "B - Up" , 0 , guidesignvar , font  )
gad(34)=gadgetbutton( win , 10 , 510 , 52 , 15 , "R - Down" , 0 , guidesignvar , font  )
gad(35)=gadgetbutton( win , 71 , 510 , 52 , 15 , "G - Down" , 0 , guidesignvar , font  )
gad(36)=gadgetbutton( win , 134 , 510 , 52 , 15 , "B - Down" , 0 , guidesignvar , font  )

gad(37)=gadgetbutton( win , 10 , 65 , 52 , 15 , "Texture 2" , 0 , guidesignvar , font  )
gad(38)=gadgetbutton( win , 66 , 65 , 15 , 15 , "Up" , 0 , guidesignvar , font  )
gad(39)=gadgetbutton( win , 106 , 65 , 15 , 15 , "Dn" , 0 , guidesignvar , font  )
gad(40)=gadgetbutton( win , 126 , 65 , 15 , 15 , "Up" , 0 , guidesignvar , font  )
gad(41)=gadgetbutton( win , 166 , 65 , 15 , 15 , "Dn" , 0 , guidesignvar , font  )


gad(42)=gadgetbutton( win , 10 , 85 , 52 , 15 , "Texture 3" , 0 , guidesignvar , font  )
gad(43)=gadgetbutton( win , 66 , 85 , 15 , 15 , "Up" , 0 , guidesignvar , font  )
gad(44)=gadgetbutton( win , 106 , 85 , 15 , 15 , "Dn" , 0 , guidesignvar , font  )
gad(45)=gadgetbutton( win , 126 , 85 , 15 , 15 , "Up" , 0 , guidesignvar , font  )
gad(46)=gadgetbutton( win , 166 , 85 , 15 , 15 , "Dn" , 0 , guidesignvar , font  )

gad(47)=gadgetbutton( win , 10 , 105 , 52 , 15 , "Texture 4" , 0 , guidesignvar , font  )
gad(48)=gadgetbutton( win , 66 , 105 , 15 , 15 , "Up" , 0 , guidesignvar , font  )
gad(49)=gadgetbutton( win , 106 , 105 , 15 , 15 , "Dn" , 0 , guidesignvar , font  )
gad(50)=gadgetbutton( win , 126 , 105 , 15 , 15 , "Up" , 0 , guidesignvar , font  )
gad(51)=gadgetbutton( win , 166 , 105 , 15 , 15 , "Dn" , 0 , guidesignvar , font  )

gad(52)=gadgetbutton( win1 , 430 , 20 , 58 , 15 , "Load Sprite" , 0 , guidesignvar , font  )
gad(53)=gadgetbutton( win1 , 430 , 55 , 20 , 12 , "Up" , 0 , guidesignvar , font  )
gad(54)=gadgetbutton( win1 , 485 , 55 , 20 , 12 , "Dn" , 0 , guidesignvar , font  )
gad(55)=gadgetbutton( win1 , 530 , 20 , 55 , 15 , "Place" , 0 , guidesignvar , font  )

gad(56)=gadgetbutton( win1 , 515 , 40 , 70 , 15 , "Place Random" , 0 , guidesignvar , font  )
gad(57)=gadgetbutton( win1 , 515 , 55 , 20 , 12 , "Up" , 0 , guidesignvar , font  )
gad(58)=gadgetbutton( win1 , 565 , 55 , 20 , 12 , "Dn" , 0 , guidesignvar , font  )
gad(59)=gadgetbutton( win1 , 430 , 40 , 20 , 12 , "Up" , 0 , guidesignvar , font  )
gad(60)=gadgetbutton( win1 , 485 , 40 , 20 , 12 , "Dn" , 0 , guidesignvar , font  )
gad(61)=gadgetbutton( win , 67 , 312 , 52 , 15 , "Obj Tex" , 0 , guidesignvar , font  )

gad(62)=gadgetbutton( win , 130 , 305 , 15 , 12 , "Up" , 0 , guidesignvar , font  )
gad(63)=gadgetbutton( win , 170 , 305 , 15 , 12 , "Dn" , 0 , guidesignvar , font  )
gad(64)=gadgetbutton( win , 130 , 320 , 15 , 12 , "Up" , 0 , guidesignvar , font  )
gad(65)=gadgetbutton( win , 170 , 320 , 15 , 12 , "Dn" , 0 , guidesignvar , font  )

gad(66)=gadgetbutton( win , 6 , 165 , 20 , 12 , "R-up" , 0 , guidesignvar , font  )
gad(67)=gadgetbutton( win , 45 , 165 , 15 , 12 , "Dn" , 0 , guidesignvar , font  )
gad(68)=gadgetbutton( win , 70 , 165 , 20 , 12 , "G-up" , 0 , guidesignvar , font  )
gad(69)=gadgetbutton( win , 110 , 165 , 15 , 12 , "Dn" , 0 , guidesignvar , font  )
gad(70)=gadgetbutton( win , 135 , 165 , 20 , 12 , "B-up" , 0 , guidesignvar , font  )
gad(71)=gadgetbutton( win , 175 , 165 , 15 , 12 , "Dn" , 0 , guidesignvar , font  )


SetBuffer BackBuffer()
Dim job$(300)
Dim obj(300)
Dim hastex(300)
Dim obtx$(300)
Dim obtex1(300)
Dim ox(300)
Dim oy(300)
Dim pox(300)
Dim poy(300)
Dim poz(300)
Dim rox(300)
Dim roy(300)
Dim roz(300)
Dim sox(300)
Dim soy(300)
Dim soz(300)
Dim lox(7)
Dim loy(7)
Dim loz(7)
near=20:far=200
red=200:green=200:blue=200
fred=120:fgreen=120:fblue=120
; Create a camera        
Global camera=CreateCamera()
PositionEntity camera,525,13,1566
CameraViewport camera,10,10,590,490
CameraClsColor camera,0,0,0    
CameraRange camera,1,500
CameraFogMode camera,1
CameraFogRange camera,near,far
CameraFogColor camera,fred,fgreen,fblue
;  initialise 
Global objectNum=0
Global x#=EntityX(camera)
Global y#=EntityY(camera)
Global z#=EntityZ(camera)
Global terrain1
Global hmap$
Global tex$
Global tu
Global tv
Global xtips,nos,ytips
; dimension arrays 
Dim lightBulb(20)
Dim terrainTex(10)
Dim objects(20)
Dim lite(8)
Dim lr(8)
Dim lg(8)
Dim lb(8) 
Dim lhite(8)
Dim sprite(500)
Dim spname$(500)
Dim rspit$(500)
Dim rnos(500)
Dim spox(500)
Dim spoy(500)
Dim spoz(500)
Dim spx(500)
Dim spy(500)
crl=1           
;#### Lights! #######
red=200:green=200:blue=200
AmbientLight red,green,blue
lightBulb(1)=CreateLight (3)
PositionEntity lightBulb(1),680,40,1215
RotateEntity lightBulb(1),89.9999,180.000,180.000
LightRange lightBulb(1),100
LightConeAngles lightBulb(1),0,90
LightColor lightBulb(1),55,255,25
Global lcr,lcg,lcb
;*** setup scene ***
;#### Place Code Here For Requester ######
Flip 
FlushKeys
Cls
Color 100,255,100
FlushKeys
hmap$=windowfilerequest$(GraphicsWidth()/2-200,GraphicsHeight()/2-150,400,300,guidesignvar,font,"Load HeightMap...",".bmp|.jpg|.png",file$)

tex$=windowfilerequest$(GraphicsWidth()/2-200,GraphicsHeight()/2-150,400,300,guidesignvar,font,"Load Ground Texture..",".bmp|.jpg|.png",file$)
Color 100,255,100
setupTerrain()
FlushKeys

backpic=LoadImage("screen3.jpg")
terra_y#=TerrainY(terrain1,x#,y#,z#)
;camotex=LoadTexture("camo.bmp",1)
;Create Water plane
plane=CreatePlane(10)
planeTex=LoadTexture( "water03.bmp")
water$="water03.bmp"
ScaleTexture planeTex,100,100
EntityTexture plane,planeTex
EntityAlpha plane,0.50
PositionEntity plane,0,5,0

;Create Ground Plane 
gplane=CreatePlane(10)
gplaneTex=LoadTexture(tex$)
gtex$=tex$
ScaleTexture gplaneTex,100,100
EntityTexture gplane,gplaneTex

;### Meet Sarge ##
Global player=LoadMD2( "ss.md2" )
ss_tex=LoadTexture( "ss3.pcx" )
EntityTexture player,ss_tex
ScaleEntity player,.09,.09,.09
AnimateMD2 player,1,0.5,0,19
EntityType player,1
EntityRadius player,2
PositionEntity player,508,1,1544
RotateEntity player,0.0000,150,0.00000
;########### Cheap 3rd Person Camera #########
PointEntity camera,player
EntityParent camera,player
Global x1#=EntityX(player)
Global y1#=EntityY(player)
Global z1#=EntityZ(player)
;### SKY WRITING ###
Global sphere=CreateSphere(32)
PositionEntity sphere,x#,y#,z#
skytex=LoadTexture("sky9.bmp",8)
stex$="sky9.bmp"
ScaleEntity sphere,250,250,250
EntityTexture sphere,skytex
EntityAlpha sphere,1
FlipMesh sphere
Global wx#
Global wy#
frametimer=CreateTimer(30)
EntityType player,1
Global gamma
gamma=232
ShowPointer
TextureFilter "",9
nos=1:xtips=5:ytips=5:ox(zap)=50:oy(zap)=50
Collisions 1,2,2,2

;########## Loop Loop Loop Loop Loop Loop #########
;***********************************************
;***********************************************
While Not KeyHit(1)
WaitTimer(frametimer)
DrawImage backpic,0,0
windowinteractall()
gadgetinteractall()
windowdrawall()
mx=MouseX()
my=MouseY()
GameInput()

x1#=EntityX(player)
y1#=EntityY(player)
z1#=EntityZ(player)
;### Read the Mouse ###
If gadgetreleased(gad(0)) 
hmap$=windowfilerequest$(GraphicsWidth()/2-200,GraphicsHeight()/2-150,400,300,guidesignvar,font,"Load HeightMap...",".bmp|.jpg|.png",file$)
FreeEntity terrain1
setupTerrain2()
EndIf

If gadgetreleased(gad(1)) 
tex$=windowfilerequest$(GraphicsWidth()/2-200,GraphicsHeight()/2-150,400,300,guidesignvar,font,"Load Terrain Texture...",".bmp|.jpg|.png",file$)
setupTerrain3()
EndIf

If gadgetreleased(gad(3)) 
gtex$=windowfilerequest$(GraphicsWidth()/2-200,GraphicsHeight()/2-150,400,300,guidesignvar,font,"Load Ground Texture...",".bmp|.jpg|.png",file$)
gplaneTex=LoadTexture(gtex$)
ScaleTexture gplaneTex,100,100
EntityTexture gplane,gplaneTex
EndIf

If gadgetreleased(gad(4)) 
water$=windowfilerequest$(GraphicsWidth()/2-200,GraphicsHeight()/2-150,400,300,guidesignvar,font,"Load Water Texture...",".bmp|.jpg|.png",file$)
planeTex=LoadTexture(water$)
ScaleTexture planeTex,100,100
EntityTexture plane,planeTex
EndIf


If gadgetreleased(gad(2)) 
stex$=windowfilerequest$(GraphicsWidth()/2-200,GraphicsHeight()/2-150,400,300,guidesignvar,font,"Load Sky Texture...",".bmp|.jpg|.png",file$)
skytex=LoadTexture(stex$)
EntityTexture sphere,skytex
EndIf

If KeyHit(2)
bsp$=windowfilerequest$(GraphicsWidth()/2-200,GraphicsHeight()/2-150,400,300,guidesignvar,font,"Load BSP...",".bsp",file$)
bspl=LoadBSP(bsp$) 
PositionEntity bspl,x1#,y1#,z1#
BSPAmbientLight bspl,0,0,0
BSPLighting bspl,1

EndIf


If gadgetreleased(gad(5)) 
crl=crl+1
If crl>8 Then crl=8
lite(crl)=CreateLight(3)
PositionEntity lite(crl),x1#,y1#+100,z1# 
RotateEntity lite(crl),90,180,180
LightRange lite(crl),y1#+100
lhite(crl)=y1#+100
LightConeAngles lite(crl),0,90
LightColor lite(crl),255,255,255
lr(crl)=255
lg(crl)=255
lb(crl)=255
lcr=255
lcg=255
lcb=255
lox(crl)=x1#
loy(crl)=y1#+100
loz(crl)=z1#
EndIf

If gadgetpressed(gad(66)) 
lcr=lcr+1
If lcr>255 Then lcr=255
lr(crl)=lcr
LightColor lite(crl),lr(crl),lg(crl),lb(crl)
EndIf
If gadgetpressed(gad(67)) 
lcr=lcr-1
If lcr<-255 Then lcr=-255
lr(crl)=lcr
LightColor lite(crl),lr(crl),lg(crl),lb(crl)
EndIf

If gadgetpressed(gad(68)) 
lcg=lcg+1
If lcg>255 Then lcg=255
lg(crl)=lcg
LightColor lite(crl),lr(crl),lg(crl),lb(crl)
EndIf
If gadgetpressed(gad(69)) 
lcg=lcg-1
If lcg<-255 Then lcg=-255
lg(crl)=lcg
LightColor lite(crl),lr(crl),lg(crl),lb(crl)
EndIf


If gadgetpressed(gad(70)) 
lcb=lcb+1
If lcb>255 Then lcb=255
lb(crl)=lcb
LightColor lite(crl),lr(crl),lg(crl),lb(crl)
EndIf
If gadgetpressed(gad(71)) 
lcb=lcb-1
If lcb<-255 Then lcb=-255
lb(crl)=lcb
LightColor lite(crl),lr(crl),lg(crl),lb(crl)
EndIf



If gadgetreleased(gad(7)) 
zap=zap+1:If zap>ap Then zap=ap
terra_y1#=TerrainY(terrain1,EntityX(obj(zap)),EntityY(obj(zap)),EntityZ(obj(zap)))
PositionEntity player,EntityX(obj(zap)),terra_y1#,EntityZ(obj(zap))
EndIf
If gadgetreleased(gad(8)) 
zap=zap-1:If zap<1 Then zap=1
terra_y1#=TerrainY(terrain1,EntityX(obj(zap)),EntityY(obj(zap)),EntityZ(obj(zap)))
PositionEntity player,EntityX(obj(zap)),terra_y1#,EntityZ(obj(zap))
EndIf
If gadgetreleased(gad(9)) 
Gosub posx
EndIf
If gadgetreleased(gad(10)) 
Gosub posy
EndIf
If gadgetreleased(gad(11)) 
Gosub posz
EndIf
If gadgetreleased(gad(12)) 
Gosub rotx
EndIf
If gadgetreleased(gad(13)) 
Gosub roty
EndIf
If gadgetreleased(gad(14)) 
Gosub rotz
EndIf
If gadgetreleased(gad(15)) 
Gosub scalex
EndIf

If gadgetpressed(gad(16)) 
tu=tu+1
ScaleTexture terrainTex(1),tu,tv
TextureBlend terrainTex(1),1
EntityTexture Terrain1,terrainTex(1),0,1
EndIf

If gadgetpressed(gad(17)) 
tu=tu-1
ScaleTexture terrainTex(1),tu,tv
TextureBlend terrainTex(1),1
EntityTexture Terrain1,terrainTex(1),0,1
EndIf
If gadgetpressed(gad(19)) 
tv=tv+1
ScaleTexture terrainTex(1),tu,tv
TextureBlend terrainTex(1),1
EntityTexture Terrain1,terrainTex(1),0,1
EndIf

If gadgetpressed(gad(20)) 
tv=tv-1
ScaleTexture terrainTex(1),tu,tv
TextureBlend terrainTex(1),1
EntityTexture Terrain1,terrainTex(1),0,1
EndIf
If gadgetpressed(gad(21)) 
red=red+1
If red>255 Then red=255
AmbientLight red,green,blue
EndIf
If gadgetpressed(gad(22)) 
green=green+1
If green>255 Then green=255
AmbientLight red,green,blue
EndIf
If gadgetpressed(gad(23)) 
blue=blue+1
If blue>255 Then blue=255
AmbientLight red,green,blue
EndIf
If gadgetpressed(gad(24)) 
red=red-1
If red<0 Then red=0
AmbientLight red,green,blue
EndIf
If gadgetpressed(gad(25)) 
green=green-1
If green<0 Then green=0
AmbientLight red,green,blue
EndIf
If gadgetpressed(gad(26)) 
blue=blue-1
If blue<0 Then blue=0
AmbientLight red,green,blue
EndIf
If gadgetpressed(gad(31)) 
fred=fred+1
If fred>255 Then fred=255
CameraFogColor camera,fred,fgreen,fblue
EndIf
If gadgetpressed(gad(32)) 
fgreen=fgreen+1
If fgreen>255 Then fgreen=255
CameraFogColor camera,fred,fgreen,fblue
EndIf
If gadgetpressed(gad(33)) 
fblue=fblue+1
If fblue>255 Then fblue=255
CameraFogColor camera,fred,fgreen,fblue
EndIf
If gadgetpressed(gad(34)) 
fred=fred-1
If fred<0 Then fred=0
CameraFogColor camera,fred,fgreen,fblue
EndIf
If gadgetpressed(gad(35)) 
fgreen=fgreen-1
If fgreen<0 Then fgreen=0
CameraFogColor camera,fred,fgreen,fblue
EndIf
If gadgetpressed(gad(36)) 
fblue=fblue-1
If fblue<0 Then fblue=0
CameraFogColor camera,fred,fgreen,fblue
EndIf




;CameraFogColor camera,red+50,green+50,blue+50

If gadgetpressed(gad(27)) 
near=near-1
If near<10 Then near=10
CameraFogRange camera,near,far
EndIf
If gadgetpressed(gad(28)) 
near=near+1
If near>3000 Then near=3000
CameraFogRange camera,near,far
EndIf


If gadgetpressed(gad(29)) 
far=far-1
If far<30 Then far=30
CameraFogRange camera,near,far
EndIf
If gadgetpressed(gad(30)) 
far=far+1
If far>5000 Then far=5000
CameraFogRange camera,near,far
EndIf

If gadgetreleased(gad(37)) 
tmap2$=windowfilerequest$(GraphicsWidth()/2-200,GraphicsHeight()/2-150,400,300,guidesignvar,font,"Load Texture 2",".bmp|.jpg|.png",file$)
tex2=LoadTexture( tmap2$,3 )
ScaleTexture tex2,50,50
tsx2=50:tsy2=50
TextureBlend tex2,1
EntityTexture Terrain1,tex2,0,2
t2=1
EndIf
If gadgetpressed(gad(38)) 
tsx2=tsx2+1
ScaleTexture tex2,tsx2,tsy2
EndIf
If gadgetpressed(gad(39)) 
tsx2=tsx2-1
If tsx2<1 Then tsx2=1
ScaleTexture tex2,tsx2,tsy2
EndIf
If gadgetpressed(gad(40)) 
tsy2=tsy2+1
ScaleTexture tex2,tsx2,tsy2
EndIf
If gadgetpressed(gad(41)) 
tsy2=tsy2-1
If tsy2<1 Then tsy2=1
ScaleTexture tex2,tsx2,tsy2
EndIf



If gadgetreleased(gad(42)) 
tmap3$=windowfilerequest$(GraphicsWidth()/2-200,GraphicsHeight()/2-150,400,300,guidesignvar,font,"Load Texture 3",".bmp|.jpg|.png",file$)
tex3=LoadTexture( tmap3$,3 )
ScaleTexture tex3,50,50
tsx3=50:tsy3=50
TextureBlend tex3,1
EntityTexture Terrain1,tex3,0,3
t3=1
EndIf
If gadgetpressed(gad(43)) 
tsx3=tsx3+1
ScaleTexture tex3,tsx3,tsy3
EndIf
If gadgetpressed(gad(44)) 
tsx3=tsx3-1
If tsx3<1 Then tsx3=1
ScaleTexture tex3,tsx3,tsy3
EndIf
If gadgetpressed(gad(45)) 
tsy3=tsy3+1
ScaleTexture tex3,tsx3,tsy3
EndIf
If gadgetpressed(gad(46)) 
tsy3=tsy3-1
If tsy3<1 Then tsy3=1
ScaleTexture tex3,tsx3,tsy3
EndIf


If gadgetreleased(gad(47)) 
tmap4$=windowfilerequest$(GraphicsWidth()/2-200,GraphicsHeight()/2-150,400,300,guidesignvar,font,"Load Texture 3",".bmp|.jpg|.png",file$)
tex4=LoadTexture( tmap4$,3 )
ScaleTexture tex4,50,50
tsx4=50:tsy4=50
TextureBlend tex4,1
EntityTexture Terrain1,tex4,0,4
t4=1
EndIf
If gadgetpressed(gad(48)) 
tsx4=tsx4+1
ScaleTexture tex4,tsx4,tsy4
EndIf
If gadgetpressed(gad(49)) 
tsx4=tsx4-1
If tsx4<1 Then tsx4=1
ScaleTexture tex4,tsx4,tsy4
EndIf
If gadgetpressed(gad(50)) 
tsy4=tsy4+1
ScaleTexture tex4,tsx4,tsy4
EndIf
If gadgetpressed(gad(51)) 
tsy4=tsy4-1
If tsy4<1 Then tsy4=1
ScaleTexture tex4,tsx4,tsy4
EndIf


If gadgetreleased(gad(52)) 
spit$=windowfilerequest$(GraphicsWidth()/2-200,GraphicsHeight()/2-150,400,300,guidesignvar,font,"Load Sprite",".bmp|.jpg|.png",file$)
spitpic=LoadImage(spit$)
sput=1:tips=1
ResizeImage spitpic,25,25

spriter=LoadSprite( spit$,7 )
	HandleSprite spriter,0,-1
	ScaleSprite spriter,4,8
	SpriteViewMode spriter,3
EndIf

If gadgetpressed(gad(53)) And spud>0
ytips=ytips+1
ScaleSprite sprite(spud),xtips,ytips
spx(spud)=xtips
spy(spud)=ytips
EndIf
If gadgetpressed(gad(54)) And spud>0
ytips=ytips-1
If ytips<1 Then ytips=1
ScaleSprite sprite(spud),xtips,ytips
spx(spud)=xtips
spy(spud)=ytips
EndIf

If gadgetpressed(gad(59)) And spud>0
xtips=xtips+1
ScaleSprite sprite(spud),xtips,ytips
spx(spud)=xtips
spy(spud)=ytips
EndIf
If gadgetpressed(gad(60)) And spud>0
xtips=xtips-1
If xtips<1 Then xtips=1
ScaleSprite sprite(spud),xtips,ytips
spx(spud)=xtips
spy(spud)=ytips
EndIf


If gadgetreleased(gad(55)) And sput>0
spud=spud+1
sprite(spud)=CopyEntity(spriter)
spname$(spud)=spit$
spty#=TerrainY(terrain1,EntityX(player),0,EntityZ(player))
PositionEntity sprite(spud),EntityX(player),spty#,EntityZ(player)
spox(spud)=EntityX(player)
spoy(spud)=spty#
spoz(spud)=EntityZ(player)
EndIf
If gadgetpressed(gad(57)) 
nos=nos+1
EndIf
If gadgetpressed(gad(58)) 
nos=nos-1
If nos<1 Then nos=1
EndIf

If gadgetreleased(gad(56)) And sput>0
rspt=rspt+1
rspit$(rspt)=spit$
rnos(rspt)=nos
For k=1 To nos
		Repeat
			tx#=Rnd(-70,1700)
			tz#=Rnd(-70,1700)
			ty#=TerrainY(terrain1,tx,0,tz )
		Until ty>-100
		t=CopyEntity( spriter )
	If ty#>10 Then	PositionEntity t,tx,ty,tz
		ScaleSprite t,Rand(2,7),Rand(4,16)
	Next
EndIf

If gadgetreleased(gad(61)) 
otex$=windowfilerequest$(GraphicsWidth()/2-200,GraphicsHeight()/2-150,400,300,guidesignvar,font,"Load Object Texture...",".bmp|.jpg|.png",file$)
obtex=LoadTexture(otex$)
ox(zap)=50:oy(zap)=50
ScaleTexture obtex,ox(zap),oy(zap)
EntityTexture obj(zap),obtex
hastex(zap)=1
obtx$(zap)=otex$
EndIf


If gadgetpressed(gad(62)) 
If hastex(zap)>0
ox(zap)=ox(zap)+1
ScaleTexture obtex,ox(zap),oy(zap)
EndIf
EndIf

If gadgetpressed(gad(63)) 
If hastex(zap)>0
ox(zap)=ox(zap)-1
If ox(zap)<1 Then ox(zap)=1
ScaleTexture obtex,ox(zap),oy(zap)
EndIf
EndIf

If gadgetpressed(gad(64)) 
If hastex(zap)>0
oy(zap)=oy(zap)+1
ScaleTexture obtex,ox(zap),oy(zap)
EndIf
EndIf

If gadgetpressed(gad(65)) 
If hastex(zap)>0
oy(zap)=oy(zap)-1
If oy(zap)<1 Then oy(zap)=1
ScaleTexture obtex,ox(zap),oy(zap)
EndIf
EndIf





If sput=1 Then DrawImage spitpic,507,530
If gadgetreleased(gad(18)) 
level$=windowfilerequest$(GraphicsWidth()/2-200,GraphicsHeight()/2-150,400,300,guidesignvar,font,"Save Program AS...",".bb",file$)
fileout=WriteFile(level$)
;##### Write Out Stub ######
WriteLine(fileout,";     # Created By HomeSpun #")
WriteLine(fileout,";# Courtesy of Doggie at BB Forums #")
WriteLine(fileout,"Graphics3D 800,600,16,1")
WriteLine(fileout,"SetBuffer BackBuffer()")
WriteLine(fileout,"Global camera=CreateCamera()")
WriteLine(fileout,"PositionEntity camera,525,13,1566")
WriteLine(fileout,"CameraViewport camera,0,0,GraphicsWidth(),GraphicsHeight()")
WriteLine(fileout,"CameraClsColor camera,0,0,0")
WriteLine(fileout,"CameraRange camera,1,500")
WriteLine(fileout,"CameraFogMode camera,1")
WriteLine(fileout,"CameraFogRange camera,"+near+","+far)
WriteLine(fileout,"CameraFogColor camera, "+(fred)+","+(fgreen)+","+(fblue))
WriteLine(fileout,"AmbientLight "+red+","+green+","+blue)
WriteLine(fileout,"terrain1=LoadTerrain( "+Chr$(34)+hmap$+Chr$(34)+")")
WriteLine(fileout,"PositionEntity terrain1,-128,-0.5,-128")
WriteLine(fileout,"TerrainDetail terrain1,500,True")
WriteLine(fileout,"ScaleEntity terrain1,6,40,6")
WriteLine(fileout,"terrainTex=LoadTexture( "+Chr$(34)+tex$+Chr$(34)+",8)")
WriteLine(fileout,"ScaleTexture terrainTex,"+tu+","+tv)
WriteLine(fileout,"TextureBlend terrainTex,1")
WriteLine(fileout,"EntityTexture terrain1,terrainTex,0,1")
If t2=1
WriteLine(fileout,"tex2=LoadTexture( "+Chr$(34)+tmap2$+Chr$(34)+",3)")
WriteLine(fileout,"ScaleTexture tex2,"+tsx2+","+tsy2)
WriteLine(fileout,"TextureBlend tex2,1")
WriteLine(fileout,"EntityTexture terrain1,tex2,0,2")
EndIf
If t3=1
WriteLine(fileout,"tex3=LoadTexture( "+Chr$(34)+tmap3$+Chr$(34)+",3)")
WriteLine(fileout,"ScaleTexture tex3,"+tsx3+","+tsy3)
WriteLine(fileout,"TextureBlend tex3,1")
WriteLine(fileout,"EntityTexture terrain1,tex3,0,3")
EndIf
If t4=1
WriteLine(fileout,"tex4=LoadTexture( "+Chr$(34)+tmap4$+Chr$(34)+",3)")
WriteLine(fileout,"ScaleTexture tex4,"+tsx4+","+tsy4)
WriteLine(fileout,"TextureBlend tex4,1")
WriteLine(fileout,"EntityTexture terrain1,tex4,0,4")
EndIf
WriteLine(fileout,"plane=CreatePlane(10)")
WriteLine(fileout,"planeTex=LoadTexture("+Chr$(34)+water$+Chr$(34)+")")
WriteLine(fileout,"ScaleTexture planeTex,100,100")
WriteLine(fileout,"EntityTexture plane,planeTex")
WriteLine(fileout,"EntityAlpha plane,0.50")
WriteLine(fileout,"PositionEntity plane,0,5,0")
WriteLine(fileout,"FreeImage planetex")
WriteLine(fileout,"gplane=CreatePlane(10)")
WriteLine(fileout,"gplaneTex=LoadTexture("+Chr$(34)+gtex$+Chr$(34)+")")
WriteLine(fileout,"ScaleTexture gplaneTex,100,100")
WriteLine(fileout,"EntityTexture gplane,gplaneTex")
WriteLine(fileout,"Global player=LoadMD2( "+Chr$(34)+"ss.md2"+Chr$(34)+")")
WriteLine(fileout,"ss_tex=LoadTexture( "+Chr$(34)+"ss3.pcx"+Chr$(34)+")")
WriteLine(fileout,"EntityTexture player,ss_tex")
WriteLine(fileout,"ScaleEntity player,.09,.09,.09")
WriteLine(fileout,"AnimateMD2 player,1,0.5,0,19")
WriteLine(fileout,"PositionEntity player,508,1,1544")
WriteLine(fileout,"RotateEntity player,0,150,0")

WriteLine(fileout,"EntityRadius player,2")
WriteLine(fileout,"EntityType player,1")

WriteLine(fileout,"PointEntity camera,player")
WriteLine(fileout,"EntityParent camera,player")
WriteLine(fileout,"Global sphere=CreateSphere(32)")
WriteLine(fileout,"EntityParent camera,player")
WriteLine(fileout,"PositionEntity sphere,508,1,1544")
WriteLine(fileout,"light1=CreateLight (3)")
WriteLine(fileout,"PositionEntity light1,508,50,1544")
WriteLine(fileout,"RotateEntity light1,90,180,180")
WriteLine(fileout,"LightRange light1,100")
WriteLine(fileout,"LightConeAngles light1,0,90")
WriteLine(fileout,"LightColor light1,55,255,25")
WriteLine(fileout,"skytex=LoadTexture("+Chr$(34)+stex$+Chr$(34)+",8 )")
WriteLine(fileout,"ScaleEntity sphere,250,250,250")
WriteLine(fileout,"EntityTexture sphere,skytex")
WriteLine(fileout,"EntityAlpha sphere,1")
WriteLine(fileout,"FlipMesh sphere")
For zit=1 To ap
WriteLine(fileout,"obj"+zit+"=LoadMesh("+Chr$(34)+job$(zit)+Chr$(34)+")")
WriteLine(fileout,"PositionEntity obj"+zit+","+pox(zit)+","+poy(zit)+","+poz(zit))
WriteLine(fileout,"ScaleEntity obj"+zit+","+sox(zit)+","+soy(zit)+","+soz(zit))
WriteLine(fileout,"RotateEntity obj"+zit+","+rox(zit)+","+roy(zit)+","+roz(zit))
WriteLine(fileout,"EntityType obj"+zit+","+2)
WriteLine(fileout,"EntityRadius obj"+zit+",2")
If hastex(zit)>0
WriteLine(fileout,"obtex1"+zit+"=LoadTexture("+Chr$(34)+obtx$(zit)+Chr$(34)+")")
WriteLine(fileout,"EntityTexture obj"+zit+",obtex1"+zit)
WriteLine(fileout,"ScaleTexture obtex1"+zit+","+ox(zit)+","+oy(zit))
EndIf
Next


For zit=1 To spud
WriteLine(fileout,"sprite"+zit+"=LoadSprite("+Chr$(34)+spname$(zit)+Chr$(34)+",7 )")
WriteLine(fileout,"HandleSprite sprite"+zit+",0,-1")
WriteLine(fileout,"ScaleSprite sprite"+zit+","+spx(zit)+","+spy(zit))
WriteLine(fileout,"SpriteViewMode sprite"+zit+",3")
WriteLine(fileout,"PositionEntity sprite"+zit+","+spox(zit)+","+spoy(zit)+","+spoz(zit))
Next

For zit=1 To rspt
WriteLine(fileout,"spritz=LoadSprite("+Chr$(34)+rspit$(zit)+Chr$(34)+",7)")
WriteLine(fileout,"HandleSprite spritz,0,-1")
WriteLine(fileout,"SpriteViewMode spritz,3")
WriteLine(fileout,"For k=1 To "+rnos(zit))
WriteLine(fileout,"Repeat")
WriteLine(fileout,"tx#=Rnd(-70,1700)")
WriteLine(fileout,"tz#=Rnd(-70,1700)")
WriteLine(fileout,"ty#=TerrainY(terrain1,tx,0,tz )")
WriteLine(fileout,"Until ty>-100")
WriteLine(fileout,"t=CopyEntity(spritz)")
WriteLine(fileout,"If ty#>10 Then	PositionEntity t,tx,ty,tz")
WriteLine(fileout,"ScaleSprite t,Rand(2,7),Rand(4,16)")
WriteLine(fileout,"Next")
Next
For zit=2 To crl
WriteLine(fileout,"lite"+zit+"=CreateLight(3)")
WriteLine(fileout,"PositionEntity lite"+zit+","+lox(zit)+","+loy(zit)+","+loz(zit))
WriteLine(fileout,"RotateEntity lite"+zit+",90,180,180")
WriteLine(fileout,"LightRange lite"+zit+","+lhite(zit))
WriteLine(fileout,"LightConeAngles lite"+zit+",0,90")
WriteLine(fileout,"LightColor lite"+zit+","+lr(zit)+","+lg(zit)+","+lb(zit))
Next
WriteLine(fileout,"Collisions 1,2,2,2")

WriteLine(fileout,";############ Main Loop ############")
WriteLine(fileout,"While Not KeyHit(1)")
WriteLine(fileout,"If KeyDown(200) Then")
WriteLine(fileout,"MoveEntity player,0,0,2 ")
WriteLine(fileout,"EndIf")
WriteLine(fileout,"If KeyDown(208) Then")
WriteLine(fileout,"MoveEntity player,0,0,-2 ")
WriteLine(fileout,"EndIf")
WriteLine(fileout,"If KeyDown(203) Then")
WriteLine(fileout,"TurnEntity player ,0,2,0 ")
WriteLine(fileout,"EndIf")
WriteLine(fileout,"If KeyDown(205) Then")
WriteLine(fileout,"TurnEntity player ,0,-2,0 ")
WriteLine(fileout,"EndIf")
WriteLine(fileout,"x#=EntityX(camera)")
WriteLine(fileout,"y#=EntityY(camera)")
WriteLine(fileout,"z#=EntityZ(camera)")
WriteLine(fileout,"x1#=EntityX(player)")
WriteLine(fileout,"y1#=EntityY(player)")
WriteLine(fileout,"z1#=EntityZ(player)")
WriteLine(fileout,"terra_y#=TerrainY(terrain1,x#,y#,z#)+5")
WriteLine(fileout,"PositionEntity camera,x#,terra_y#+135,z#")
WriteLine(fileout,"terra_y1#=TerrainY(terrain1,x1#,y1#,z1#)")
WriteLine(fileout,"PositionEntity player,x1#,terra_y1#+4,z1#")	
WriteLine(fileout,"PositionEntity sphere,x1#,y1#,z1#")
WriteLine(fileout,"PositionEntity light1,x1#,y1#+50,z1#")
WriteLine(fileout,"wx#=(wx#+.001)Mod 1")
WriteLine(fileout,"wy#=(wy#+.001)Mod 1")
WriteLine(fileout,"sx#=(sx#+.0001)Mod 1")
WriteLine(fileout,"sy#=(sy#+.0001)Mod 1")
WriteLine(fileout,"PositionTexture planeTex,wx#,wy#")
WriteLine(fileout,"PositionTexture skytex,sx#,0")
WriteLine(fileout,"If Not KeyDown(200) Or KeyDown(208)")
WriteLine(fileout,"AnimateMD2 player,1,0.5,20,25 :UpdateWorld")
WriteLine(fileout,"EndIf")
WriteLine(fileout,"UpdateWorld")
WriteLine(fileout,"RenderWorld")
WriteLine(fileout,"Flip")
WriteLine(fileout,"Wend")
EndIf

;### POSITION OBJECTS###

If gadgetreleased(gad(6)) 
objec$=windowfilerequest$(GraphicsWidth()/2-200,GraphicsHeight()/2-150,400,300,guidesignvar,font,"Load 3D Object...",".3ds",file$)

ap=ap+1
zap=ap
FlushKeys
Color 100,255,100
obj(ap)=LoadMesh(objec$)
EntityType obj(ap),2
EntityRadius obj(ap),2
job$(ap)=objec$
PositionEntity obj(ap),x1#,y1#-5,z1#
pox(ap)=x1#
poy(ap)=y1#-5
poz(ap)=z1#
EndIf 
If KeyDown(27)
gamma=gamma+1:If gamma>255 Then gamma=255
AmbientLight gamma,gamma,gamma
EndIf
If KeyDown(26)
gamma=gamma-1:If gamma<0 Then gamma=0
AmbientLight gamma,gamma,gamma
EndIf
If Not KeyDown(200) Or KeyDown(208)
AnimateMD2 player,1,0.5,20,25 :UpdateWorld
EndIf
;### Cheap Sunshine ###
PositionEntity lightbulb(1),x1#,y1#+15,z1#
PointEntity lightbulb(1),player
;##### Move Sky With Player
PositionEntity sphere,x1#,y1#,z1#   
wx#=(wx#+.001)Mod 1
wy#=(wy#+.001)Mod 1
sx#=(sx#+.0001)Mod 1
sy#=(sy#+.0001)Mod 1
x1=EntityX(player)
y1=EntityY(player)
z1=EntityZ(player)
PositionTexture planeTex,wx#,wy#
PositionTexture skytex,sx#,0
UpdateWorld
RenderWorld

Text 25,35,"X-Pos= " +Int(x1) +" Y-Pos= " +Int(y1) +" Z-Pos= " +Int(z1)
Color 0,0,0
Text 690,266,zap
Text 695,51,tu
Text 695,72,tv
Text 779,171,crl
Text 633,190,lcr
Text 696,190,lcg
Text 761,190,lcb
Text 675,370,"Ambient Light"
Text 640,425,red
Text 700,425,green
Text 760,425,blue
Text 670,445,"Camera Fog Range"
Text 650,445,near
Text 750,445,far
Text 25,20,MouseX()
Text 55,20,MouseY()
Text 685,498,"Fog Color"
Text 640,550,fred
Text 700,550,fgreen
Text 760,550,fblue
Text 463,557,"X= "+xtips
Text 463,577,"Y= "+ytips
Text 552,577,nos
Text 688,90,tsx2
Text 750,90,tsy2

Text 688,110,tsx3
Text 750,110,tsy3

Text 688,130,tsx4
Text 750,130,tsy4
Text 752,332,ox(zap)
Text 752,342,oy(zap)
Rect 502,528,35,29,0
Color 255,255,255
Flip
Wend
End

;***********************************************************************
;***********************************************************************
;***********************************************************************
.posx
px#=EntityX(obj(zap))
While Not KeyHit(28)
If KeyDown(200)
px#=px#+1
PositionEntity obj(zap),px#,EntityY(obj(zap)),EntityZ(obj(zap))
pox(zap)=px#
EndIf
If KeyDown(208)
px#=px#-1
PositionEntity obj(zap),px#,EntityY(obj(zap)),EntityZ(obj(zap))
pox(zap)=px#
EndIf
UpdateWorld
RenderWorld
Flip
Wend
Return
.posy
py#=EntityY(obj(zap))
While Not KeyHit(28)
If KeyDown(200)
py#=py#+1
PositionEntity obj(zap),EntityX(obj(zap)),py#,EntityZ(obj(zap))
poy(zap)=py#
EndIf
If KeyDown(208)
py#=py#-1
PositionEntity obj(zap),EntityX(obj(zap)),py#,EntityZ(obj(zap))
poy(zap)=py#
EndIf
UpdateWorld
RenderWorld
Flip
Wend
Return
.posz
pz#=EntityZ(obj(zap))
While Not KeyHit(28)
If KeyDown(200)
pz#=pz#+1
PositionEntity obj(zap),EntityX(obj(zap)),EntityY(obj(zap)),pz#
poz(zap)=pz#
EndIf
If KeyDown(208)
pz#=pz#-1
PositionEntity obj(zap),EntityX(obj(zap)),EntityY(obj(zap)),pz#
poz(zap)=pz#
EndIf
UpdateWorld
RenderWorld
Flip
Wend
Return
.rotx
While Not KeyHit(28)
If KeyDown(200)
rx#=rx#+1
RotateEntity obj(zap),rx#,0,0
rox(zap)=rx#
EndIf
If KeyDown(208)
rx#=rx#-1
RotateEntity obj(zap),rx#,0,0
rox(zap)=rx#
EndIf
UpdateWorld
RenderWorld
Flip
Wend
Return
.roty
While Not KeyHit(28)
If KeyDown(200)
ry#=ry#+1
RotateEntity obj(zap),0,ry#,0
roy(zap)=ry#
EndIf
If KeyDown(208)
ry#=ry#-1
RotateEntity obj(zap),0,ry#,0
roy(zap)=ry#
EndIf
UpdateWorld
RenderWorld
Flip
Wend
Return
.rotz
While Not KeyHit(28)
If KeyDown(200)
rz#=rz#+1
RotateEntity obj(zap),0,0,rz#
roz(zap)=rz#
EndIf
If KeyDown(208)
rz#=rz#-1
RotateEntity obj(zap),0,0,rz#
roz(zap)=rz#
EndIf
UpdateWorld
RenderWorld
Flip
Wend
Return
.scalex
While Not KeyHit(28)
If KeyDown(200)
sx#=sx#+.1
ScaleEntity obj(zap),sx#,sx#,sx#
sox(zap)=sx#
soy(zap)=sx#
soz(zap)=sx#
EndIf
If KeyDown(208)
sx#=sx#-.1
ScaleEntity obj(zap),sx#,sx#,sx#
sox(zap)=sx#
soy(zap)=sx#
soz(zap)=sx#
EndIf
UpdateWorld
RenderWorld
Flip
Wend
Return
.scaley
While Not KeyHit(28)
If KeyDown(200)
sy#=sy#+1
ScaleEntity obj(ap),0,sy#,0
soy(ap)=sy#
EndIf
If KeyDown(208)
sy#=sy#-1
ScaleEntity obj(ap),0,sy#,0
soy(ap)=sy#
EndIf
UpdateWorld
RenderWorld
Flip
Wend
Return

.scalez
While Not KeyHit(28)
If KeyDown(200)
sz#=sz#+1
ScaleEntity obj(ap),0,0,sz#
soz(ap)=sz#
EndIf
If KeyDown(208)
sz#=sz#-1
ScaleEntity obj(ap),0,0,sz#
soz(ap)=sz#
EndIf
UpdateWorld
RenderWorld
Flip
Wend
Return







Function GameInput()

	If KeyDown(200) Then
		MoveEntity player,0,0,2 ;up
		EndIf

	If KeyDown(208) Then
		MoveEntity player,0,0,-2 ;down
	    EndIf
	
	If KeyDown(203) Then
	camyaw#=2
		TurnEntity player ,0,camyaw#,0 ;left
	EndIf
	If KeyDown(205) Then
	camyaw#=-2
		TurnEntity player ,0,camyaw#,0 ;right
	EndIf
	x#=EntityX(camera)
    y#=EntityY(camera)
    z#=EntityZ(camera)
    x1#=EntityX(player)
    y1#=EntityY(player)
    z1#=EntityZ(player)
 
    terra_y#=TerrainY(terrain1,x#,y#,z#)+5
    PositionEntity camera,x#,terra_y#+135,z#
    terra_y1#=TerrainY(terrain1,x1#,y1#,z1#)
   
PositionEntity player,x1#,terra_y1#+4,z1#
   
End Function

Function setupTerrain()
terrain1=LoadTerrain( hmap$ )
RotateEntity terrain1,0,0,0
PositionEntity terrain1,-128,-0.5,-128
TerrainDetail terrain1,1500,True
ScaleEntity terrain1,6,40,6
TerrainShading Terrain1,1
terrainTex(1)=LoadTexture( tex$,8 )
ScaleTexture terrainTex(1),44,44
EntityTexture terrain1,terrainTex(1),0,1
tu=44:tv=44
Return
End Function
Function setupTerrain2()
terrain1=LoadTerrain( hmap$ )
RotateEntity terrain1,0,0,0
PositionEntity terrain1,-128,-0.5,-128
TerrainDetail terrain1,1500,True
TerrainShading Terrain1,1
ScaleEntity terrain1,6,40,6
ScaleTexture terrainTex(1),44,44
EntityTexture terrain1,terrainTex(1),0,1
Return
End Function
Function setupTerrain3()
terrainTex(1)=LoadTexture(tex$,9 )
ScaleTexture terrainTex(1),44,44
EntityTexture terrain1,terrainTex(1),0,1
Return
End Function


Function CenterMesh (entity) 
    FitMesh entity, -(MeshWidth (entity) / 2), -(MeshHeight (entity) / 2), -(MeshDepth (entity) / 2), MeshWidth (entity), MeshHeight (entity), MeshDepth (entity) 
End Function 


Doggie


elseano(Posted 2003) [#5]
Thanks, everyone.