Match 3 — Full Powerup Edition

A single-file Match-3 puzzle game built with Python and Pygame. Swap gems, build powerups, fuse them into bigger blasts, and clear every layer of the board to win.

Python 3 Pygame Single file: match3.py Mouse only Saved high score
Screenshot of the game: an 8 by 8 board of colored gems on green and purple tiles, with powerup gems showing cross and square symbols
Powerup gems glow with a colored ring and show a symbol inside.

About this project

A classic swap-and-match game with a twist: the board is also a puzzle.

Under the gem grid sits a layer of tiles. Every gem you clear damages the tile beneath it, and you only win once every tile in the center 6×6 area has been completely cleared. That turns a simple match game into a small strategy puzzle: where you clear matters as much as how much you clear.

Powerups

Special matches spawn Line, Color and Area bombs that you can fire on demand.

Fusions

Swap two powerups together for a stronger combined effect, up to wiping the whole board.

Scalable challenge

Pick 1–10 gem colors and 1–50 tile layers. Beat a level and jump straight to the next.

How to play

Mouse only. Press ESC any time to return to the menu.

  1. Select a gem. Click a gem and a yellow ring appears around it.
  2. Swap it. Click an adjacent gem to swap the two. If the swap makes no match, the gems slide back.
  3. Match 3 or more. Line up three or more gems of the same color in a row or column to clear them. Gems fall, new ones drop in, and chains score extra.
  4. Break the tiles. Each cleared gem removes one layer from the tile under it. Only the center 6×6 tiles have layers; the outer border starts already cleared.
  5. Win. Clear every layer in the center 6×6 area.

Tile colors

Tiles change color as they take damage, so you can see at a glance where work is left.

Many layers left
Middle
Almost cleared
Cleared

Top bar

  • Score and the current Lv. / D. (level and difficulty).
  • Progress bar showing layer hits cleared out of the total needed.
  • HINT highlights one valid swap in yellow.
  • Shuffle (×3) reshuffles the board. You get three per game.

If no valid move is left, the game ends with NO MORE MOVES.

Powerups

Created automatically from special matches. The powerup appears on the gem you just swapped.

+

Line Bomb

Match exactly 4

Gold ring with a cross. Clears a full row or a full column, whichever damages more tiles.

✦

Color Bomb

Match 5 or more

Pink ring with a pentagon of dots. Clears every gem on the board that shares its color.

▢

Area Bomb

Match in an L or T shape

Teal ring with a square. Clears the 3×3 area around itself.

Firing a powerup

  • Double-click it to fire immediately.
  • Swap it with a normal gem to fire it.
  • Swap it with another powerup to fuse them (see below).

Powerup gems never count as part of a normal match; they break runs until you use them.

Fusions

Swap powerup A onto powerup B. The order doesn't matter.

ComboResultEffect
Line + LineCross BombFull row and full column of both powerups
Line + AreaMega Area5×5 blast
Area + AreaMega Area5×5 blast
Line + ColorColor LineAll gems of that color plus their entire rows and columns
Area + ColorColor AreaAll gems of that color plus a 3×3 around each
Color + ColorWipe BoardClears the entire board

Level & difficulty

Two dials on the start screen control how hard a game is.

Difficulty: 1–10

The number of gem colors in play. Fewer colors means easier matches and more chains. More colors means harder matching. The start screen previews the colors you've chosen.

Level: 1–50

The number of layers on every center tile. Level 1 needs one hit per tile; level 50 needs fifty. Win a level and the "Next Level" button takes you up by one.

Scoring

Bigger clears and longer chains pay off.

ComponentPoints
Base10 per gem cleared
Size bonus+10 for each gem beyond the minimum of 3
Chain bonus+30 per chain level above 1 (chain 2 = +30, chain 3 = +60, …)

Your best score is saved to match3_highscore.json next to the script, and shown on the menu and end screens.

Run it

You need Python 3 and Pygame.

pip install pygame
python3 match3.py

The window is 512 × 592 pixels (an 8×8 grid of 64px cells plus an 80px top bar).

Controls

InputAction
Click gem, click neighborSwap
Double-click a powerupFire it
ESCBack to menu (works during animations too)
RMenu, from the win or game over screen
QQuit, from the win or game over screen

Under the hood

Everything lives in one well-commented file, match3.py.

Code layout

  • Constants: grid size, cell size, animation timings, colors. Tweak the *_MS values to change how the game feels.
  • Gem data: each cell is a small dict, {"color": int, "power": str | None}, wrapped by helpers like make_gem() and is_powerup().
  • Grid logic: make_grid() builds a board with no starting matches; find_matches() scans rows and columns; detect_powerup_type() decides which powerup a match earns; apply_gravity() and fill_empty() refill the board.
  • Powerups: activate_powerup() handles a single bomb and fuse_powerups() handles combinations, keyed on an order-independent frozenset.
  • Helpers: has_any_move() for game over detection, find_hint(), and do_shuffle(), which retries until the board has no matches but still has a move.
  • Drawing: tiles, gems, powerup rings and symbols, and a small FloatText class for the drifting "+score" popups.

Game state machine

The main loop is driven by a simple state variable.

start→ playing→ swapping→ flashing→ falling→ playing
  • reverting: a swap with no result slides back.
  • falling re-checks the board, so chain reactions loop back into flashing.
  • win triggers the moment the last tile layer clears, even mid-combo.
  • gameover triggers when no valid move remains after a combo ends.