ok, details:
1. Create header:
type TBox3D
posX# as float
posY# as float
posZ# as float
posW# as float
posH# as float
posD# as float
endtype
type TScriptZone
position as TBox3D
nextMapName as string
endtype
global objectCount as integer
global zoneGoTo as TScriptZone ` your script-zone
global Render_Player_Speed# as float
global cx# as float
global cy# as float
global cz# as float
global cax# as float
global cay# as float
global caz# as float
Render_Player_Speed#=10.0 ` speed for move
cy#=0
sorry, in my city now night on the street, i sleep in walking, and i'm bad writing the code))
2. You need use load scene from file. It may be:
function loadScene(filename as string)
#constant MAP_FILE = 0x0001
local tmp as string
local modelName as string
local textureName as string
local posX# as float
local posY# as float
local posZ# as float
local angX# as float
local angY# as float
local angZ# as float
global level as string
level = filename
if file exist (filename)=0 then exitfunction
cleadAll()
open to read MAP_FILE, filename ` open file
read string MAP_FILE,tmp ` check map
if tmp<>"MAP" ` this file not map!
exit prompt "error!","err"
end
endif
read float MAP_FILE, cX#
read float MAP_FILE, cY#
read float MAP_FILE, cZ#
read float MAP_FILE, caX#
read float MAP_FILE, caY#
read float MAP_FILE, caZ#
read string MAP_FILE, zoneGoTo.nextMapName ` next level
read float MAP_FILE, zoneGoTo.position.posX# ` zone pos
read float MAP_FILE, zoneGoTo.position.posY#
read float MAP_FILE, zoneGoTo.position.posZ#
read float MAP_FILE, zoneGoTo.position.posW#
read float MAP_FILE, zoneGoTo.position.posH#
read float MAP_FILE, zoneGoTo.position.posD#
make object box 0x64ff, abs(zoneGoTo.position.posW#-zoneGoTo.position.posX#),abs(zoneGoTo.position.posH#-zoneGoTo.position.posY#),abs(zoneGoTo.position.posD#-zoneGoTo.position.posZ#) ` i create this script zone, for you see it
position object 0x64ff,zoneGoTo.position.posX#,zoneGoTo.position.posY#,zoneGoTo.position.posZ# ` position zone
ghost object on 0x64ff
color object 0x64ff,rgb(255,0,0)
read long MAP_FILE, objectCount
for i=1 to objectCount
read string MAP_FILE,modelName
read string MAP_FILE,textureName
read float MAP_FILE,posX#
read float MAP_FILE,posY#
read float MAP_FILE,posZ#
read float MAP_FILE,angX#
read float MAP_FILE,angY#
read float MAP_FILE,angZ#
select (modelName) ` this test block, you need "load object" and "texture object", i be use "make object" for demonstration
case "box"
make object box i,rnd(50)+20,rnd(50)+20,rnd(50)+20
endcase
case "sphere"
make object sphere i,rnd(50)+20
endcase
endselect
position object i,posX#,posY#,posZ#
rotate object i,angX#,angY#,angZ#
next
close file MAP_FILE
endfunction
for demonstration, i create mini scenes from functions:
function createScene1(fileName as string, nextLevel as string)
if file exist(filename)=1 then delete file filename
open to write 1,filename
write string 1,"MAP"
write float 1,0 ` position player in scene
write float 1,0
write float 1,0
write float 1,0 ` rotation
write float 1,0
write float 1,0
write string 1,nextLevel ` next level
write float 1,2000 ` script-zone
write float 1,-5
write float 1,2000
write float 1,3000
write float 1,1000
write float 1,3000
write long 1,200 ` objects
for i=0 to 199
write string 1,"box"
write string 1,"texture"
write float 1,rnd(3000)
write float 1,-rnd(10)-50
write float 1,rnd(3000)
write float 1,rnd(360)
write float 1,rnd(360)
write float 1,rnd(360)
next
close file 1
endfunction
and:
function createScene2(fileName as string, nextLevel as string)
if file exist(filename)=1 then delete file filename
open to write 1,filename
write string 1,"MAP"
write float 1,500 ` position player in scene
write float 1,0
write float 1,500
write float 1,0 ` rotation
write float 1,0
write float 1,0
write string 1,nextLevel ` next level
write float 1,1000 ` script-zone
write float 1,-5
write float 1,3000
write float 1,4000
write float 1,1000
write float 1,4000
write long 1,100 ` objects
for i=0 to 99
write string 1,"sphere"
write string 1,"texture"
write float 1,rnd(3000)
write float 1,-rnd(10)-50
write float 1,rnd(3000)
write float 1,rnd(360)
write float 1,rnd(360)
write float 1,rnd(360)
next
close file 1
endfunction
3. You need create simple "zone checker"
function playerInScriptZone()
local result as integer
result = 0
if camera position x()>=zoneGoTo.position.posX# and camera position x()<=zoneGoTo.position.posW#
if camera position y()>=zoneGoTo.position.posY# and camera position y()<=zoneGoTo.position.posH#
if camera position z()>=zoneGoTo.position.posZ# and camera position z()<=zoneGoTo.position.posD#
result=1
endif
endif
endif
endfunction result
4. Create clean all:
function cleadAll() ` clean for example
for i=1 to objectCount
delete object i
next
delete object 0x64ff
objectCount=0
endfunction
ok. next, add program for testing:
createScene1("level1.map","level2.map") ` make levels, and setup point for "transition"
createScene2("level2.map","level1.map")
loadScene("level1.map") `load default level
sync rate 60
sync on
do
if (KeyState(17) = 1)
cx#=NewXvalue(cx#,cay#,Render_Player_Speed#)
cz#=NewZvalue(cz#,cay#,Render_Player_Speed#)
endif
if (KeyState(31) = 1)
cx#=NewXvalue(cx#,WrapValue(cay#-180),Render_Player_Speed#)
cz#=NewZvalue(cz#,WrapValue(cay#-180),Render_Player_Speed#)
endif
if (KeyState(30) = 1)
cx#=NewXvalue(cx#,WrapValue(cay#-90),Render_Player_Speed#)
cz#=NewZvalue(cz#,WrapValue(cay#-90),Render_Player_Speed#)
endif
If (KeyState(32) = 1)
cx#=NewXvalue(cx#,WrapValue(cay#+90),Render_Player_Speed#)
cz#=NewZvalue(cz#,WrapValue(cay#+90),Render_Player_Speed#)
endif
inc cax#,mousemovey()*0.8 : cax#=wrapvalue(cax#)
inc cay#,mousemovex()*0.8 : cay#=wrapvalue(cay#)
position camera cx#,cy#,cz#
rotate camera cax#,cay#,caz#
set cursor 0,0
print "pos: "+str$(cx#)+"; "+str$(cy#)+"; "+str$(cz#)
print "level: '"+level+"'"
if playerInScriptZone()=1 ` check script
loadScene(zoneGoTo.nextMapName) `load next level
endif
sync
loop
that's all.
If you start this programm, loading level1, next, go to the "red box", and level reset, and programm read next level. I created loop levels.
Sorry for my English, tried to explain as best I could.
I attached source file, for compilation.