Yay. I coded this without help, with the exception of the 3d mouse and I think it turned out very well. I just wanted some comments on my code and what to add next. Also I need to turn all the functions concerning creating foliage into one function.
Rem Project: MapEditor
Rem Created: Thursday, April 08, 2010
Rem ***** Main Source File *****
Sync On
Sync Rate 80
Autocam Off
LM start
set ambient light 50
`************GLOBAL VARIABLES*********
Global gbvar1 as integer
Global gbvar2 as integer
Global gbvar3 as integer
Global camx# as float
Global camz# as float
Global tree as integer
Global collision as integer
Global tree2 as integer
Global tree3 as integer
Global rock1 as integer
Global rock2 as integer
Global g1 as integer
Global g2 as integer
Global g3 as integer
Global flower1 as integer
Global flower2 as integer
Global flower3 as integer
Global fern1 as integer
Global fern2 as integer
Global fern3 as integer
Global mush1 as integer
Global mush2 as integer
Global t1s as integer
Global t2s as integer
Global t3s as integer
Global r1s as integer
Global r2s as integer
Global g1s as integer
Global g2s as integer
Global f1s as integer
Global f2s as integer
Global f3s as integer
Global fe1s as integer
Global fe2s as integer
Global fe3s as integer
Global m1s as integer
Global m2s as integer
Global omx# as float
Global omy# as float
t1s = 0
collision = 50000
tree = 500
tree2 = 1501
tree3 = 2501
rock1 = 3501
rock2 = 4501
g1 = 5501
g2 = 6501
flower1 = 7501
flower2 = 8501
flower3 = 9501
fern1 = 10501
fern2 = 11501
fern3 = 12501
mush1 = 13501
mush2 = 14501
camx# = 500
camz# = 300
pitch camera down 60
`************LOAD MEDIA***************
`GUI
Load Image "GUI1.png",17
Sprite 1,818,0,17
`World
Make Object Plain 1,1000,1000
Xrotate object 1,90
Position Object 1,500,0,500
scale object texture 1,3,3
`WorldTextures
Load Image "grass1.jpg",1
Load Image "grass2.bmp",2
Load Image "sand1.bmp",3
Load Image "stone1.bmp",4
`Trees
Load Object "tree1.dbo",tree
Load Object "tree2.dbo",tree2
Load Object "tree3.dbo",tree3
Load Object "rock1.dbo",rock1
Load Object "rock2.dbo",rock2
Load Object "grasssmall.dbo",g1
Load Object "grassmed.dbo",g2
Load Object "mushroom1.dbo",mush1
Load Object "mushroom2.dbo",mush2
Load Object "flower1.dbo",flower1
Load Object "flower2.dbo",flower2
Load Object "flower3.dbo",flower3
Load Object "fern1.dbo",fern1
Load Object "fern2.dbo",fern2
Load Object "fern3.dbo",fern3
`***********MAIN LOOP*****************
Do
movecam()
gui()
`spawnobjects()
floortexture()
if gbvar2 <> 0
spawnobjectss(gbvar1,gbvar2,gbvar3)
endif
Sync
Loop
end
Function movecam()
if upkey() = 1
inc camz#,5
endif
if downkey() = 1
dec camz#,5
endif
if leftkey() = 1
dec camx#,5
endif
if rightkey() = 1
inc camx#,5
endif
position camera camx#,300,camz#
Endfunction
Function gui()
mx# = mousex()
my# = mousey()
mc# = mouseclick()
`********TREE BUTTONS*********************************
if mc# = 1 and mx# > 835 and my# > 48 and mx# < 932 and my# < 64
mx# = omx#
my# = omy#
gosub tree1
spawnobjectss(t1s,tree,1500)
endif
if mc# = 1 and mx# > 835 and my# > 72 and mx# < 932 and my# < 90
gosub tree2
spawnobjectss(t2s,tree2,2500)
endif
if mc# = 1 and mx# > 835 and my# > 94 and mx# < 932 and my# < 112
gosub tree3
spawnobjectss(t3s,tree3,3500)
endif
`********ROCK BUTTONS************************************
if mc# = 1 and mx# > 835 and my# > 166 and mx# < 932 and my# < 186
gosub rock1
spawnobjectss(r1s,rock1,4500)
endif
if mc# = 1 and mx# > 835 and my# > 190 and mx# < 932 and my# < 211
gosub rock2
spawnobjectss(r2s,rock2,5500)
endif
`*******GRASS BUTTONS*************************************
if mc# = 1 and mx# > 835 and my# > 263 and mx# < 932 and my# < 282
`gosub grass1
endif
if mc# = 1 and mx# > 835 and my# > 287 and mx# < 932 and my# < 305
`gosub grass2
endif
if mc# = 1 and mx# > 835 and my# > 309 and mx# < 932 and my# < 330
`gosub grass3
endif
`*******FLOWER BUTTONS*************************************
if mc# = 1 and mx# > 835 and my# > 382 and mx# < 932 and my# < 404
gosub flower1
spawnobjectss(f1s,flower1,8500)
endif
if mc# = 1 and mx# > 835 and my# > 408 and mx# < 932 and my# < 427
gosub flower2
spawnobjectss(f2s,flower2,9500)
endif
if mc# = 1 and mx# > 835 and my# > 431 and mx# < 932 and my# < 449
`gosub flower3
endif
`********FERN BUTTONS************************************
if mc# = 1 and mx# > 835 and my# > 501 and mx# < 932 and my# < 521
`gosub fern1
endif
if mc# = 1 and mx# > 835 and my# > 524 and mx# < 932 and my# < 545
`gosub fern2
endif
if mc# = 1 and mx# > 835 and my# > 548 and mx# < 932 and my# < 568
`gosub fern3
endif
`********MUSHROOM BUTTONS*********************************
if mc# = 1 and mx# > 835 and my# > 623 and mx# < 932 and my# < 643
`gosub mushroom1
endif
if mc# = 1 and mx# > 835 and my# > 646 and mx# < 932 and my# < 665
`gosub mushroom2
endif
endfunction
tree1:
t1s = 1
t2s = 0
t3s = 0
r1s = 0
r2s = 0
g1s = 0
g2s = 0
f1s = 0
f2s = 0
fe3s = 0
fe2s = 0
fe1s = 0
m1s = 0
m2s = 0
return
tree2:
t2s = 1
t1s = 0
t3s = 0
r1s = 0
r2s = 0
g1s = 0
g2s = 0
f1s = 0
f2s = 0
fe3s = 0
fe2s = 0
fe1s = 0
m1s = 0
m2s = 0
return
tree3:
t1s = 0
t2s = 0
t3s = 1
r1s = 0
r2s = 0
g1s = 0
g2s = 0
f1s = 0
f2s = 0
fe3s = 0
fe2s = 0
fe1s = 0
m1s = 0
m2s = 0
return
rock1:
t1s = 0
t2s = 0
t3s = 0
r1s = 1
r2s = 0
g1s = 0
g2s = 0
f1s = 0
f2s = 0
fe3s = 0
fe2s = 0
fe1s = 0
m1s = 0
m2s = 0
return
rock2:
t1s = 0
t2s = 0
t3s = 0
r1s = 0
r2s = 1
g1s = 0
g2s = 0
f1s = 0
f2s = 0
fe3s = 0
fe2s = 0
fe1s = 0
m1s = 0
m2s = 0
return
grass1:
g1s = 1
t1s = 0
t2s = 0
t3s = 0
r1s = 0
r2s = 0
g2s = 0
f1s = 0
f2s = 0
fe3s = 0
fe2s = 0
fe1s = 0
m1s = 0
m2s = 0
return
grass2:
g2s = 1
g1s = 0
t1s = 0
t2s = 0
t3s = 0
r1s = 0
r2s = 0
f1s = 0
f2s = 0
fe3s = 0
fe2s = 0
fe1s = 0
m1s = 0
m2s = 0
return
grass3:
end
return
flower1:
g2s = 0
g1s = 0
t1s = 0
t2s = 0
t3s = 0
r1s = 0
r2s = 0
f1s = 1
f2s = 0
fe3s = 0
fe2s = 0
fe1s = 0
m1s = 0
m2s = 0
return
flower2:
g2s = 0
g1s = 0
t1s = 0
t2s = 0
t3s = 0
r1s = 0
r2s = 0
f1s = 0
f2s = 1
f3s = 0
fe3s = 0
fe2s = 0
fe1s = 0
m1s = 0
m2s = 0
return
flower3:
fe3s = 0
fe2s = 0
fe1s = 0
g2s = 0
g1s = 0
t1s = 0
t2s = 0
t3s = 0
r1s = 0
r2s = 0
f1s = 0
f2s = 0
f3s = 1
m1s = 0
m2s = 0
return
fern1:
fe1s = 1
fe2s = 0
fe3s = 0
g2s = 0
g1s = 0
t1s = 0
t2s = 0
t3s = 0
r1s = 0
r2s = 0
f1s = 0
f2s = 0
f3s = 0
m1s = 0
m2s = 0
return
fern2:
fe2s = 1
fe1s = 0
fe3s = 0
g2s = 0
g1s = 0
t1s = 0
t2s = 0
t3s = 0
r1s = 0
r2s = 0
f1s = 0
f2s = 0
f3s = 0
m1s = 0
m2s = 0
return
fern3:
fe3s = 1
fe2s = 0
fe1s = 0
g2s = 0
g1s = 0
t1s = 0
t2s = 0
t3s = 0
r1s = 0
r2s = 0
f1s = 0
f2s = 0
f3s = 0
m1s = 0
m2s = 0
return
mushroom1:
fe3s = 0
fe2s = 0
fe1s = 0
g2s = 0
g1s = 0
t1s = 0
t2s = 0
t3s = 0
r1s = 0
r2s = 0
f1s = 0
f2s = 0
f3s = 0
m1s = 1
m2s = 0
return
mushroom2:
fe3s = 0
fe2s = 0
fe1s = 0
g2s = 0
g1s = 0
t1s = 0
t2s = 0
t3s = 0
r1s = 0
r2s = 0
f1s = 0
f2s = 0
f3s = 0
m1s = 0
m2s = 1
return
function spawnobjectss(objectswitch,objectnumber,objectlimit)
var1 = objectswitch
var2 = objectnumber
var2copy = objectnumber
var3 = objectlimit
scale# = object size(var2,1)
set cursor 0,50
print "working"
print var1
print var2
print var3
`**********************************************************
if var1 = 1 and var2 < var3-1 and mousex()<800
show object var2
set object transparency var2 ,6
`3D Mouse
flag=pick object (mousex(),mousey(),1,1)
mx=get pick vector x()
my=get pick vector y()
mz=get pick vector z()
mes$="x;"+str$(mx)+"y;"+str$(my)+"z;"+str$(mz)
targetx=mx+camera position x()
targety=my+camera position y()
targetz=mz+camera position z()
ghost object on var2 ,1
`ROTATING
if keystate(26) = 1
yrotate object var2 , wrapvalue(object angle y(var2) - 3.0)
endif
if keystate(27) = 1
yrotate object var2 , wrapvalue(object angle y(var2) + 3.0)
endif
position object var2 ,targetx,targety+1,targetz
If mouseclick() = 1
flag=pick object (mousex(),mousey(),1,1)
mx=get pick vector x()
my=get pick vector y()
mz=get pick vector z()
mes$="x;"+str$(mx)+"y;"+str$(my)+"z;"+str$(mz)
targetx=mx+camera position x()
targety=my+camera position y()
targetz=mz+camera position z()
position object var2 ,targetx,targety+1,targetz
`COLLISION BOXES
make object box collision,object size x(var2)/2,object size y(var2),object size z(var2)/2
position object collision, object position x(var2),object position y(var2), object position z(var2)
inc collision,1
`position object var2 ,mousex(),0,object position z(10)
Repeat
Until Mouseclick() = 0
ghost object off var2
LM Add Collision Object var2
clone object var2+1,var2
inc var2,1
set object transparency var2 ,6
var1 = 0
endif
Endif
if var1 = 0
hide object var2
endif
if var2 >= var2copy
if var2 >= 500 and var2 < 1500
tree=var2
gbvar2=tree
gbvar1=t1s
endif
if var2 >= 1501 and var2 < 2500
tree2=var2
gbvar2=tree2
gbvar1=t2s
endif
if var2 >= 2501 and var2 < 3500
tree3=var2
gbvar2=tree3
gbvar1=t3s
endif
if var2 >= 3501 and var2 < 4500
rock1=var2
gbvar2=rock1
gbvar1=r1s
endif
if var2 >= 4501 and var2 < 5500
rock2=var2
gbvar2=rock2
gbvar1=r2s
endif
if var2 >= 7501 and var2 < 8500
flower1=var2
gbvar2=flower1
gbvar1=f1s
endif
if var2 >= 8501 and var2 < 9500
flower2=var2
gbvar2=flower2
gbvar1=f2s
endif
endif
gbvar1=var1
gbvar3=var3
set cursor 0,100
print var2
endfunction
function floortexture()
set cursor 0,0
print "To change the texture of the floor press the corrisponding number:"
print "1-grass1 2-grass2 3-sand1 4-stone1"
Print "Use [ and ] to rotate objects"
if keystate(3) = 1
texture object 1,2
endif
if keystate(4) = 1
texture object 1,3
endif
endfunction
Gingerkid Jack - Aspiring Game Designer\3d Modeler