[go: up one dir, main page]

0% found this document useful (0 votes)
46 views1 page

Game Maker

Uploaded by

lalisanina10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views1 page

Game Maker

Uploaded by

lalisanina10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Vitrina Tutoriales Comunidad Blog DOWNLOAD

MAKE YOUR FIRST PLATFORMER IN GAMEMAKER


Guselect | 12 de septiembre de 2024 | Principiante | Complete Game | Getting Started

Let's create a game together! It's going to be a simple platform game where you have to dodge spikes and reach the flag!

This will be the end result:

0:00 / 0:10

Even though it's simple, it'll be a great introduction to GameMaker! You can also follow along the video:

We'll start by creating a new blank project. Once you create your project there's quite a lot to explore, but don't worry! For now
focus on the Asset Browser on the right side of the screen:

This is where all the assets of your game will be, like sprites, sounds, and objects. For this project, we will only use sprites, objects,
and rooms.

You can delete the unused folders if you want, which is what I'm going to do here.

WORKING WITH SPRITES


First, let's talk about sprites. Sprites are the images in your game. They represent your character, enemies, items, and even the
background.

Let's create a sprite! Right-click on the empty space, go to Assets, select "Create Sprite" and name it sPlayer. You can name it
whatever you want, but I usually go with sPlayer for the player sprite.

I recommend that you create your own sprite, but for this tutorial, I already prepared mine. I'll click "Import" and import my sprites
into the game:

(Click here to download my sprites, that you can also import!)

Next, let's create more sprites. Right-click on the sprites folder and select "Create -> Sprite". I'll create a sprite for each object of
the game:

WORKING WITH OBJECTS


Now let's move on to objects! In objects you define the behavior and interactions of your sprites.

We'll create one object for each sprite we made. Right-click on the Objects folder and select "Create -> Object".

Name this oPlayer and assign the player sprite to this object.

The area on the right is the event window where you write the code for your object. This is where you decide what happens when
the character touches an enemy, picks up an item, advances to the next level, and more!

For now, let’s just create the other objects:

To each object we will assign its corresponding sprite.

WORKING WITH ROOMS


Now, let's set up our game level. Open the “Rooms” folder and double-click Room1. This will show a black grid which is your level:

The default room size is quite large, so let's change it to 320 by 180 in the Inspector, on the bottom left corner of the screen:

If you don't see this menu, click on your room (Room1) in the Asset Browser and it should appear.

Adjust the zoom and place your objects on the screen. This is done by selecting an object from the Asset Browser, and holding
"Alt" (or Option on Mac) to paint them in the level. Or, you can drag the objects one-by-one.

The objects snap to the grid, which is too large, so change the grid size to 16 by 16 pixels:

Now place the player, ground, some spikes, and the flag.

WRITING CODE FOR PLAYER MOVEMENT


Now we need to write some code. Add a Create Event to oPlayer:

If you get a choice between GML Code and GML Visual on this step, choose GML Code.

This code runs as soon as the object is created, which is when the game starts.

We'll write a function to set the game window size to 720p:

window_set_size(1280, 720);

Next, create two variables for horizontal and vertical speed, both set to zero:

xsp = 0;
ysp = 0;

Add a Step Event to handle player movement, this event runs every frame.

Let's write some code to give our character gravity by applying a downward vertical force. We'll also make sure the player remains
stationary when no keys are pressed:

ysp += 0.1
xsp = 0

Now let's add the movement code, checking if the left or right key is being pressed and manipulating the horizontal speed of our
object:

if keyboard_check(vk_left)
{
xsp = -1
}

if keyboard_check(vk_right)
{
xsp = +1
}

Let's make our character jump! We'll check if the character is on the ground using place_meeting.

In this code snippet, when the player is on the ground, their vertical speed is zero and if the player presses the up key, they jump:

if place_meeting(x, y+1, oSolid)


{
ysp = 0
if keyboard_check(vk_up)
{
ysp = -2
}
}

Lastly, we will enable the player to move and interact with oSolid:

move_and_collide(xsp, ysp, oSolid)

Read the move_and_collide() manual page for more info.

TESTING AND ADDING LEVELS


Click "Play" or press F5 to test the game. You should be able to move the character:

0:00 / 0:10

However, the character still doesn't die when touching the spikes, or proceed to the next level! We need to add collision
detection with the flag and the spikes.

Include the following code in the Step event, it will make the character transition to the next room when touching oFlag and
reset the current room if it touches oSpike:

if (place_meeting(x, y, oFlag))
{
room_goto_next();
}
if (place_meeting(x, y, oSpike))
{
room_restart();
}

Run the game, and you can now lose from the spikes, or reach the flag to win.

However, when you win, the game crashes: this happens because there is no next level to move to.

So, all that's left now is to create more levels! But before that, let's try to make the game a bit prettier.

CREATING THE BACKGROUND


To make the game look better, I will create a background sprite. It will be a simple 32x32 sprite (you can import this from the
package download given before):

Assign this sprite to the room's "Background" layer and make it tile horizontally and vertically. You can also change its color and
add effects to make it look nicer:

0:00 / 0:08

ADDING MORE LEVELS


Right-click on the room and duplicate it to create a new level:

Rename it to Room2. Add more spikes, move the flag, and change the background color. Just do the same thing with a few
more rooms and you should have a complete game!

0:00 / 0:12

CONCLUSION
This is a very simple game, made to introduce you to GameMaker. Many things here weren't the most optimized, but they were
done in the simplest, most understandable way.

Keep working on your projects, and feel free to expand this game with animations, new mechanics, and more!

What’s next: You’ll notice the game still crashes on finishing the last level. What if you added a game end screen with a button to
take you back to Room1? (Tip: Repurpose the “Play” button created in that video to make a “Play again” button!)

Happy GameMaking!

ATRÁS TUTORIALES

GameMaker Apoya Equipo Redes sociales Parte de Opera


Descargar Manual Acerca de nosotros

Funciones Notas de lanzamiento Empleo

Precios Centro de Ayuda Contacto

Mercado Reportar un Bug

Paquetes de Assets Blog

Guia Cuentas

Educación

Merch

Jurídico Política de Privacidad Política de Cookies y Preferencias Derechos de autor © 2013-2024 YoYo Games Ltd.

You might also like