Title Screens

Started by
5 comments, last by Ekim_Gram 20 years ago
Ok, this has got to be my 10th topic helping me along with my game and I must thank you guys so much for all the help. I just finished my level-progressing functions (a good 200-400 lines as a matter of fact) and now I need to make up a title screen. My problem is that I''m not exactly sure how to do it. The game starts and the title screen appears where you set the difficulty and then choose to start the game. But now...I have a function called InitGame() that set''s up all the sdl stuff and items needed for the first level. It looks like this:

int CGame::InitGame()
{
	// Set the game variables first

	m_GameOver  = 0;			// Game isn''t over

	m_GamePause = 0;			// Game isn''t paused

	m_Scroll    = 0;			// The scrolling background''s position

	m_LevelImage = true;

	// Initialize SDL

  if (SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 )
  {
    printf("Unable to init SDL: %s\n", SDL_GetError());
    exit(1);
  }
  atexit(SDL_Quit);

	// Now set up the Video

	g_GameScreen = SDL_SetVideoMode(640,480,32,SDL_SWSURFACE|SDL_HWPALETTE|SDL_FULLSCREEN);
  if (g_GameScreen == NULL)
  {
    printf("Unable to set 640x480 video: %s\n", SDL_GetError());
    exit(1);
  }

	// Initialize the key input

	m_Keys = SDL_GetKeyState(NULL);
	
	// Load the font(s) and initialize it/them

	g_Font.m_FontStruct = g_Font.initFont("data/font3");

	// Set the random number seed

	srand(time(NULL));

	// Say goodbye to the cursor

	SDL_ShowCursor(0);

	// Load the level data and start on level 1

	Level.InitLevel("data/level_1");
	Level.LoadLevel();

	return 1;		// Return 1 or true if everything went well

}
I guess instead of loading the levels I could make a title screen function and do that...hell...I''m answering my own question as I write this. Long question short, what''s the best way to do a title screen? VG-Force | Ekim Gram Productions
Advertisement
A function is only supposed to do one thing. The init function should just do that. Then when it returns that init went well then call a menu function that does your menu stuff. Then call the game function. That way you can set game variables before you start the game.
"best" is a subjective term..but using a state manager is a nice way. Clicky to get you started.

-Luctus
Statisticly seen, most things happens to other people.
[Mail]

[edited by - Luctus on April 3, 2004 12:34:24 PM]
-LuctusIn the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move - Douglas Adams
Well, get rid of the Level.x calls and replace them with calls to load your menu. Then when the user presses the "Go" button, then call the level.load() stuff.

Not sure if that really answers anything though...

Walter O. Krawec
www.waltsgames.com
My TBS game has several "screen types" where each type is actually a ParaGUI (library) widget the size of the screen which i place other objects under.

But I have a class called RenderMan and i call RenderMan->ChangeScreens( screen_type s ) when it''s time to switch. And of course, there are several flavors of screen_type including:

SCREEN_TYPE_START
SCREEN_TYPE_MAIN
SCREEN_TYPE_OPTIONS
SCREEN_TYPE_HELP
SCREEN_TYPE_HIGHSCORE

or whatever else you need. Each screen type is it''s own class, so i just let each class worry about what kind of info actually goes on it.

However, that''s for my game where rendering and logic have been largely decoupled.
I haven''t read all your post but heres some ideas...

A Title Screen is a current state of play, that is, like an introduction to the game it shouldn''t process data structures or whatnot but display an image and wait for an action (or whatever you want it to do).

Anyhow heres some code...

if(game_state == GAME_TITLE_SCR){     DrawBitmap("Title.bmp");     if(KEYDOWN())          game_state = GAME_MENU;}


Basically, I like to use state transition models, when game_state transists to GAME_MENU the program would decide what the user wants to do, i.e New Game, Load Game, Settings etc.
-----------------------------Language: C++API: Win32, DirectXCompiler: VC++ 2003
Oh, just so you know I finished my title screen this morning. Works fine


VG-Force | Ekim Gram Productions

This topic is closed to new replies.

Advertisement