Skip to content

sarev/breakout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Breakout

A modern, Pygame-based take on the classic brick-breaker. Clear all destroyable bricks while keeping the blue “hero” ball in play. Power-ups, lasers, inversion, and multi-ball keep things lively.

Illustration

Features

  • Six handcrafted levels with per-level brick layouts
  • Multiple brick types with unique effects and hit points
  • Bonus balls, extra bats, control inversion, laser mode, and blackout mode
  • Stereo-panned sound effects
  • Multi-monitor aware with dynamic resizing
  • Smooth intro scene with perspective-warped card and animated balls

Requirements

  • Python: 3.10 or newer
  • OS: Windows, macOS, or Linux with a working SDL2 video driver

Python packages

Installed via pip:

  • pygame – rendering, input, audio
  • opencv-python – intro image warping
  • numpy – array ops and masks

Dependencies

pygame>=2.5
opencv-python>=4.9
numpy>=1.24

Note: this game is also compatible with Pygame Community Edition. If you would prefer to use that, simply replace pygame with pygame-ce in the installation process.

Installation and Setup

# 1) Create a virtual environment (recommended)
python -m venv .venv

# 2) Activate the virtual environment
# Windows
.venv\Scripts\activate
# macOS/Linux
source .venv/bin/activate

# 3) Ensure the 'pip' tool is up to date
python -m pip install -U pip

# 4) Install dependencies
pip install pygame opencv-python numpy

Running the game

# 1) Activate the virtual environment (if you haven't already done so)
# Windows
.venv\Scripts\activate
# macOS/Linux
source .venv/bin/activate

# 2) Start the game
python breakout.py

You can also pass the --ratio (or -r) parameter to scale the graphics down by a specified amount, e.g.

python breakout.py -r 4

will down-scale all of the graphics by a factor of four (horizontally and vertically). Higher values give more retro vibes! If your machine struggles to play Breakout smoothly at full resolution, increasing the -r parameter should reduce CPU load.

Monitor selection

If you have multiple monitors, you can pass the --monitor (or -m) parameter to specify the desired monitor number (with 0 being the primary display).

python breakout.py -m 2

If this parameter isn't passed and there are multiple monitors detected, you will see a monitor selection icon in the top-left of the intro screen. Clicking this will move the game to each monitor in turn.

How to play

  • Goal: Destroy all destroyable bricks in a level without losing all of your lives.
  • Lives: You lose one life each time the blue hero ball falls off the bottom. Some bricks grant extra lives.
  • Levels: Clear a level to advance.

Controls

  • Mouse: Move the bat horizontally
  • Left click: Speed all the balls up a little
  • Space: Pause or resume
  • Q / Esc: Quit
  • Intro screen: Move the mouse over the menu to select a difficulty, then click or press any key

Brick types

Brick Type Description
Blue Blue Standard; no effect
Red Red Spawns a temporary red bonus ball
Green Green Adds a temporary extra bat
White star White star Grants an extra life
Black hole Black hole Temporarily darkens the screen
Yellow arrows Yellow arrows Temporarily reverse controls
Cracked fire Cracked fire Destroys neighbouring bricks (cascade)
Metal Metal Indestructible
Warning triangle Warning triangle Enables laser mode for a duration

Different brick types require different numbers of hits to destroy. If no brick is destroyed for a while, an extra bonus ball is introduced.

Troubleshooting

  • No video device / SDL errors (Linux): Ensure you are in a graphical session and SDL2 can open a display. On headless systems set up Xvfb or Wayland appropriately.
  • OpenCV import errors: Use opencv-python wheels rather than opencv. On some Linux distros you may need system OpenGL packages.
  • Fonts missing: The code uses the default Pygame font; if you change it (e.g. to a system font), ensure it is installed.
  • DPI scaling quirks (Windows): The game queries monitor DPI in a subprocess. Ensure python is on PATH and dpi_subproc.py is accessible next to your main script.

Credits


Dedicated to Helena and Karen.

About

A modern, Pygame-based take on the classic brick-breaker.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages