What's on the menu?

Main menus may have disappeared in many applications, but they are still alive and well in games. The main menu gives the player a chance to decide what to do once the game has loaded. We are going to create a simple menu that allows the player to start the game, display the credits, or exit the game.

Creating the menu

Our menu will be built out of two components. First, we will load an image to use as the background. Next, we will load additional images to use as UI buttons. Together, these images will create a screen that will allow the player to navigate our game.

We will start by defining a sprite to represent the menu. Add the following line of code to the variable declarations in RoboRacer2D.cpp:

Sprite* menuScreen;

Next, ...

Get OpenGL Game Development By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.