gamemaker how to make a platformer

"Gamemaker Platformer Guide: Step-by-Step Tutorial"

By Jessica Martinez
AD

Embarking on the journey of creating a platformer game can be an exciting and rewarding experience. With the right tools and guidance, you can bring your imagination to life and craft an engaging gaming experience. In this comprehensive guide, we'll explore the process of creating a platformer using GameMaker, a powerful and user-friendly game engine.

GameMaker Studio 2 offers a drag-and-drop interface along with a scripting language, GML, enabling both beginners and experienced developers to build complex games with ease. To create a platformer, you'll use a combination of these features to design your game's mechanics, art, and overall world. By the end of this guide, you'll have a solid understanding of how to make a platformer in GameMaker and be well on your way to building your own unique gaming experience.

Setting Up Your Project

Before diving into the creative process, it's crucial to set up your project correctly. Opening GameMaker Studio 2, you'll see the welcome screen. Click on "New" to create a new project. Name your project, choose the appropriate folder, and select "2D" as the game type since we're creating a 2D platformer.

AD
GameMaker: Studio 1.4 - Platformer Tutorial
GameMaker: Studio 1.4 - Platformer Tutorial
Game Maker Studio: In-depth Platformer Tutorial
Game Maker Studio: In-depth Platformer Tutorial
Basic Platformer Mechanics in GameMaker: Studio ⋆ Nikles dabbling in Game Dev
Basic Platformer Mechanics in GameMaker: Studio ⋆ Nikles dabbling in Game Dev

Once your project is created, you'll notice the workspace is divided into several panels. Familiarize yourself with the following key areas: File Structure, Assets, Creation, World, and the Main Panel. The File Structure panel displays the project's files and folders, while the Assets panel holds your game's resources like images, sounds, and scripts. The Creation panel is where you'll design game objects and their behaviors, and the World panel is where you'll design your game's levels.

Creating Your First Game Object

To begin creating your platformer, let's start by making the player character. Right-click in the Assets panel and select "Create Object...". Name your object "Player" and click "Create Object and Open". In the Object Editor, you'll see the object's properties and events. We'll start by defining the player's appearance.

GameMaker: Studio 1.4 - Platformer Tutorial
GameMaker: Studio 1.4 - Platformer Tutorial
Design 2D Platformer Levels Effortlessly | GameDev | Eledris
Design 2D Platformer Levels Effortlessly | GameDev | Eledris

Click on the " documentaire.png" icon under the "Sprite" category to open the Sprite Editor. Choose or draw your player character's sprite. Once done, click "OK" to return to the Object Editor. Now, let's give your player character some basic movement behaviors.

Implementing Basic Player Movement

In the Object Editor, you'll find the "Create Event" in the Events panel. This event is triggered once when the object is created. In this event, add the following code to give your player character basic left and right movement:

AD
if keyboard_check(vk_left) { x -= 4; } if keyboard_check(vk_right) { x += 4; }

This script checks if the left or right arrow keys are pressed and moves the player character accordingly.

Creating Platforms and Background

With the player character created, let's move on to designing the game's levels. For this, we'll create a platform object and some background layers.

Create a new object called "Platform", open it, and assign it a rectangle sprite for now. Position this object in the World panel at the desired coordinates to create your first platform. You can duplicate this object to create more platforms and vary their shapes and sizes.

AD

Creating Background Layers

To create a background layer, right-click in the World panel and select "Create Background...". Name your background layer, choose a color or image for the background, and click "Create". You can duplicate and reposition background layers to create different section backgrounds in your game.

Now, let's add some basic functionality to our platform. In the "Collision Event" of the "Platform" object, add the following code to stop the player on top of the platform:

if place_meeting(x,y+1,obj_player) && yspeed > 0 { yspeed = 0; y = y - sprite_height(); instance_destroy(); }

This script checks if the player is on top of the platform and if they're falling (y-speed is greater than 0). If both conditions are true, the script stops the player's vertical motion and destroys the platform instance, creating a seamless platform experience.

AD

Implementing Gravity and Jumping Mechanics

Let's add gravity and jumping functionality to our player character. In the "Step Event" of the "Player" object, add the following code to apply gravity:

if yspeed < 10 { yspeed++ }

This script increases the player's vertical speed (yspeed) by 1 each step, simulating gravity. Now, let's add jumping functionality. In the "Collision Event" of the "Player" object, add the following code:

if keyboard_check_pressed(vk_space) && yspeed == 0 { yspeed = -15; }

This script checks if the spacebar is pressed and if the player is on the ground (y-speed is 0). If both conditions are true, it propels the player upwards with a velocity of -15.

Adding Enemies and Collectibles

To make your platformer more engaging, let's add enemies and collectibles. Create a new object called "Enemy", assign it a sprite, and position it in the World panel. For this example, we'll make a simple left-right moving enemy. In the "Step Event" of the "Enemy" object, add the following code:

if x < 50 { dx = 1; } if x > 700 { dx = -1; }

This script makes the enemy move left and right between two points (50 and 700 in the x-coordinate). To make your player character interact with enemies, you can add a collision event in the "Player" object that damages or jumps over the enemy.

For collectibles, create a new object called "Collectible", assign it a sprite (like a coin or gem), and position it in the World panel. To make the collectible disappear when the player touches it, add the following code to the "Collision Event" of the "Collectible" object:

instance_destroy();

To track the number of collectibles the player has picked up, you can create a global variable in the "Create Event" of the "Player" object:

collectibles = 0

Then, update this variable in the "Collision Event" of the "Player" object when the player collects a collectible:

collectibles += 1;

Embarking on the journey of creating a platformer game is an exciting creative process. With the guidance provided in this guide, you now have a solid foundation in GameMaker to begin building your unique platformer game. The possibilities are endless, so keep experimenting, learning, and expressing your imagination through your creations. Happy game making!

AD