Thanks Rudolpho!
right when I went to bed last night, I figured the double in resource usage, could be indeed the fact than whenever I load a new map, I did have cleared the content of the previous map, but the original loop was still running, so when a new map is running, the old one still runs in the background.
I think I might be able to fix the problem if I make it so that the original, first, loop will completely end, before I run another instance. Gonna fiddle with this! I really appreciate all the help given so far! ^^
Edit: Hmmm, changing the map running loop condition, has no effect. Perhaps I should turn the loop into a separate function that completely gets ended with a map end/change.
Edit 2: Hmmm, I've tried a line of code, but it won't run at all. I still need something like that. I've put a big arrow at my closing function, so if anybody has an idea how to do it, please tell!
// =====================================================================
// Load & run map
// =====================================================================
_load_map: // Goto destination
// Globals :
global map
global stats_status$
// Initial Settings (later read from file!)
SYNC ON
SYNC RATE 60
AUTOCAM OFF
stats_status$="off"
// Load the map file
map = B3D LOAD OBJECT (mapfiles$)
// Enviromental Settings
FOG ON
FOG Color RGB(161,208,255)
FOG DISTANCE 8000
load_map()
// =====================================================================
// Find and load all limbs/entities of the map
// =====================================================================
function load_map()
// Here goes the entity 'types' to use to spawn around
// Here is the limb counter loop to find and spawn all entities.
for Limb = 0 to get limb count( map )
// fly_cam
if instr(limb name$(map, Limb), "spawn_fly_cam") > 0
fly_cam = find free object()
fly_cam_camera = CMR MAKE CAMERA()
COLOR BACKDROP fly_cam_camera,RGB(161,208,255)
SET CAMERA RANGE fly_cam_camera,0.1,90000
position CAMERA fly_cam_camera, limb position x(map, Limb), limb position y(map, Limb), limb position z(map, Limb)
rotate camera fly_cam_camera, limb direction x(map, Limb), limb direction y(map, Limb), limb direction z(map, Limb)
endif
next
endfunction
run_map()
// =====================================================================
// Main map loop
// =====================================================================
function run_map()
game_state$ = "on"
while game_state$ = "on"
// LOCK BACKBUFFER `Backbuffer op slot en dan data laden
// 3D Stuff <<<----------------------------
if keystate(30)= 1 //a
map = B3D Delete Object( map )
endif
// TEMP controls
CONTROL CAMERA USING ARROWKEYS fly_cam_camera,10,5
//inc cax#,mousemovey()
//inc cay#,mousemovex()
//rotate camera fly_cam_camera, wrapvalue(cax#),wrapvalue(cay#),0
yrotate camera camera angle y() + mousemovex()*0.3
xrotate camera camera angle x() + mousemovey()*0.3
UNLOCK BACKBUFFER `Open de backbuffer en render de data
// 2D Stuff <<<----------------------------
//FPS + Polycount
if stats_status$="on"
text 3,18,("polygons : "+str$(statistic(1)))
text 3,33,("fps : "+str$(screen fps()))
endif
// Call Console
Text 3,3,"press tilde for console"
if keystate(41)
repeat
until scancode()=0
console()
endif
//PHY UPDATE
SYNC
// End of loop
endwhile
endfunction
end // Ends the program
// ============================== END ==================================
// close map
function closemap()
// clear all items!
map = B3D Delete Object( map )
// terminate the game loop : DOES NOT WORK! Turn game loop in a function and
// terminate that when closing/changing a map?
//game_state$ = "off"
endfunction run_map() <<---------------------------------------
FLUSH VIDEO MEMORY
cls
endfunction
// changemap
function changemap()
closemap()
goto _load_map
endfunction
Regards,
Sph!nx
www.DevEd-portal.com