A simple level editor I made in a few hours.
Nothing fancy, but maybe it will come to use for someone.
For the moment it only creates segments and loads a box (as a placeholder for entities and models)
When you are done you press I to save everything, each part of the level will be saved to a seperate .object file.
Controls:
Use mousekey to look around
WASD to move
1 and 2 to swap camera between FPS and top camera.
E for segmentmode
Q for modelmode
P for new segment/model when in segment/modelmode
O to reset segment position
arrowkeys to move segment
When you have made a new entity the entity will position itself at the cameras X and Z position, so switch to camera 2, then press spacekey to lock its position.
Feel free to use in anyway, to add stuff and reupload.
NOTICE:
You neew to make a folder named "objects" in your projects folder. You also need two textures named:
treadplate_d.dds
treadplate_n.dds
These are form darkshader, change to your likning.
and the code:
Rem Project: Game editor
Rem Created: Friday, June 25, 2010
Rem ***** Main Source File *****
sync on
sync rate 60
dim object(100,8)
ID = 1
x = 100
y = 10
z = 100
xP = 10
yP = 10
zP = 30
objectID = 1
newest = 1
curcam = 1
make object box 10001,10,10,10
hide object 10001
make light 1
make light 2
color light 2,rgb(255,0,0)
set light range 1,1000
set light range 2,1000
set point light 1,0,0,0
set point light 2,0,0,0
position light 1,200,200,0
position light 2,-200,200,200
hide light 0
set ambient light 65
set normalization on
make camera 1
make matrix 1,1000,1000,50,50
position matrix 1,-500,0,-500
//Laddar texturer
load image "treadplate_D.dds",1
load image "treadplate_N.dds",2
set dir "objects"
//Laddar variabler
for p = 1 to 100
if file exist ("object" + str$(p) + ".position")
open to read 1,"object" + str$(p) + ".position"
read long 1,object(p,1)
read long 1,object(p,2)
read long 1,object(p,3)
read long 1,object(p,4)
read long 1,object(p,5)
read long 1,object(p,6)
read long 1,object(p,7)
read long 1,object(p,8)
close file 1
endif
next p
for t = 1 to 100
if file exist ("object" + str$(t) + ".position")
make object box object(t,1),object(t,2),object(t,3),object(t,4)
position object object(t,1),object(t,5),object(t,6),object(t,7)
texture object t,object(t,8)
set bump mapping on t,2
endif
next t
do
if file exist ("object" + str$(objectID) + ".position") then inc objectID,1
//Vad som ska stå på skärmen
text 10,10,str$(screen fps())
text 10,30,"E = segment"
text 10,40,"I = save"
text 10,50,"Q = models"
text 10,60,"1 and 2 for camera"
if keystate(18) = 1
text 110,10,"P = New segment"
text 110,20,"O = reset segment"
text 110,30,"arrowkeys to move segment"
endif
if keystate(16) = 1
text 110,10,"P = New model"
//text 110,20,"O = Nollställ segment"
//text 110,30,"Piltangenter för att flytta segment"
endif
//Skapar segment i mitten
if keystate(18) = 1 and keystate(25) = 1 and Pkey = 0
if file exist ("object" + str$(objectID) + ".position") = 0
object(objectID,1) = objectID
object(objectID,2) = x
object(objectID,3) = y
object(objectID,4) = z
object(objectID,5) = 0
object(objectID,6) = 0
object(objectID,7) = 0
object(objectID,8) = 1
make object box object(objectID,1),object(objectID,2),object(objectID,3),object(objectID,4)
position object object(objectID,1),object(objectID,5),object(objectID,6),object(objectID,7)
texture object objectID,1
set bump mapping on objectID,2
newest = objectID
inc objectID,1
else
inc objectID,1
endif
endif
//Pkey = keystate(25)
//Skapar en modell
if keystate(16) = 1 and keystate(25) = 1 and Pkey = 0 //and entitymode = 0
if file exist ("object" + str$(objectID) + ".position") = 0
object(objectID,1) = objectID
object(objectID,2) = 10
object(objectID,3) = 20
object(objectID,4) = 10
object(objectID,5) = 0
object(objectID,6) = 10
object(objectID,7) = 0
object(objectID,8) = 1
make object box object(objectID,1),object(objectID,2),object(objectID,3),object(objectID,4)
position object object(objectID,1),object(objectID,5),object(objectID,6),object(objectID,7)
texture object objectID,1
set bump mapping on objectID,2
entitymode = 1
newestE = objectID
inc objectID,1
else
inc objectID,1
endif
endif
Pkey = keystate(25)
if entitymode = 1
text 110,20,"Press spacekey to lock position. Camera 2"
position object newestE, camera position x (1),10,camera position z(1)
if spacekey() = 1
entitymode = 0
object(newestE,5) = object position X(newestE)
object(newestE,6) = object position Y(newestE)
object(newestE,7) = object position Z(newestE)
endif
endif
//Tar hand om kamerorna
if keystate(2) = 1
position camera 1,object position x(10001),object position y(10001),object position z(10001)
hide object 10001
curcam = 1
endif
if keystate(3) = 1 and twokey = 0
show object 10001
position object 10001,camera position x(1),camera position y(1),camera position Z(1)
curcam = 2
camX = 0
camZ = 0
position camera 1,0,200,0
rotate camera 1,90,0,0
camY = 200
endif
twokey = keystate(3)
//Flyttar senaste modellen
if keystate(18) = 1 and leftkey() = 1 and left = 0 then dec object(newest,5),10
if keystate(18) = 1 and rightkey() = 1 and right = 0 then inc object(newest,5),10
if keystate(18) = 1 and upkey() = 1 and up = 0 then inc object(newest,7),10
if keystate(18) = 1 and downkey() = 1 and down = 0 then dec object(newest,7),10
if keystate(18) = 1 and keystate(24) = 1 then position object newest,0,0,0
left = leftkey()
right = rightkey()
up = upkey()
down = downkey()
if object exist (newest) then position object newest,object(newest,5),object(newest,6),object(newest,7)
//Sparar allt med I
if keystate(23) = 1
for i = 1 to 100
if object exist (i) and file exist ("object"+ str$(i) +".position") = 0
delete file "object"+ str$(i) +".position"
writefile(i,object(i,2),object(i,3),object(i,4),object(i,5),object(i,6),object(i,7),object(i,8))
endif
next i
endif
//Uppdaterar kameran
if curcam = 1 then camera()
if curcam = 2
if keystate(17) = 1 then inc camZ,1
if keystate(31) = 1 then dec camZ,1
if keystate(30) = 1 then dec camX,1
if keystate(32) = 1 then inc camX,1
position camera 1,camX,mouseZ()/4 + 200,camZ
endif
sync
loop
function writefile(objectID,x,y,z,xP,yP,zP,texture)
//if file exist ("object"+str$(objectID) +".position") then inc objectID,1
open to write 1,"object" + str$(objectID) + ".position"
write long 1,objectID
write long 1,x
write long 1,y
write long 1,z
write long 1,xP
write long 1,yP
write long 1,zP
write long 1,texture
close file 1
endfunction
function camera()
if keystate(17) = 1
move camera 1,1
endif
if keystate(31) = 1
move camera 1,-1
endif
mousePox = camera angle x(1) + mousemoveY()/2
mousePoy = camera angle y(1) + mousemoveX()/2
if mousePox >89 then mousePox = 89
if mousePox <-89 then mousePox = -89
//if camera angle x (1) <90 and camera angle y (1) > - 90
rotate camera 1,mousepox,mousepoy,0
// endif
position mouse screen width()/2,screen height()/2
text 10,20,str$(camera angle x(1))
endfunction