19.1 Init State

In the init state, we provide the regular application functions: InitPre, Init, Shut, Update and Draw. You can take these from any program that you made earlier. Next, you provide the functions with the necessary code.

So far, we mostly left the InitPre function alone. This is the first function that is executed when the application starts. You can use this function to adjust some basic settings. In this case, that will be the name of the program and the size of the window. This can be done by using the constants we declared before.

 
void InitPre() 
{ 
   EE_INIT(); 
   App.name(APP_NAME); 
5   D.mode(WINDOW_WIDTH, WINDOW_HEIGHT); 
}  

The init function contains two lines of code. You should call the create method of the object Background and the startMusic method of the object SoundManager. You can certainly write this without an example, right?

We’ll skip the Update function for now. But in the Draw function you can go wild for a moment. This is where you create a beautiful startup screen. You can certainly use the image and show some text in the accompanying Tetris fonts. And with some extra effort, it is not too hard to make those move or even change colors. Make sure you also show a text “Push space to start”, because that is how we will start the game.