Skip to content

Sprites, Objects,and Rooms

Sprites: Creating Visual Elements

Sprites are the pictures that show what your game characters and objects look like. In this section, we’ll learn how to make and edit these pictures, called sprites, using a tool in Game Maker Studio called the Sprite Editor. Instead of using ready-made pictures, we’re going to draw our own to spark our creativity and help us learn how to use the tools better.

How to Create a Sprite

  1. Open the Sprite Editor:

    • Find the “Sprites” folder on the left side of the screen.
    • Right-click on it and select “Create Sprite.” A new sprite will appear.
  2. Name Your Sprite:

    • Give your sprite a name that tells what it is, like spr_pacman for Pac-Man or spr_ghost for a ghost.
  3. Edit the Image:

    • Click on the “Edit Image” button to start drawing your sprite. This will open the Sprite Editor, where you can create your picture.

Tools for Drawing Sprites

The Sprite Editor has different tools to help you draw your sprites. Here’s how to use some of the main ones:

  1. Paint Tool:

    • The Paint Tool is like a digital paintbrush. You can pick a color and draw freehand on the canvas (the blank area where you draw).
    • You can make the brush bigger or smaller using the toolbar at the top.
  2. Eraser Tool:

    • The Eraser Tool works like a digital eraser. It helps you fix mistakes or make changes by removing parts of your drawing.
    • You can change the size of the eraser just like you can with the Paint Tool.
  3. Line Tool:

    • The Line Tool lets you draw straight lines. Just click where you want the line to start, drag to where you want it to end, and then let go.
  4. Rectangle Tool:

    • The Rectangle Tool is for drawing squares and rectangles. You can choose to make the rectangle just an outline or fill it with color.

Drawing Our Sprites

Now that you know how to use the tools, let’s start drawing the characters and items for our game!

Drawing Pac-Man

  1. Create a New Sprite:

    • Name it spr_pacman.
    • Open the Sprite Editor and choose a small canvas size, like 32x32 pixels, which is a good size for our game.
  2. Draw Pac-Man:

    • Use the Paint Tool to draw a yellow circle. This will be Pac-Man’s body.
    • Use the Line Tool to draw a triangle cut-out to make Pac-Man’s mouth, so it looks like he’s always chomping.

Drawing the Ghosts

  1. Create Four New Sprites:

    • Name them spr_ghost_red, spr_ghost_pink, spr_ghost_blue, and spr_ghost_orange.
    • Open each sprite in the Sprite Editor with a canvas size of 32x32 pixels.
  2. Draw the Ghosts:

    • Use the Paint Tool to draw each ghost in its own color. Start with a round top and a wavy bottom for the ghost’s body.
    • Draw eyes on each ghost using the Paint Tool, with white for the eyeballs and blue or black for the pupils, so the ghosts look like they’re watching Pac-Man.

Drawing Power Circles

  1. Create a New Sprite:

    • Name it spr_powercircle.
    • Use a smaller canvas size, like 16x16 pixels.
  2. Draw Power Circles:

    • Draw a small, white circle. This will be the power-up that Pac-Man collects in the game.

Drawing the Maze

  1. Create a New Sprite:

    • Name it spr_maze.
    • Use a larger canvas size, like 256x256 pixels, for the maze.
  2. Draw the Maze:

    • Use the Line Tool or Rectangle Tool to draw the maze’s walls. Make sure the paths are wide enough for Pac-Man and the ghosts to move through.

Tips for Drawing Sprites

  • Use Consistent Colors: Try to use the same colors throughout your game to make it look nice and uniform.
  • Keep It Simple: Simple drawings often work best, especially for small sprites, where too much detail can be hard to see.
  • Experiment: Don’t be afraid to try different ideas! You can always erase and try again.

By following these steps and using the tools in the Sprite Editor, you’ll create the characters and items you need for your Pac-Man game. Next, we’ll learn how to make these sprites move and interact in the game!


Objects: Bringing Sprites to Life

Objects are what make the pictures (sprites) in your game come alive. They’re like the characters and items that do things in your game, like moving around or collecting points. In this section, we’ll learn how to create objects in Game Maker Studio, give them their sprites, and make sure they interact correctly in the game.

How to Create an Object

  1. Open the Object Editor:

    • Find the “Objects” folder on the left side of the screen.
    • Right-click on it and select “Create Object.” A new object will appear.
  2. Name Your Object:

    • Give your object a name that makes it clear what it is, like obj_pacman for Pac-Man or obj_ghost_red for the red ghost.
  3. Set the Sprite:

    • In the Object Editor, choose the sprite you made earlier from the dropdown menu to give your object its picture.
  4. Set the Collision Mask:

    • In the Properties Panel, set the “Collision Mask” to “Precise (slow).” This makes sure that when objects touch each other, the game knows exactly where they’ve collided.

