I want to add a splash screen to my game but this is new to me, I need a little help. I am making a breakout game using opengl and c++.
splash screen
is this code good for game states
class CGameState
{
public:
void Init();
void Cleanup(); void Pause();
void Resume();
void HandleEvents();
void Update();
void Draw();
};
It should be OK but, if I'm not wrong you need virtual keyword before void's :-)
You only need virtual if you plan on overwriting the function in child classes. "void" works if you are not returning anything from a function.
how do I actually implement this code, I have 14 pages of code, where should I start
.
I am assuming you already have some game code? Perhaps a running game? Since you want to run the splash before opening any real window (assuming you are using a windowed design), you could just create a splash screen window that does not have any windowed effects (ie title bar, minimize button, close button) to show your splash screen, and while that is displayed, load your resources. When your resources are loaded, call the rest of your already established code, for instance your game window that does have a title bar and a close button.
With the structure you posted*, just put the splash screen code in your init() function, at the start, show a splash image, then start loading resources and data. When it finishes, start the game code.
* - edited
It should be OK but, if I'm not wrong you need virtual keyword before void's :-)
You only need virtual if you plan on overwriting the function in child classes. "void" works if you are not returning anything from a function.
This is not an accurate way of thinking about it. First you can overwrite a method in a child class without virtual, however to call it you must have a variable or pointer to the child class. Virtual is for polymorphism. If you wish to call a method on a parent class but have the method called for child class of the runtime type. To get this to work you must use the heap, and there for pointers, and inheritance.
It should be OK but, if I'm not wrong you need virtual keyword before void's :-)
You only need virtual if you plan on overwriting the function in child classes. "void" works if you are not returning anything from a function.
This is not an accurate way of thinking about it. First you can overwrite a method in a child class without virtual, however to call it you must have a variable or pointer to the child class. Virtual is for polymorphism. If you wish to call a method on a parent class but have the method called for child class of the runtime type. To get this to work you must use the heap, and there for pointers, and inheritance.
I was thinking more along the lines of interfaces when Damian. mentioned virtual. You are right.
assuming you are using a windowed design
Forgot to mention:
If you are doing just a full screen game you don't need to create a new window/change styles, just draw the splash screen, handle loading, then clear the screen and start running/drawing your game.