Skip to content

Tutorial Breakout

Gabe1290 edited this page Sep 10, 2026 · 3 revisions

Tutorial: Create a Breakout Game

Home | Beginner Preset | Français

This tutorial will guide you through creating a classic Breakout game. It's a perfect first project for learning PyGameMaker!

Breakout Game Concept


What You'll Learn

  • Creating and using sprites
  • Setting up game objects with events and actions
  • Keyboard controls for player movement
  • Collision detection and bouncing
  • Destroying objects on collision
  • Building a game room

Step 1: Create the Sprites

First, we need to create the visual elements for our game.

1.1 Create the Paddle Sprite

  1. In the Assets panel, right-click on SpritesCreate Sprite
  2. Name it spr_paddle
  3. Draw a horizontal rectangle (about 64x16 pixels)
  4. Important: Click Center to set the origin to the center

1.2 Create the Ball Sprite

  1. Create another sprite named spr_ball
  2. Draw a small circle (about 16x16 pixels)
  3. Click Center to set the origin

1.3 Create the Brick Sprite

  1. Create a sprite named spr_brick
  2. Draw a rectangle (about 48x24 pixels)
  3. Click Center to set the origin

1.4 Create the Wall Sprite

  1. Create a sprite named spr_wall
  2. Draw a square (about 32x32 pixels) - this will be the boundary
  3. Click Center to set the origin

1.5 Create a Background (Optional)

  1. Right-click on BackgroundsCreate Background
  2. Name it bg_game
  3. Draw or load a background image

The Sprite Editor with spr_ball open, origin already centered


Step 2: Create the Paddle Object

Now let's program the paddle that the player controls.

2.1 Create the Object

  1. Right-click on ObjectsCreate Object
  2. Name it obj_paddle
  3. Set the Sprite to spr_paddle
  4. Check the Solid checkbox

2.2 Add Right Arrow Movement

  1. Click Add EventKeyboard → select Right Arrow
  2. Add the action Set Horizontal Speed
  3. Set value to 5 (or any speed you prefer)

2.3 Add Left Arrow Movement

  1. Click Add EventKeyboard → select Left Arrow
  2. Add the action Set Horizontal Speed
  3. Set value to -5

2.4 Stop When Keys Released

The paddle keeps moving even after releasing the key! Let's fix that.

  1. Click Add EventKeyboard Release → select Right Arrow

  2. Add the action Set Horizontal Speed

  3. Set value to 0

  4. Click Add EventKeyboard Release → select Left Arrow

  5. Add the action Set Horizontal Speed

  6. Set value to 0

Now the paddle stops when you release the arrow keys.

obj_paddle's Object Events panel: Keyboard (held) and Keyboard Release, two actions each


Step 3: Create the Ball Object

3.1 Create the Object

  1. Create a new object named obj_ball
  2. Set the Sprite to spr_ball
  3. Check the Solid checkbox

3.2 Set Initial Movement

  1. Click Add EventCreate
  2. Add the action Start Moving (Direction) (or Set Horizontal/Vertical Speed)
  3. Set a diagonal direction with speed 5
    • For example: hspeed = 4, vspeed = -4

This makes the ball start moving when the game begins.

3.3 Bounce Off the Paddle

  1. Click Add EventCollision → select obj_paddle
  2. Add the action Reverse Vertical (to bounce)

3.4 Bounce Off Walls

  1. Click Add EventCollision → select obj_wall
  2. Add the action Reverse Horizontal or Reverse Vertical as needed
    • Or use both to handle corner bounces

obj_ball's Object Events panel: Create, Collision with obj_paddle, Collision with obj_wall


Step 4: Create the Brick Object

4.1 Create the Object

  1. Create a new object named obj_brick
  2. Set the Sprite to spr_brick
  3. Check the Solid checkbox

4.2 Destroy on Ball Collision

  1. Click Add EventCollision → select obj_ball
  2. Add the action Destroy Instance with target self

This destroys the brick when the ball hits it!

4.3 Bounce the Ball

Reverse Vertical always applies to the instance whose event it's in — it has no "applies to other" option — so this needs to go on the ball, not the brick:

  1. Go back to obj_ball and add:
  2. Add EventCollision → select obj_brick
  3. Add action Reverse Vertical

obj_brick's Object Events panel: Collision with obj_ball, one action (Destroy Instance)


Step 5: Create the Wall Object

5.1 Create the Object

  1. Create a new object named obj_wall
  2. Set the Sprite to spr_wall
  3. Check the Solid checkbox

That's all - the wall just needs to be solid for the ball to bounce off.

obj_wall's Object Events panel: empty -- solid is all it needs


Step 6: Create the Game Room

6.1 Create the Room

  1. Right-click on RoomsCreate Room
  2. Name it room_game

6.2 Set the Background (Optional)

  1. In the room settings, find Background
  2. Select your bg_game background
  3. Check Stretch if you want it to fill the room

6.3 Place the Objects

Now place your objects in the room:

  1. Place the Paddle: Put obj_paddle at the bottom center of the room

  2. Place the Walls: Put obj_wall instances around the edges:

    • Along the top
    • Along the left side
    • Along the right side
    • Leave the bottom open (this is where the ball can escape!)
  3. Place the Ball: Put obj_ball somewhere in the middle

  4. Place the Bricks: Arrange obj_brick instances in rows at the top of the room

The Room Editor with walls around three edges, three rows of bricks, the paddle near the bottom, and the ball in the gap between them


Step 7: Test Your Game!

  1. Click the Play button (green arrow)
  2. Use the Left and Right arrow keys to move the paddle
  3. Try to bounce the ball to destroy all the bricks!
  4. Press Escape to quit

What's Next?

Your basic Breakout game is complete! Here are some improvements to try:

Add a Life System

  • Add a No More Lives event to show "Game Over"
  • Lose a life when the ball goes off the bottom

Add Scoring

  • Use Add Score action when destroying bricks
  • Display the score with Draw Score

Add Multiple Levels

  • Create more rooms with different brick layouts
  • Use Next Room when all bricks are destroyed

Add Sound Effects

  • Add sounds for bouncing and brick destruction
  • Use Play Sound action

Summary of Objects

Object Sprite Solid Events
obj_paddle spr_paddle Yes Keyboard (Left/Right), Keyboard Release
obj_ball spr_ball Yes Create, Collision (paddle, wall, brick)
obj_brick spr_brick Yes Collision (ball) - Destroy self
obj_wall spr_wall Yes None needed

See Also

Clone this wiki locally