how to make a floor in game maker

How to Create a Floor in GameMaker Studio 2

By Hannah Anderson
AD

Creating an interactive floor within your GameMaker game is a rewarding task, allowing you to set the stage for your heroes or characters to traverse. This step-by-step guide will help you understand the process, from creating the floor object to setting it in motion. Let's dive right in!

Whether you're new to GameMaker or have prior experience, this tutorial will provide a solid foundation for creating floors. By the end, you'll be equipped to build terrain, platforms, and more, enhancing the playability and visual appeal of your game.

Creating the Floor Object

The first step in creating a floor is to define the floor object in GameMaker. Here, we'll create a simple 2D floor, but the principles can be extended to 3D environments or more complex assets.

AD
How to make a disco floor πŸ•Ί πŸ’ƒ
How to make a disco floor πŸ•Ί πŸ’ƒ
the floor plan for a room in a house
the floor plan for a room in a house
an image of a window with wooden shutters on the front and side of it
an image of a window with wooden shutters on the front and side of it

To begin, open GameMaker and prepare your workspace. Then, create a new object named 'Floor'.

Object Properties

In the Properties panel, set the 'Sprite' to a suitable floor image. Ensure the 'Depth' is set lower than other objects to ensure your floor appears at the correct layer. Set the 'Gravity' to 0 to prevent the floor from falling.

γ™γ‚„γ™γ‚„γƒ‰γƒƒγƒˆη΅΅γƒ‘γƒΌγ‚«γƒΌ
γ™γ‚„γ™γ‚„γƒ‰γƒƒγƒˆη΅΅γƒ‘γƒΌγ‚«γƒΌ
Layout for my fake game :}
Layout for my fake game :}
an animated floor trap is shown with the instructions to make it look like they have eyes
an animated floor trap is shown with the instructions to make it look like they have eyes

Add a 'Activate' event to your object. Here, set the 'X Speed = Left Ψ§Ω„Ψ³Ψ§Ψ―Ψ³Ψ©, X Speed = Right 6' to control horizontal movement. You can also adjust the 'Gravity' to allow the floor to move vertically, simulating a different environment like a zero-gravity area or a planet with high gravity.

Collision and Monitoring

Add a 'Collision' event with the player. Here, you can change the 'Y Speed' to 0, preventing the player from falling through the floor. You can also add alarms to monitor the player's position over the floor for special effects or power-ups.

AD

For a simple floor, that's all you need. However, you can expand this by adding more functionality, such as subtracting health when the player stands on the floor or actions triggered by the player's presence on the floor.

Wooden Floor - Isometric Tile Drawing Tutorial
Wooden Floor - Isometric Tile Drawing Tutorial
wood flooring is shown with instructions to make it look like they are made out of wood
wood flooring is shown with instructions to make it look like they are made out of wood
Pixel Art Wooden Flooring
Pixel Art Wooden Flooring
an info sheet showing the different types of windows
an info sheet showing the different types of windows
100 Minecraft Floor Designs (Tutorial)
100 Minecraft Floor Designs (Tutorial)
a floor plan for a house with furniture
a floor plan for a house with furniture

Setting the Floor in Motion

Now that you've created your floor object, let's make it dynamic by setting it in motion. This adds interactivity and a sense of action to your game.

A common approach is to create a scrolling effect, simulating the player moving forward or sideways. Here's how you can achieve this:

AD

Moving the Floor Horizontally

Create a 'Timer' event on your floor object and add the following code to move the floor horizontally:

// Scrolling speed x_speed = -2; if (place_meeting(x+5, y, obj_player)) { x_speed = 0; } else if (place_meeting(x-hsize/2, y)) { x_speed = 2; }

The 'x_speed' variable determines the scroll speed. The 'place_meeting()' function is used to detect collisions with the player and the edge of the floor. This allows the floor to stop scrolling when the player is at the center and reverses the scroll direction when the player or the edge is reached.

AD

Moving the Floor Vertically

To move the floor vertically, use a similar approach with 'y_speed'. Create a 'Timer' event and add the following code:

// Scrolling speed y_speed = 0; // Adjust this value for the desired speed if (place_meeting(x, y+hsize/2)) { y_speed = 0; } else if (place_meeting(x, y-hsize/2)) { y_speed = 0; }

-scroll velocidad--

The 'y_speed' variable determines the vertical scroll speed. The 'place_meeting()' function is used to detect collisions with the edges of the floor, ensuring the floor stops scrolling at the top and bottom edges.

You can adjust the speeds and add more conditions to create a more complex scrolling effect.

That's it! You've now created a dynamic floor in your GameMaker game. This hands-on guide should have equipped you with the skills to build more interactive and immersive environments. Keep practicing and expanding your skills. Happy gaming!

AD