Next level

Blitz3D Forums/Blitz3D Beginners Area/Next level

jigga619(Posted 2003) [#1]
I am working on a 3d game that has 5 levels in it. It is a FPS. Each level looks dramatically different. The levels are each made in maplet. My question is, how do I code it so that when a player get 5 points , the level he is on ends, and another one begins. I think, it may go something
like this.......



if playerpoints#>4 and playerpoints#<6
GOSUB leveltwo
endif

leveltwo.
loadmesh("level2.b3d")
return


jhocking(Posted 2003) [#2]
Something like that but the specifics are a little odd. For starters, "if playerpoints>4 and playerpoints<6" is the same as saying "if playerpoints=5"

Also, you need to unload the current level before/when loading a new level. Look into ClearWorld and the various "FreeSomething" commands.

Usually you don't want a separate function for each level, you just want a generic LevelLoad function which decides which level to actually load based on the state of the game. For example, have a global "currentLevel" variable which keeps track of the level the player is on, add one to it at the end of every level (before loading the next,) and then call LoadMesh with that variable:

Function LevelLoad()
levelMesh=LoadMesh("level"+currentLevel+".b3d")
<various other level loading tasks>
End Function


semar(Posted 2003) [#3]
I would avoid the use of gosub; rather, I would consider this way:

if playerpoints = 5 AND current_level = 1 then ;note that you don't need a float variable to store the player score
current_level = 2;set the new current level

;now I think you should load the new level as you did
;but first you should discard the previous one with
;freemesh or freentity command

the_level = loadmesh("level2.b3d")

;now you should warp the player at the x,y,z position where the new level should start from

endif


Consider, also, to show a briefing screen where to inform the player that a new level has been reached; show the score, and such, and give a 'press space to enter the new level' message. After that, then release the old mesh, load the new one, warp the player and... play !

Hope this has sense for you,
Sergio.

P.S.
jhocking you're so fast !!
;)


SSS(Posted 2003) [#4]
i dont mean to doubt your abilities but maybe you should start with something a bit simpler...


DarkEagle(Posted 2003) [#5]
this is simple :P

when the player gets 5 points, do some kind of fade out effect, free all entities, load new level, fade back in :)


jhocking(Posted 2003) [#6]
Wow, that was remarkably useless advice. His question was about how to code level changing (ie. all that stuff you listed.)