Gw Temp

Menu

Tutorial - 'Game Maker Basics' by phantomditto

An item about Gamemaker posted on

Blurb

A tutorial discussing very basic techniques in the Game Maker program

Body

So you decided to advance a bit from RM2k, and want to get started in Game Maker, first off, congratulations for coming this far! Now to the serious business. The first thing to make you feel comfortable with this is learning how to make a graphic move around the screen when you press a button. Just like sprites in RM2k, but a simple moving picture can be at least a 10 minute job if you want to do it right. WARNING: This involves an average amount of commands, because Game Maker doesn't handle sprites like RM2k does.

OK, here's the drill.

On the left side of the screen, there's a list of all the components of a game. First off, we want to get the ball's graphic into our game. Do this by clicking on the Sprites folder and pressing Insert. This will pop up the Sprites Property dialog box. Luckily, the sprite we're going to use comes with Game Maker in the Various folder. Click Open and find the little graphic that says ball. It is a soccer ball. Who cares? At the top of the dailog box, there is a name box. Type in ball, so you'll remember what it is. Click OK.

There, you've just gotten a sprite. As of yet, though, all it is is a bitmap that happens to be included in our game file. We have to make it an object to make it do anything. Click the Objects folder and press Insert.

This opens the Object Properties dialog box. Name this "ball" as well. Below that, there will be two tabs, Basic and Advanced. Don't worry about Advanced for now, just go down to the text box that says , click it, and choose your ball sprite. Yay! We *could* put it in a room now, but let's keep going so it actually does something.

There will be two boxes in the right part of the box. The first one is the Events box and the other one is the Actions box. Get used to these, you'll be using them often. In short, the function of these is WHEN this happens, do THIS. What do we want to do with this ball? Well, when we press a directional button, we want the ball to move in that direction. So click the button that says Add Event and choose Key Press and then choose . This way, on event Key Press: Down, it will do what we want it to do. In our case, we want it to move down. Now we get into the important part of this: the Actions. On the far right, there will be a bunch of little things that look like buttons, with a bunch of tabs beside it. If the Move tab isn't already selected, then select it, and find the button with arrows pointing every direction. Now click and drag it into the white box, and a new box will pop up, asking for parameters. In the "Applies To..." box, the radio button "self" is selected to show that it will move itself. Below that there will appear a bunch of little arrows, one for each direction. Now a little explanation is necessary. You can choose more than one direction, but then it will select one at random and move in that direction. But for now, we want it to move down when we press Down. So click Down.

Repeat for the other directions, because I'd have this thing five pages long if I repeated myself three more times.

Now, it will move in any direction when you press a button! Or it would, if you had a place to put it. Now we get into rooms. Click on the Rooms folder and press Insert. This opens the (you guessed it) Room Properties dialog box. You don't have to worry about putting down floor tiles yet. If the objects tab at the top lefthand side isn't clicked, click it, and go straight down to where it says "Object to add with left Mouse button". Click the object you created and click somewhere on the grey area ONCE! And don't drag! This will place your "ball" object on the stage. Now you can go back and Test Play this to see it work!

...have you tried it yet? If you have I'm sure you realized that the ball doesn't stop. This is because we didn't tell it to! Ooops! Go back to your Object Properties dialog box and add an event: Key Release, Any Key. Then go to your Move Action and click the red box in the middle of the arrows. This will stop it when you release any button. Lovely!

Now, I'm sure you've wondered how you make a walking animation for when he's walking and stop when he stops. Well, it's just a matter of going back, making a lot more sprites, and changing them as we go. Also, we introduce variables! Weee! And yay! And stuff!

Part 2- Walking Graphics and correct stoppage.

I'm not going into graphics editing, but it's quite easy to figure out, just fool around with the Sprite Properties box. Once you have figured out how to make an animation, make a walking animation for each direction. NOTE: A good idea is to copy each frame 4 times. Then make a standing sprite for each direction. You could also do eight, but I'm still working out how to do diagonals, so that will be in my next tutorial.

Instead of having just the movement in the directional event, we will have to do a little working around. Under the Objects tab, there will be a dragbutton with a circle, a rectangle, and a triangle. Drag that on there before the movement. For the parameters, set the sprite of the character WALKING. That is, the little animation for that direction. Now go down to the Code tab. There will be a little dragbutton that has "Var" written on it. for the name, type in global.direction. (Actually, you can name it whatever you like, as long as it has global and a period in front of it. Then give it a value, which will represent the direction. A good idea for Rm2kers is to used the variable values used in RM2k (1=down, 4= up, 2=left, and 3= right, I think.) The "global." prefix will let your variable be used in different events. You'll see what it's for in a moment. Repeat this for the rest of the directions.

Now then, you can test play it. Wait a second! He must be Richard Simmons, because he walks in place even when I let go of the button! This is what the variable global.direction is for. Go to your Release Event. Under the Question tab, there will be a little octagon with the word Var on it. Drag this into the Actions box, and it'll pop up a Parameters box asking for a variable and a value and an operator. choose your global.direction variable and choose the value for, say, up. Click ok, and then drag that up-facing arrow into the Actions box below the Var octagon. This lets it know to operate this block of events when global.directions = 4. Now go to the Objects tab, and use the Change Sprite command to change the sprite into the standing sprite for that direction. As usual, repeat for the other directions. This will make the sprite stop when the button is released.


Now you will have a sprite that walks around, animates when it's moving, and stops when it stops moving. Kewl, huh? I thought not. But it's a start, and it should give you a good idea of how Game Maker handles events and actions and things like that. Thanks for reading, now go make some great games!