RPG Style Title Screen
Alright, this is the second tutorial for the TAW Program (main topic: http://www.rpgrevolution.com/forums/index....howtopic=31232)
!Note! I'm assuming you're using Game Maker 7 Lite for this tutorial. If you have Pro, like me, you can get a bit more functionality out of this. You'll need to experiment on your own for that.
I'll be including all the resources I post here in the actual demo file too, if you don't feel like downloading them individually.
This tutorial will teach how to create a basic title screen for your game. It will have the basic RPG style options:
I'll also discuss how to implement various other optional features, like a settings menu.
First things first, you decide on some resources to use for the title screen. You'll probably want the following:
Picture with the menu options on it (unless you're using a script to display windows, but I'm assuming you're not)
Any other animated graphics you want on the title screen
I'm going to assume that you're using the default 640x480 game resolution. Go ahead and make the background image first. If you don't have one, you're free to try out this one:
Now time to find music! You need to use WAV or MIDI files, or else Game Maker will use the computer's media player to play them instead of playing them right from the program. If you're planning on releasing your game, you shouldn't use any music you don't have the rights to. I recommend going to http://www.musopen.com/
if you want free music that you can legally use, or you can of course make your own music or ask someone to make it for you. If you want a track to use, you're free to use this: http://www.mediafire.com/download.php?wgg5tzvtmwo
It's not very good, but it's what you get for the price. It's just a little thing i recorded quickly on my rather cheap keyboard (that's why there's a high pitched noise behind it).
Make an image with all the options you want on it. I'm going to be going with "New Game" "Load" and "Quit." Here's the one I made:
Now for a cursor image! Make sure that it's about the size of a line of text on your options picture. Here's one I made:
I'm not going to make any extra graphics for animations, but you're perfectly able to if you want.
It's finally time to open up Game Maker! Import the Cursor as a sprite. Make sure it's set to transparent. Import the Background as a background. Do not make it transparent. Import the options as a sprite. Make it transparent. If you have Game Maker 7 Lite, import the music as a sound. If you have Pro, you might want to consider keeping the music seperate and importing it in-game to speed up load time.
Now that you have all the resources you need in place, it's time time begin. Create a room, and set your title screen background as the background. Create an object, and set the sprite to your options sprite. Then go into the room and lay it in a good centered position.
Make an object for your cursor too. To position it correctly in the room, you'll need to turn off "delete underlying" and set the grid very small. I wound up using a 2 pixel grid to position it properly.
Now we're going to make the cursor actually move. Because there are so few possible options on the title screen list, it's going to probably be better to have the player press the key each time he or she wants to move the cursor, instead of trying to code a good system for time delays in movement. The system we're doing is going to be very easy. Make 2 events, one for Key pressed > up and one for key pressed > down. Go in to the "control" tab and find "set variable." Set the variable "position" to 1 for the down arrow, and -1 for the up arrow, and check the box that says "relative." This means that every time up is pressed, "position" decreases by one, and every time down is pressed, it increases by one.
If you run the game now, it will get an error, because the variable "position" has never been created. So what we need to do is set up a "create" event for the cursor object. In the actions for it, set the variable "position" to 0. Do NOT check relative on this one. Now it won't give you any errors, but it won't do anything yet either.
Before it will do anything, we need to tell the cursor where it should go on the screen for each value of "position." Create a "step" event for the object. We're going to be some actual GML coding here. It's possible to do it with drag and drop controls, but a bit tedious. Before we start, we need to figure out exactly where the cursor needs to move. Because each option on mine is 32 pixels tall, the formula I will use is:
y = 346 + 32*position
346 is the starting position of the cursor on mine. Yours might be different. The X may or may not need to change, based on the layout of your title. Now pressing the arrows will visibly move the cursor. But wait! The cursor can move past the end of the option list. So go back into that same code you just added, and add this at the beginning:
if (position < 0)
position = 2;
if (position > 2)
position = 0;
This will make the cursor "wrap around" when it goes outside the allowed positions.
Give it a test run. The cursor should move pretty much perfectly now.
Now we're going to make the choices actually do something! New Game and Quit Game will be the easiest, so let's cover those first. Create a key press>enter event. This will be used for all of them. Add a "test variable" action. Set the variable to position and the value to 0. Go ahead and add start- and close-blocks after it. Copy and paste this whole set, with the variable check testing for 0, 1, and 2. For 0, inside the block you simply put in a transfer to the room to start the story in. For 2, you simply end the game. You'll want to make another room to test the "new game" one.
Loading is going to be the weirdest one to implement, because there are simply so many different ways to implement loading. I'm going to assume that you're only using one save file, and that you're using Game Maker's default saving function. Now, there is something a little odd about how Game Maker saves work. If the player does the built in save with F5, it names it something like _save684483.sav. This is not good for easy loading unless you want the player to type in the name of the save game. Instead of having the player use f5 to save the game, you should set up your own saving system using the game_save(filename) function or drag and drop action. Make sure you remember the name of the save that will be used. Stick a "load game" action in the block for position=1. Use the same file name that your save games will use.
If you want to use the default F5 saving, you could have the "load" button simulate an f6 press. To do this, add this in an "execute code" action instead of the load game:
Here's what my GM screen looks like with a few random windows open
The basic stuff should work like so. There are a few things that we missed, though. We need to add music to the title screen, and have it end when new game is pressed. Well, why not just stick the music start in the create event of the cursor, and the stop in the enter key event? It's as easy as it sounds. In the create event, add a "play sound" action, and in the enter event, add a "stop sound" action. Don't put the stop sound within any of the blocks. If you want to add animations to your title screen, just find some gifs or sheets you like, import them, and stick objects around the title (don't do it to much or people may hate you for it).
If you want to add more options to your menu, it's quite easy. Just us a different "options" image, and change the max number of possible positions for the cursor.
Having multiple save files could wind up being a little bit difficult. You'd need to create another room that displayed a list of all the possible save files, and process what to do for each one.
Reason for edit: Messed up topic title