© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
B. TyersGameMaker Fundamentalshttps://doi.org/10.1007/978-1-4842-8713-2_15

15. Splash Screens and Menu

Ben Tyers1  
(1)
Worthing, West Sussex, UK
 

A splash screen is typically shown when a game starts. It is a great time to show off your logo and set up variables needed for the game. This room is an ideal place to load any saved game data, such as highscores.

A menu is generally then shown, allowing the player to select which level to play. A completed game rooms tree may look something like this:

An illustration of the rooms folder. It lists the room game complete, room level 1, room level 2, room menu, and room splash.

Figure 15-1

Showing an example of rooms in the resource tree

If you look at Figure 15-1, you’ll see a house symbol next to room_splash. This tells you which room will be the first to run when the game is started.

Go ahead and create these rooms as shown in the Figure 15-1.

Splash Screen Example

Create a new object, obj_splash_screen. Assign the logo sprite from the resources folder, with the origin as Middle Center. Put the following code in the Create Event:
/// @description Set up
global.level=0;
lives=10; //Start with 10 lives
score=0; //Start with a score of 0
global.bonus_score=0; //No Bonus
health=100; //Set health
alarm[0]= game_get_speed(gamespeed_fps)*5;
//center sprite
x=room_width/2;
y=room_height/2;

This sets some initial variables for this example.

Alarm[0] Event code will then take the player to the menu room by running the following code:
/// @description Change room
room_goto(room_menu);

Place one instance of this object in room_splash and test.

Basic Projects

  1. A)

    Set up so a sprite animates to its last frame, set an alarm for five seconds that then goes to a new room.

     
  2. B)

    Set a menu room and three buttons that can take a player to two levels and an info room, return to the menu when the player presses spacebar. Make the buttons change color when mouse hovers over them.

     

Advanced Project

  1. C)

    Make five buttons that become unlocked based on the player’s level. Use different subimages to graphically show this. Allow keys 1 through 5 to set current level.

     

Useful Functions

room_get_name() can be used to get the name of the current room, useful if you wish to display it on your HUD, for example. It will set a variable as string.
room_set_camera()

Summary

You should now understand the importance of setting up global variables at game start so you can access them later within your game.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.228.210