Ok, basically i'm trying to make an object placing level editor that uses a set matrix size for one of the tools for my game, but i just can't get it to work! Heck i don't even now how to go about making one! I'm just converting a 2d level editor that i made a long time ago into 3d but i don't think it'll work.
What i would like to know is:
A-There is a way to get this code to work
or should i:
B-recode it and how i should go about doing this
C-find a good level maker with object positioning.
here's my old 2D(well 3d but its 2D gameplay) level maker.
`Constants
normal_texture=2
metallic_texture=3
scary_texture=4
pole_cylinder=5
sharp_texture=6
black_texture=7
tiled_texture=8
crack_texture=9
`Which object is being called and its size value
Current_Cube=1
size_value=10
Morph=1
`Map size
dim map(64,12,1)
`Set current texture to first one
current_texture = normal_texture
REM * Gfx system initialization.
set display mode 800,600,16
sync on
sync rate 60
load image "back.bmp",10
load image "dark01.jpg",1
make matrix 1,700,1000,1.0,1.0
randomize matrix 1,5
prepare matrix texture 1,1,2,2
make matrix 2,700,1000,15.0,15.0
randomize matrix 2,50
prepare matrix texture 2,1,2,2
position matrix 2,0,120,0
make object cube Current_Cube,size_value
zrotate object current_cube,180
color backdrop 0
fog on
fog distance 1000
gosub thegfx
do
gosub keyboard
set cursor 0,0
print "Polygons:";statistic(1);" Framerate:";screen fps()
sync
loop
thegfx:
load image "tile1.jpg",normal_texture
load image "tile2.jpg",metallic_texture
load image "tile3.jpg",scary_texture
load image "tile4.jpg",pole_cylinder
load image "tile5.jpg",sharp_texture
load image "tile6.jpg",black_texture
load image "tile7.jpg",tiled_texture
load image "tile8.jpg",crack_texture
num_texture=9
min_texture=2
return
keyboard:
texture object Current_cube,current_texture
x#=object position x(Current_Cube)
y#=object position y(Current_Cube)
rk=returnkey()
sk=shiftkey()
if upkey()=1 then y#=y#+10
if downkey()=1 then y#=y#-10
if leftkey()=1 then x#=x#-10
if rightkey()=1 then x#=x#+10
bx=(x#/10)*10
by=(y#/10)*10
mapx=bx/10
mapy=by/10
position object Current_Cube,bx,by,60
position camera x#+10,y#+20,-60
REM * Press Q to increase current_texture
if keystate(16)=1 and current_texture < num_texture
current_texture = current_texture + 1
sleep 120
endif
REM * Press A to decrease current_texture
if keystate(30)=1 and current_texture > min_texture
current_texture = current_texture - 1
sleep 120
endif
REM * Press left mouse button to draw the current texture
if returnkey()= 1 and mapx>0 and mapx<64 and mapy>0 and mapy<12
texture Object Current_Cube,current_texture
position object current_cube,bx,by,60
map(mapx-1,mapy-1,0) = current_cube
map(mapx-1,mapy-1,1) = current_texture
inc Current_cube,1
make object cube Current_Cube,size_value
position object current_cube,object position x(Current_Cube-1),object position y(Current_Cube-1),60
zrotate object current_cube,180
endif
REM * Press R to refresh the map
if keystate(19)=1 then gosub drawmap
if inkey$()="B"
map(mapx-1,mapy-1,0) = morph
endif
REM * Press S to save the map to as the <mapnum> map
if keystate(31)=1 then gosub savemap
REM * Press L to load mapinfo from the <mapnum> map file
if keystate(38)=1 then gosub loadmap
REM * Press C to clear the map
if keystate(46)=1 then gosub clrmap
if object exist(Current_cube)>1 then inc Current_cube
return
savemap:
input mapnum
fname$ = "maps/"+str$(mapnum)+".lvl"
if file exist(fname$)=1 then delete file fname$
ink rgb(0,0,0),rgb(0,0,0)
box 0,448,639,479
ink rgb(255,255,255),rgb(0,0,0)
text 0,460,"Saving map "+str$(mapnum)+"..."
open to write 1,fname$
for x=0 to 63
for y=0 to 11
for z=0 to 1
write word 1,map(x,y,z)
next z
next y
next x
close file 1
sleep 1000
ink rgb(0,0,0),rgb(0,0,0)
box 0,448,639,479
ink rgb(255,255,255),rgb(0,0,0)
text 0,460,"MapNum: "+str$(mapnum)
return
loadmap:
input mapnum
fname$ = "maps/"+str$(mapnum)+".lvl"
if file exist(fname$)=1
ink rgb(0,0,0),rgb(0,0,0)
box 0,448,639,479
ink rgb(255,255,255),rgb(0,0,0)
text 0,460,"Loading map "+str$(mapnum)+"..."
open to read 1,fname$
for x=0 to 63
for y=0 to 11
for z=0 to 1
read word 1,map(x,y,z)
next z
next y
next x
close file 1
sleep 1000
ink rgb(0,0,0),rgb(0,0,0)
box 0,448,639,479
ink rgb(255,255,255),rgb(0,0,0)
text 0,460,"MapNum: "+str$(mapnum)
gosub drawmap
endif
return
REM * Draws the whole map to the screen
drawmap:
for x=1 to 64
for y=1 to 12
if map(x-1,y-1,0)>0
if object exist(map(x-1,y-1,0))=0
make object cube map(x-1,y-1,0),size_value
position object map(x-1,y-1,0),x*10,y*10,60
texture object map(x-1,y-1,0),map(x-1,y-1,1)
zrotate object map(x-1,y-1,0),180
endif
endif
next y
next x
return
REM * Clears the current map.
clrmap:
for x=1 to 64
for y=1 to 12
if map(x-1,y-1)>0
if object exist(map(x-1,y-1))>1
delete object map(x-1,y-1)
text 0,460,"MapNum: "+str$(Current_cube)
endif
endif
next x
next y
return
and here's the unsuccessfully converted one(i removed a few of the gosubs):
set window on
`constants
HQ=1
arch=2
tower=3
sign=4
obpoint=5
orange=6
blue=7
slant=8
grey=9
`Which object is being called and its size value
Current_object=1
Morph=1
`Map size
`Set current texture to first one
current_object = normal_object
Print "Is matrix required?: "
input res$
if res$="y" or res$="yes" then make matrix 1,1000,5000,25.0,25.0
dim map(1000,5000)
REM * Gfx system initialization.
set display mode 800,600,16
sync on
sync rate 60
fog on
fog distance 1000
gosub thegfx
do
gosub keyboard
set cursor 0,0
print "Polygons:";statistic(1);" Framerate:";screen fps()
sync
loop
thegfx:
load object "modelsleveleditorLevel1HQ.3ds",HQ : make mesh from object 1,1 : delete object 1
load object "modelsleveleditorLevel1arch.3ds",arch : make mesh from object 2,2 : delete object 2
load object "modelsleveleditorLevel1tower.3ds",tower : make mesh from object 3,3 : delete object 3
load object "modelsleveleditorLevel1sign.3ds",sign : make mesh from object 4,4 : delete object 4
load object "modelsleveleditorLevel1point.3ds",obpoint : make mesh from object 5,5 : delete object 5
load object "modelsleveleditorLevel1orangebox.3ds",orange : make mesh from object 6,6 : delete object 6
load object "modelsleveleditorLevel1bluebox.3ds",blue : make mesh from object 7,7 : delete object 7
load object "modelsleveleditorLevel1boxslant.3ds",slant : make mesh from object 8,8 : delete object 8
load object "modelsleveleditorLevel1greybox.3ds",grey : make mesh from object 9,9 : delete object 9
num_object=9
min_object=1
return
keyboard:
change mesh Current_object,0,Current_object
y#=get ground height(1,x#,z#)
rk=returnkey()
sk=shiftkey()
if upkey()=1 then z#=z#+1
if downkey()=1 then z#=z#-1
if leftkey()=1 then x#=x#-10
if rightkey()=1 then x#=x#+10
bx=(x#/10)*10
bz=(z#/10)*10
mapx=bx/10
mapz=bz/10
position object Current_object,bx,bz,60
position camera x#+10,y#+20,-60
REM * Press Q to increase current_texture
if keystate(16)=1 and Current_object < num_object
Current_object = Current_object + 1
sleep 120
endif
REM * Press A to decrease current_texture
if keystate(30)=1 and Current_object > min_object
Current_object = Current_object - 1
sleep 120
endif
REM * Press left mouse button to draw the current texture
if returnkey()= 1 and mapx>0 and mapx<10000 and mapz>0 and mapz<50000
change mesh Current_object,0,Current_object
position object current_cube,bx,bz,60
map(mapx-1,mapz-1,0) = current_object
inc Current_object,1
sleep 100
endif
REM * Press S to save the map to as the <mapnum> map
if keystate(31)=1 then gosub savemap
REM * Press L to load mapinfo from the <mapnum> map file
if keystate(38)=1 then gosub loadmap
return
savemap:
input mapnum
fname$ = str$(mapnum)+".lvl"
if file exist(fname$)=1 then delete file fname$
ink rgb(0,0,0),rgb(0,0,0)
box 0,448,639,479
ink rgb(255,255,255),rgb(0,0,0)
text 0,460,"Saving map "+str$(mapnum)+"..."
open to write 1,fname$
for x=0 to 63
for y=0 to 11
for z=0 to 1
write word 1,map(x,y,z)
next z
next y
next x
close file 1
sleep 1000
ink rgb(0,0,0),rgb(0,0,0)
box 0,448,639,479
ink rgb(255,255,255),rgb(0,0,0)
text 0,460,"MapNum: "+str$(mapnum)
return
loadmap:
input mapnum
fname$ = str$(mapnum)+".lvl"
if file exist(fname$)=1
ink rgb(0,0,0),rgb(0,0,0)
box 0,448,639,479
ink rgb(255,255,255),rgb(0,0,0)
text 0,460,"Loading map "+str$(mapnum)+"..."
open to read 1,fname$
for x=0 to 63
for y=0 to 11
for z=0 to 1
read word 1,map(x,y,z)
next z
next y
next x
close file 1
sleep 1000
ink rgb(0,0,0),rgb(0,0,0)
box 0,448,639,479
ink rgb(255,255,255),rgb(0,0,0)
text 0,460,"MapNum: "+str$(mapnum)
endif
return