What this is
This repo holds the full source for Block Breaker, made by Yosef Setiawan. Everything lives in one script with no image or sound files, so you can read it top to bottom. The game draws every shape itself, and the settings you are most likely to change sit in a block of named constants at the top.
Move the paddle, launch the ball, and clear every brick to move on. Each new level adds rows, makes bricks take more hits, and speeds up the ball.
Controls
| Input | Action |
|---|---|
| Mouse | Move the paddle |
| ← → | Move the paddle with the keyboard |
| Space or click | Launch the ball |
| Esc | Pause and resume |
| Space or Enter | Play again after Game Over |
Powerups
About one in four destroyed bricks drops a powerup, and the first brick you break each round always does. Catch it with the paddle to activate it.
Explode
The ball blasts every brick within 90 pixels of the brick it hits. It wears off the first time the ball touches a wall.
Pierce
The ball passes through bricks instead of bouncing. Each brick can be hit once per second, and the effect ends after two wall bounces.
Split
On your next paddle hit, two small clone balls launch beside the main ball. Clones vanish if the main ball is lost.
Auto-aim
Not a drop. When 10 or fewer bricks remain, the ball curves toward the nearest one and it gets a yellow outline.
Levels, lives and score
- You start with 3 lives. Losing the main ball costs one and resets the round.
- Level 1 has 5 rows. Each level adds a row, up to 14.
- Every brick takes as many hits as the level number. Bricks darken and show white dots for hits left.
- Ball speed starts at 5.5 and rises by 0.4 per level, capped at 12.
- Each brick scores 10 × level. Clearing a level adds a bonus of 100 × level.
- Your best score is shown during the session.
Run it
You need Python 3 and Pygame.
pip install pygame
python block_breaker.py
Replace block_breaker.py with the name of the script in this repo. The game opens an 800 × 650 window.
Make it your own
Edit these constants near the top of the script, then run it again.
FPSframe rate (default 30)PADDLE_Wpaddle widthBALL_RADIUSball sizeBLOCK_COLSbricks per rowINITIAL_SPEEDball speed at level 1SPEED_INCREMENTspeed gained per levelMAX_SPEEDspeed capLIVES_STARTstarting livesAUTO_AIM_THRESHOLDbricks left before auto-aim startsAUTO_AIM_STRENGTHhow hard the ball steersPOWERUP_CHANCEdrop chance per brickEXPLODE_RADIUSblast size in pixelsPIERCE_WALL_LIMITwall bounces before pierce endsROW_COLORSbrick colors