gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Starting a new game within a game O_o

#104022 - TheWopr - Tue Sep 26, 2006 1:49 am

Ok i'm pretty sure this hasn't been asked, but before i go crazy resetting variables and using the forbidden goto statements. I wanted to know if anyone knew of a fast way to restart a game within a game. For example, while paused, if you hit select it would take you back to where it would have been if the game had just started. I thought of possibly basing the entire game off of an object class, so at the end i can just destroy it and create a new one. Any ideas?

#104028 - tepples - Tue Sep 26, 2006 2:12 am

TheWopr wrote:
I thought of possibly basing the entire game off of an object class, so at the end i can just destroy it and create a new one.

That sounds like a decent plan, putting the new in "New Game".
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#104030 - TheWopr - Tue Sep 26, 2006 2:20 am

Lol, I get what your saying I was just checking if there was some standard that game developers used, that i wasn't aware of. Doing it that way would work, it would destroy all the variables and such but what about all the graphics? The screens would still have the previous data, I guess I would just reset that manually? I'll see what i can manage with it, thanks Tepples

#104032 - sajiimori - Tue Sep 26, 2006 2:35 am

Try doing all the necessary initialization in the constructor, including graphics stuff.

#104088 - Sausage Boy - Tue Sep 26, 2006 2:35 pm

Try not doing anything in the constructor that could fail (that would be fat stuff mainly).
_________________
"no offense, but this is the gayest game ever"

#104118 - sajiimori - Tue Sep 26, 2006 6:02 pm

I wouldn't worry about it unless you intend to make your game exception-safe, and I don't know why you would on a handheld. It opens up a whole can of worms without much payoff.

#104120 - tepples - Tue Sep 26, 2006 6:07 pm

If anything in the constructor can fail, it's OK to throw an exception unless you're using -fno-exceptions to save code space. (But -fno-exceptions should really only be necessary in GBA multiboot or DS ARM7, which generally has a much smaller code section.)
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.