-
Notifications
You must be signed in to change notification settings - Fork 0
Tutorial Breakout
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!
- 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
First, we need to create the visual elements for our game.
- In the Assets panel, right-click on Sprites → Create Sprite
- Name it
spr_paddle - Draw a horizontal rectangle (about 64x16 pixels)
- Important: Click Center to set the origin to the center
- Create another sprite named
spr_ball - Draw a small circle (about 16x16 pixels)
- Click Center to set the origin
- Create a sprite named
spr_brick - Draw a rectangle (about 48x24 pixels)
- Click Center to set the origin
- Create a sprite named
spr_wall - Draw a square (about 32x32 pixels) - this will be the boundary
- Click Center to set the origin
- Right-click on Backgrounds → Create Background
- Name it
bg_game - Draw or load a background image
![]()
Now let's program the paddle that the player controls.
- Right-click on Objects → Create Object
- Name it
obj_paddle - Set the Sprite to
spr_paddle - Check the Solid checkbox
- Click Add Event → Keyboard → select Right Arrow
- Add the action Set Horizontal Speed
- Set value to
5(or any speed you prefer)
- Click Add Event → Keyboard → select Left Arrow
- Add the action Set Horizontal Speed
- Set value to
-5
The paddle keeps moving even after releasing the key! Let's fix that.
-
Click Add Event → Keyboard Release → select Right Arrow
-
Add the action Set Horizontal Speed
-
Set value to
0 -
Click Add Event → Keyboard Release → select Left Arrow
-
Add the action Set Horizontal Speed
-
Set value to
0
Now the paddle stops when you release the arrow keys.

- Create a new object named
obj_ball - Set the Sprite to
spr_ball - Check the Solid checkbox
- Click Add Event → Create
- Add the action Start Moving (Direction) (or Set Horizontal/Vertical Speed)
- Set a diagonal direction with speed
5- For example: hspeed =
4, vspeed =-4
- For example: hspeed =
This makes the ball start moving when the game begins.
- Click Add Event → Collision → select
obj_paddle - Add the action Reverse Vertical (to bounce)
- Click Add Event → Collision → select
obj_wall - Add the action Reverse Horizontal or Reverse Vertical as needed
- Or use both to handle corner bounces

- Create a new object named
obj_brick - Set the Sprite to
spr_brick - Check the Solid checkbox
- Click Add Event → Collision → select
obj_ball - Add the action Destroy Instance with target self
This destroys the brick when the ball hits it!
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:
- Go back to
obj_balland add: -
Add Event → Collision → select
obj_brick - Add action Reverse Vertical

- Create a new object named
obj_wall - Set the Sprite to
spr_wall - Check the Solid checkbox
That's all - the wall just needs to be solid for the ball to bounce off.

- Right-click on Rooms → Create Room
- Name it
room_game
- In the room settings, find Background
- Select your
bg_gamebackground - Check Stretch if you want it to fill the room
Now place your objects in the room:
-
Place the Paddle: Put
obj_paddleat the bottom center of the room -
Place the Walls: Put
obj_wallinstances 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!)
-
Place the Ball: Put
obj_ballsomewhere in the middle -
Place the Bricks: Arrange
obj_brickinstances in rows at the top of the room

- Click the Play button (green arrow)
- Use the Left and Right arrow keys to move the paddle
- Try to bounce the ball to destroy all the bricks!
- Press Escape to quit
Your basic Breakout game is complete! Here are some improvements to try:
- Add a No More Lives event to show "Game Over"
- Lose a life when the ball goes off the bottom
- Use Add Score action when destroying bricks
- Display the score with Draw Score
- Create more rooms with different brick layouts
- Use Next Room when all bricks are destroyed
- Add sounds for bouncing and brick destruction
- Use Play Sound action
| 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 |
- Beginner Preset - Events and actions used in this tutorial
- Event Reference - All available events
- Full Action Reference - All available actions