·

Simple Top-Down Movement

Top-down movement is one of the most common systems you’ll build in GameMaker.
The goal is simple: read player input and move the character smoothly in 8 directions.

Try It Out!

Let’s build a solid, flexible version you can reuse in any project.

Step 1: Read Player Input

First, we check which directional keys are being pressed.

var move_x = keyboard_check(vk_right) - keyboard_check(vk_left);
var move_y = keyboard_check(vk_down)  - keyboard_check(vk_up);

This gives us a direction vector based on input:

Step 2: Normalize the Direction

If the player is moving, we normalize the direction so it behaves consistently in all directions.

if (move_x != 0 || move_y != 0)
{
    var distance = point_distance(0, 0, move_x, move_y);
    move_x /= distance;
    move_y /= distance;
}

This keeps movement smooth and predictable no matter which keys are held.

Step 3: Apply Movement Speed

Now we apply speed once, using the direction we calculated.

var move_speed = 4;

x += move_x * move_speed;
y += move_y * move_speed;

That’s it! Now you’ve got clean, responsive top-down movement.

Where to Put This Code

This code typically lives in the Step Event of your player object.

Here’s the whole code just so you have it in one spot:

var move_x = keyboard_check(vk_right) - keyboard_check(vk_left);
var move_y = keyboard_check(vk_down)  - keyboard_check(vk_up);

if (move_x != 0 || move_y != 0)
{
    var distance = point_distance(0, 0, move_x, move_y);
    move_x /= distance;
    move_y /= distance;
}

var move_speed = 2;

x += move_x * move_speed;
y += move_y * move_speed;

You can also replace keyboard_check with:

The structure stays the same.

Why This Works Well

This approach:

Once you’re comfortable with this setup, you can layer on:

Next Steps

Try extending this by:

This foundation will carry you through a lot of games.