A simple tutorial of controlling your character

  • XBuster
  • 04/10/2015 12:46 AM
Hello everyone,I decided to create my own tutorial series for the wandering game maker developer. Although I'm still learning a lot about game maker myself, I would like to share my current knowledge and prevent people from going through the sea of trouble I went through developing my game(s) over the years.

In this lesson, you will learn how to control your character and make contact with the floor. My goal is to make all tutorials as simple as possible so even the beginners can get the material and start creating their own amazing games. Most sections will include a game maker file for visual learners.

  • Usage of Gravity

  • Landing

  • Moving Left and Right

  • Jumping(normally and with variables)

Step 1:Gravity

What comes up, must come down. The key to gravity is thinking about what is going on. When the object is airborne, we want it to fall until it collides with the floor or another object. To do this, create an object and name it "player"or something. Go to the "Add Event" button in the object and click the "Step"Event.

When you click the step event. go into the "Control" tab on the right hand side and drag the "Execute Code" command into the "Actions" space to your left. Within the text, type or copy this code in...

if place_free(x,y+1)


I bet you're asking what does this mean? Well, its simple actually. The code is saying if you don't have a collision beneath you that is SOLID, then fall. If you don't understand the gravity direction, this is a variable that tells where to fall in degrees relative to a circle. 270 in this case is downward. For extra, 90 is upward, 0/360 is right, and 180 is left.

STEP 2:Landing

Now that your character is able to fall, you need to create a floor object. Both your character and floor sprite should be boxes at even values. A sprite value of 16x16 or 32x32 should be perfect for this example.To keep things simple, go to your floor object and check it as solid. Your player however, is NOT solid. In the Add Event action on your player object, click "Collision" and choose the object you want to collide with(in this case the floor object).

Now, go to the "Control" tab and drag another code icon and type in this

if place_free(x,y+0)

Now, you'll come in contact with the floor in any direction.

STEP 3:Moving around

When moving around in 2-Dimensional platform games, you have two main directions(Left and Right). To move right, type in this code in the "Keyboard Event" and type these codes in...

//Moving Right Keyboard Event
if place_free(x+4,y)
//Moving Left Keyboard Event
if place_free(x-4,y)

STEP 4:Jumping

It wouldn't be a platform game if you couldn't jump, this is an important step!!
To jump, simply select a key press event of your choice and put this code in...

if place_free(x,y+1)=false

That's it for this section! Movement is not as hard as you think. If you are a visual learner, here is an example. This will work in GM Lite as well. If you have any questions, feel free to ask. For the next lesson, you will learn about platforms. Until then, feel free to download the file below. Thank you!

Tutorial 1 Game Maker File


Pages: 1
Thanks for the tutorial. It really helps having someone direct you in the right direction. So Thanks again for the tutorial!
Thanks for the tutorial. It really helps having someone direct you in the right direction. So Thanks again for the tutorial!

Anytime man! I've been meaning to create more of these, I just have to categorize all of them. There is a bunch more to learn, so there will be plenty more within the year. Glad you enjoyed it :)
Pages: 1