FMODsound for GTest
by Bob Lawrence
Hello, and welcome to my Bitmap Menu
Tutorial. I've seen lots of people ask questions about this in the forum, and
people have posted code there also. But I think it is about time that someone
did a full tutorial about it. Firstly, many newcomers don't fully understand
about the demo and bitmaps all that well. I should know, I was once like them.
When I say demo, I am talking about the map and the walk-around at the
main menu. This is a pic of my menu for my latest game, Stick People: Better
Life.
(Note: This picture has been modified and damaged to make it non-usable.
Any illegal copying of this picture is forbidden. David Bonolo ©2001)
I will tell you about the demo and the bitmaps, and show you what you want GTest to do. All code changes are done in Red.
First, to take out the demo, delete this file:
Demo.ini
You may also take out the other demo#.dem files too, if you like.
(Note: # being any number)
Now, when you run the program, the menu should flicker constantly. This is
caused by the menu being refreshed. With the demo in the background, each
frame has to be cleared before the next one comes up. But, since we no
longer have the demo, we don't have to constantly update the screen all
the time. It should only update when the user selects an item (i.e.:
Single Player Game, Options.). So, with that out of the way, let's stop
the screen from refreshing itself.
Go to the WinMain function in Genvs.c. At line 692 or so:
(Note: I put the whole block of code in, because I forgot what the
original looked like. Just edit your code to look like the code below.
Make sure the comments are in the right place. I think I uncommented the
last block. Just pay attention to the comments.)
// Get the world, and the camera from the GameMgr
World = GameMgr_GetWorld(GMgr);
Camera = GameMgr_GetCamera(GMgr);;
if (!GameMgr_Frame(GMgr, ElapsedTime))
GenVS_Error("GameMgr_Frame failed...");
// Begin frame
if (g_FarClipPlaneEnable) // If
we are using a far clip plane,
then clear the screen
{
if (!GameMgr_BeginFrame(GMgr, World, GE_TRUE))
GenVS_Error("GameMgr_BeginFrame failed.\n");
}
else if (!GameMgr_BeginFrame(GMgr, World, GE_FALSE))
{
if (!GameMgr_BeginFrame(GMgr, World, GE_TRUE))
GenVS_Error("GameMgr_BeginFrame failed.\n");
}
//if (!Host || !World)
//
GameMgr_ClearBackground(GMgr, 0, 0, NULL);
if (Host)
{
if (!Host_RenderFrame(Host, ElapsedTime))
GenVS_Error("Host_RenderFrame failed in main game loop.\n");
}
Console_Frame(Console, ElapsedTime);
if (Host)
{
if (!World)
//GameMgr_ClearBackground(GMgr, 0, 0, NULL);
if (Host_RenderFrame(Host, ElapsedTime)==GE_FALSE)
GenVS_Error("Host_RenderFrame failed in main game loop.\n");
Console_Frame(Console, ElapsedTime);
}
else
GameMgr_ClearBackground(GMgr, 0, 0, NULL);
Compile the code and you should see the screen not flicker. But when you
select any menu item, the next screen should overlap the first screen.
(Note: I've tested this code awhile back, but I'm not sure exactly. So
give me some slack if I'm wrong.)
The next part is where the bitmap is defined. It's basically the credits
menu code, just modified. So here we go.
In Gmenu.c, at line 500 or so, add these lines:
}
fclose(f);
}
}
/////// Main Menu
// Load the menu background art
Background = geBitmap_CreateFromFileName(MainFS, "Bmp\\Menu\\main.BMP");
if (!Background)
{
geErrorLog_AddString(-1, "GMenu_Create: geBitmap_CreateFromFile
failed:",
"Bmp\\Menu\\main.bmp"); // Change to your own.
goto ExitWithError;
}
// Add the background bitmap to the world
if (!geEngine_AddBitmap(Engine, Background))
{
geErrorLog_AddString(-1, "GMenu_Create: geEngine_AddBitmap failed for
Background.", NULL);
goto ExitWithError;
}
// load slider art
SliderBar = geBitmap_CreateFromFileName(MainFS, "Bmp\\Menu\\SliderB.Bmp");
The bitmap is now defined. Just remember to change the path to your own.
Notice now that it's the exactly credits menu code.
Now, we want the bitmap to come up on the main menu. At line 650 or so, add:
// Background
GraphicItem.Art = Background;
GraphicItem.x = 0;
GraphicItem.y = 0;
Menu_AddItem( MainMenu, Menu_ItemGraphic, 0xffff, &GraphicItem );
// add items to the menu
TextItem.Text = "Solo Missions";
TextItem.TextLength = strlen( TextItem.Text );
Menu_AddItem( MainMenu, Menu_ItemText, GMenu_SinglePlayerGame, &TextItem );
This will draw the bitmap on the main menu. Compile and run the program.
You'll see your beautiful background pic on the main menu. Now, select an
item, like the options menu. One of two things could happen. (1) The menu
pic disappears, and the screen is flickering again, or (2) The menu pic
stays there, but the options menu overlaps the main menu. Here's what you do.
At about line 850 starts the Options menu. Add the exact same code as
above. Compile and run. The menu should update, showing the options menu
the right way. Do this with the other menus to. Add it in the same place
in all the rest. Make sure you don't mix in with any other blocks.
That's it! If that doesn't work, try it again. That's all I can say. If
you want a better menu now, here's what you do.
1) Recopy the code defining the pic. Put it one right after another.
Change the filename.
2) Change Background to Backgroundo (Note: I use the "o" for options).
3) Change the options menu background code to Backgroundo also.
4) When you select options, it comes up with a different picture.
5) Repeat for all (if necessary).
That's all. I suggest using PhotoShop for the menus, not to mention any
other form of graphics. I hope you enjoy this, and expand on it.


Thanks to everyone that made this tutorial possible. All credit goes where
credit is due. Thank you. David Bonolo.