GPWiki.org
GPWiki.org
It is currently Sun May 26, 2013 4:33 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Mon Jan 09, 2012 5:13 pm 
Rookie

Joined: Sun Dec 04, 2011 10:13 am
Posts: 2
I have made a bunch of games now (snake, fall down, ...), but none of them have had a start up screen, main menu etc.
How should i program my game in a smart way so that add menus?
I have read this article : http://content.gpwiki.org/index.php/SDL ... e_Overview . Is this the best way to do it? ( i dident really understand all of it, but most of it).

Can you recommend some other ways to do it?
Can you link to an easy game where i can see the source code?

/lijas


Top
 Profile  
 
PostPosted: Mon Jan 09, 2012 5:30 pm 
I would use GameStates. Make seperate routines based on which gamestate your in (main menu, main game loop, etc) and use a switch statement in your loop to determine which draw/logic code to actually execute. then you can hope back and forth between them as need be.


Top
  
 
PostPosted: Mon Jan 09, 2012 7:44 pm 
Bit Baby

Joined: Mon Aug 15, 2011 1:27 am
Posts: 8
lijas wrote:
I have made a bunch of games now (snake, fall down, ...), but none of them have had a start up screen, main menu etc.
How should i program my game in a smart way so that add menus?
I have read this article : http://content.gpwiki.org/index.php/SDL ... e_Overview . Is this the best way to do it? ( i dident really understand all of it, but most of it).

Can you recommend some other ways to do it?
Can you link to an easy game where i can see the source code?

/lijas



This C++ game tutorial shows a way to create Menus ( part 3 I believe ), using as Anon suggested, game states. I would recommend starting there. The tutorial uses SFML, but the concepts should apply equally well to SDL.


Top
 Profile  
 
PostPosted: Tue Jan 17, 2012 12:24 pm 
Rookie

Joined: Sat Dec 24, 2011 5:39 am
Posts: 3
i like this one http://www.sdltutorials.com/sdl-app-states


Top
 Profile  
 
PostPosted: Tue May 29, 2012 12:55 pm 
Man, I had the exact problem you're describing.

I'd made a few "single state" games such as Snake and Pong, but as soon as I tried to put my own together, I was immediately stumped, because I didn't know how to move through the various game states, ie:

Splash screen -> Main menu -> Game (etc)

Anyway, http://www.sdltutorials.com/sdl-app-states will explain everything you need to know about states and how to manage them. it may look complex at first but it's actually quite simple. You have a base state class that all states inherit, and a state manager class that deals with switching between them. That way, each state of the game is split into its own class, with it's own game loop. Lovely stuff.

Btw, unless you have a lot of experience with SDL and C++, I recommend following a few of the earlier tutorials before that one, as you might find it hard to pick up. Having said that, it should be fairly straightforward to understand.

Good luck! :)


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group