By Josef Jahn
werewolf@playspoon.com
www.playspoon.com
based on Tom Morris' intro screen tutorial
tommorris@planetarybiology.com
www.planetarybiology.com
This tutorial includes paste-in code that will allow your Gtest app to display a loading screen
instead of this ugly "Loading level" text. And the image will be centered, regardless of screen resolution.
STEP ONE:
In GameMgr.c after these lines...
----------------------
#include <stdio.h>
#include <direct.h>
#include "Ram.h"
#include "Errorlog.h"
#include "GameMgr.h"
#include "Procedurals\gebmutil.h"
#include "procedurals/ProcEng.h"
extern void GenVS_Error(const char *Msg, ...);
extern geVFile *MainFS;
-----------------------
insert this:
-----------------------
// This is for the loading bitmaps.
// NOTE: Even if you've already incorporated Tom's intro screen code,
// you still need this because Tom's code is inside Genvs.c
geBitmap *Bitmap;
geCamera *Camera;
-----------------------
STEP TWO:
Scroll down to the function "geBoolean GameMgr_SetWorld(GameMgr *GMgr, const char *WorldName)"
and after
-----------------------
geWorld_Model *Model;
geVFile * WorldFile;
char TFile[GAMEMGR_MAX_WORLD_NAME+4];
int Width,Height;
int MessageWidth = 250;
-----------------------
insert this:
-----------------------
int LoadingPicWidth=519;
int LoadingPicHeight=149;
-----------------------
My loading bmp is 519x149 in size, you must change that value to fit yours.
Then search for these lines somewhere below:
-----------------------
if (!GameMgr_ClearBackground(GMgr, (Width/2)-(MessageWidth/2), Height/2-10, "Loading level, please wait..."))
GenVS_Error("GameMgr_SetWorld: GameMgr_ClearBackground failed.\n");
//GameMgr_ConsolePrintf(GMgr, GE_TRUE, "Loading level, please wait...\n");
-----------------------
and comment the IF statement out, like this:
-----------------------
// if (!GameMgr_ClearBackground(GMgr, (Width/2)-(MessageWidth/2), Height/2-10, "Loading level, please wait..."))
// GenVS_Error("GameMgr_SetWorld: GameMgr_ClearBackground failed.\n");
//GameMgr_ConsolePrintf(GMgr, GE_TRUE, "Loading level, please wait...\n");
-----------------------
LAST STEP:
Add this directly below:
-----------------------
if (GameMgr_ClearBackground(GMgr, (Width/2)-(MessageWidth/2), Height/2-10, " "))
{
//********** "Loading" picture *******************************************
//Get the camera.
Camera = GameMgr_GetCamera(GMgr);
//FIRST BITMAP
//Tell genesis to open your bitmap file and where to find it.
Bitmap = geBitmap_CreateFromFileName(MainFS,"bmp\\loading.bmp");
//Load the bitmap into memory and get ready to render.
geEngine_AddBitmap(Engine,Bitmap);
//Establish some screen real estate for your bitmap image.
geEngine_BeginFrame(Engine, Camera, GE_TRUE);
//Draw the bitmap to the screen.
geEngine_DrawBitmap(Engine,Bitmap,NULL,(Width/2)-(LoadingPicWidth/2),(Height/2)-(LoadingPicHeight/2));
//Done. leave it there.
geEngine_EndFrame(Engine);
}
else
{
GenVS_Error("GameMgr_SetWorld: GameMgr_ClearBackground failed.\n");
}
-----------------------
That's it!!
Now, all you have to do is to draw a "LOADING" bitmap, and put it into the "bmp" folder.
The bitmap must be in indexed color format (=256 colors) - NOT TRUECOLOR!!
At least you don't have to worry about the palette.
This method is very crude, there's much room for improvement. For example, how about a loading screen with transparent
background?
You'd have to fiddle with the palette to make the bmp's background use the last color palette entry, and the DrawBitmap
call would
be different. Or how about an animated loading screen? ;-)