Restart a game.. or load one... etc..

Blitz3D Forums/Blitz3D Beginners Area/Restart a game.. or load one... etc..

Santiworld(Posted 2008) [#1]
hi..

i have a game... start with a menu options. "new game, load, exit...."

when i choose (start) the program load 3D, variables etc...
and start the game...

if i press "ESC" back to menu.....

in case i choose "Exit", how can i clean all memory data?

if i choose "New game", i need to clear all data, and restart the game again... but crash becouse there is already data loaded in the first time y play the game...

there is a command or way to do that?

thanks again..


big10p(Posted 2008) [#2]
ClearWorld().


Santiworld(Posted 2008) [#3]
:) perfect!... thanks!!!

but, the variables don't reset with clearworld...


GIB3D(Posted 2008) [#4]
Heh, i'll try to help...

Make a function called Reset if you havent already and then have it reset all variables back to their original numbers or strings like this

x = 22
mehcode$ = "cake"
mehcode = "cow"

Function Reset();
     x = 22
     mehcode = "cake"
End Function


And just use that to reset EVERYTHING

(Someday i'd love to learn how to use Data and WriteFile and all that other stuff to make a savable\loadable map)


Santiworld(Posted 2008) [#5]
thanks, thats go to work fine , but i have more than 300 variables... :)


mtnhome3d(Posted 2008) [#6]
what i do is i create a function that calls other functions
function setup()
loadworld
loadplayer
loadotherrandomthings
run
end function

the run command is the main loop and the menu calls setup when you click start.


big10p(Posted 2008) [#7]
Of course you have to reset the variables yourself. How could ClearWorld possibly know which variables to reset, and to what value? ;)