Making Objects for Our Sprites

Now let’s create objects for all the sprites we’ve drawn. Each object will use a sprite and interact with the other objects in the game.

Creating the Pac-Man Object

  1. Create a New Object:
    • Name it obj_pacman.
    • Assign the spr_pacman sprite to this object.
    • Set the collision mask to “Precise (slow).”

Creating the Ghost Objects

  1. Create Four New Objects:
    • Name them obj_ghost_red, obj_ghost_pink, obj_ghost_blue, obj_ghost_orange.
    • Assign the corresponding ghost sprites to these objects.
    • Set the collision mask to “Precise (slow).”

Creating the Power Circle Object

  1. Create a New Object:
    • Name it obj_powercircle.
    • Assign the spr_powercircle sprite to this object.
    • Set the collision mask to “Precise (slow).”

Creating the Maze Object

  1. Create a New Object:
    • Name it obj_maze.
    • Assign the spr_maze sprite to this object.
    • Set the collision mask to “Precise (slow).”

Level 1 Exercises

  • Exercise 1: Create objects for Pac-Man, the power circles, the maze, and the ghosts in Game Maker.
  • Exercise 2: Assign the correct sprites to the Pac-Man, power circles, maze, and ghosts objects you created.

Level 2 Exercises

  • Exercise 1: Create the objects for the game you planned in Game Maker.
  • Exercise 2: Assign the correct sprites to the objects you created for the game you planned.

Level 3 Exercises

  • Exercise 1: Create the objects you planned for your game and assign the necessary sprites, then use Game Maker Language to show information about the objects.

Rooms: Building the Game Environment

Rooms are the places where your game happens, like the levels or stages. They’re where you put the objects, like Pac-Man, the ghosts, and the maze. In this section, we’ll learn how to create rooms in Game Maker Studio, add objects to them, and adjust their sizes if needed. We’ll also learn how to run the game to see how everything works together.

How to Create a Room

  1. Open the Room Editor:

    • Find the “Rooms” folder on the left side of the screen.
    • Right-click on it and select “Create Room.” A new room will appear where you can start building your game level.
  2. Name Your Room:

    • Give your room a name like rm_level1 so you know which level it is.

Adding Objects to the Room

After creating a room, it’s time to fill it with the objects you made earlier, like Pac-Man,

the ghosts, and the maze.

  1. Open the Room:

    • Double-click on your room (e.g., rm_level1) to open the Room Editor. This will show a grid where you can place your objects.
  2. Add Objects:

    • Find the “Instances” layer, which is where you put the objects in your room.
    • Drag and drop objects like obj_pacman, obj_ghost_red, and obj_powercircle into the room.
  3. Positioning Objects:

    • Place Pac-Man where you want him to start, arrange the ghosts in different spots, and put the power circles around the maze. Make sure the paths are wide enough for Pac-Man and the ghosts to move around.

Level 1 Exercises

  • Exercise 1: Add the Pac-Man object, at least 10 power circle objects, a maze object, and the ghost objects to the room in Game Maker.

Level 2 Exercises

  • Exercise 1: Add all the objects that you planned for your game to the room in Game Maker.

Level 3 Exercises

  • Exercise 1: Use Game Maker Language to create a script that shows information about the objects in the room.

Running the Game

Now that your room is set up with all the objects, it’s time to test your game!

  1. Compile and Run:

    • Click the green “Play” button at the top of the screen to start your game. This will turn your game project into something you can play.
  2. Test and Fix:

    • Play the game and see how it looks and works. Make sure everything is in the right place and working as it should. If something needs fixing, go back and make changes in the Room Editor, then test it again.

Summary

In this section, we learned how to create rooms, add objects, and test your game’s environment. These steps are the building blocks for your game, making sure everything is set up and working right. In the next chapter, we’ll learn how to make your objects move and interact, bringing your game to life!

Practice on Kahoot

Vocabulary Review

TermDefinition
Game MakerA tool that helps you create your own video games without having to know a lot of coding. It’s like a workshop where you can build games using blocks and instructions. (E)
SpritesPictures or characters that you see in a game. Sprites can be anything, like a hero, a bad guy, or a coin you collect. (B)
ObjectsThings in a game that can do stuff, like move, bounce, or disappear. They use sprites to look like characters or items. (D)
EventsActions that happen in the game, like when you press a button, touch an object, or collide with a wall. They tell the game what to do when something happens. (A)
RoomsThe different levels or places where your game happens, like a playground or a spooky cave. It’s where the game objects live and interact. (C)