Skip to content
AI-powered appsNewChat, vision, voice, generationBookings & schedulingAppointments that book themselvesShops & sellingA storefront in every pocketClient & businessRun the operation from one placeCommunities & clubsA home that is not a group chat
Health & wellnessHabits, tracking and calmGames2D, 3D and multiplayerPersonal & toolsThe tool you wish existedInternal toolsThe tool ops never had time for
See all use cases
ArcadeNewPricingSecurity
EngineThe game engine and World EditorHow it worksFrom one sentence to a live productDocsGuides for building and publishingBlogStories, guides and newsChangelogWhat shipped latelyStatusUptime of every serviceSupportGet help from the team
AI-powered appsBookings & schedulingShops & sellingClient & businessCommunities & clubsHealth & wellnessGamesPersonal & toolsInternal tools
See all use cases
ArcadeNewPricingSecurity
EngineHow it worksDocsBlogChangelogStatusSupport
Language
Blog
GamesNovember 22, 20266 min read

How to Make a Match-3 Puzzle Game

Match-3 looks simple and hides a careful state machine. Here is the logic behind swaps, cascades and special pieces, plus how to design levels around goals.

Startbase Team
Editorial ink illustration of a wooden tray of carved gems with three in a row lifting off, the middle gem in ember orange

Key takeaways

  • Run the board as a state machine: swap, find matches, clear, drop, refill, and repeat until nothing matches. Lock input until it settles.
  • Specials come from match shapes: four in a line, L and T shapes, five in a line. Decide the rules on paper first.
  • Levels are goals plus limits: collect, clear or reach a score within a number of moves. The goal is the level design.

A match-3 game is a grid of colored pieces where swapping two neighbors that creates a line of three or more clears them, pieces fall to fill the gaps, and new pieces drop in from the top. To build one you need correct grid logic, a cascade loop that keeps resolving until the board is stable, special pieces created by bigger matches, and levels defined by goals and move limits. Below is each part in the order you should build it.

The grid and the swap

Store the board as a two-dimensional array, 8 by 8 or 9 by 9 for phones, where each cell holds a piece (color, plus a special type if any) or is empty. Some cells can be permanently blocked to shape the board; that one flag gives you every non-rectangular layout you will ever need.

  1. 01The player drags a piece toward a neighbor (up, down, left or right). Diagonal swaps are not allowed.
  2. 02Animate the swap.
  3. 03Check whether either moved piece is now part of a line of 3 or more.
  4. 04If not, animate the swap back. Most games do not charge a move for an invalid swap.
  5. 05If yes, spend a move and start the cascade.

Tip

Detect swipes on the piece the finger started on, not where it ends. A 20 to 30 pixel drag in a clear direction is a swap; less is a tap (which some games use to select-then-tap instead).

Finding matches

Scan every row left to right and every column top to bottom, counting runs of the same color. Any run of 3 or more is a match. Collect all matched cells in a set first and clear them together, because one cell can belong to a horizontal and a vertical run at once (that is how L and T shapes appear). Clearing as you scan breaks those shapes.

The shape of each match group decides what special piece, if any, it creates:

  • Three in a row: clears, no special.
  • Four in a row: creates a line clearer (a striped piece in Candy Crush terms) that clears its row or column when matched. Direction usually follows the swap.
  • L or T shape (five cells across two lines): creates a bomb that clears the 3 by 3 area around it.
  • Five in a row: creates a color bomb that, swapped with any piece, clears every piece of that color.
  • Special plus special: the combinations (two line clearers make a cross, line plus bomb clears three rows and three columns) are where the genre’s big moments come from. Write a small table of combos and stop at three or four.

Cascades: the loop that makes it feel good

After a clear, pieces above fall into the gaps and new ones spawn above the board and drop in. Those new positions can create new matches nobody planned, which clear and drop again. This is the cascade, and it is what makes match-3 satisfying. The logic is a loop:

  1. 01Resolve: find all matches, create specials, trigger any specials hit by the clear (which may hit more specials).
  2. 02Clear: remove matched cells, add score, update goals.
  3. 03Gravity: for each column, move pieces down into empty cells, bottom up, skipping blocked cells.
  4. 04Refill: spawn new random pieces in the empty top cells.
  5. 05Repeat from Resolve until a pass finds no matches.
  6. 06Check for moves: if no valid swap exists anywhere, shuffle the board.

Keep the logic separate from the animation. The board state can resolve instantly; the animation layer plays back a list of events (swap, clear these cells, move these pieces, spawn these) one step at a time. Input stays locked until the list finishes. Mixing the two is the most common source of bugs where pieces overlap or vanish.

Tip

Raise a combo counter with each cascade pass and step up the clear sound’s pitch a little each time. It costs nothing and makes long cascades feel like an event. The game feel and juice guide lists the shakes, pops and pitch steps that sell a combo.

Fair boards: spawning and shuffling

  • No matches at the start. When filling a new board, pick each piece’s color from the colors that would not complete a line with the two pieces to its left or above it.
  • Always a move. After each settle, search for any swap that would make a match (try every swap and check, it is cheap on a small grid). If none exists, shuffle the existing pieces until there is one and no instant match.
  • Hint after idle. After 5 seconds without input, gently pulse one valid move.
  • Color count is difficulty. Five colors on an 8 by 8 board produces lots of cascades; six or seven makes the board much harder. It is the single strongest difficulty dial you have.

Level goals make the levels

Endless match-3 gets old quickly. What made the genre a giant was levels with goals and limits. Each level is a board shape, a color count, a move limit (typically 15 to 35) and one goal type:

  • Score target: reach N points. The easiest goal; good for teaching levels.
  • Collect: clear 20 red and 20 blue pieces. Forces players to focus on colors.
  • Clear tiles: remove a layer (ice, jelly) under specific cells by matching on top of them. Board shape and tile placement become the puzzle.
  • Bring down: drop ingredient items to the bottom row. Rewards matching low on the board.
  • Blockers: crates that take two adjacent matches to break, chains that lock a piece in place.

Award one to three stars by score when the goal is met, and convert leftover moves into bonus specials at the end; players love watching the board explode on a win. Store each level as a small data file (layout, colors, moves, goal, blockers) so you can make 30 levels by editing data instead of asking for code changes. Introduce one new blocker or goal every five or so levels. The difficulty curve guide explains why that rhythm of new ideas and easier breathers keeps players going.

The brief to paste

A match-3 puzzle game with a candy-shop look, portrait for phones. 8 by 8 board, five piece colors, some cells can be blocked to shape the board. Swipe to swap neighbors; invalid swaps bounce back without costing a move. Four in a row makes a line clearer, L and T shapes make a bomb (3 by 3), five in a row makes a color bomb. Include the combos for two specials swapped together. Board logic resolves separately from animation, then the animation plays the events in order; input is locked until the board settles. No starting matches, reshuffle when no moves exist, hint after 5 seconds idle. Levels come from data files with layout, colors, moves and one goal (score, collect colors or clear ice). Make 12 levels that introduce ice at level 4 and the collect goal at level 7. Stars by score, leftover moves become bonus specials at the end.

Polish that matters more than you think

Match-3 is a genre of tiny feedback: pieces that squash a little when they land, a short pause before a cascade continues so the eye can follow it, particles in the cleared piece’s color, a satisfying thunk for specials. The agent can generate sound effects and music for the game in the same chat. Edit the move counter, goal display and win screen layout yourself in the UI Editor. Then publish it to the Arcade and see how far people get. If you are new to building games this way, start with how to make a game without coding. Match-3 lives on return visits, so read saving game progress before you ship level 20, and improving retention for the habits behind daily return.

Frequently asked questions

How do cascades work in a match-3 game?

After matched pieces are cleared, pieces above fall into the gaps and new pieces spawn at the top. The game then checks again for matches and repeats the clear, fall and refill loop until no matches remain.

How do I make sure a match-3 board always has a move?

After each turn, test every possible swap and check whether it creates a match. If none does, shuffle the pieces on the board until a valid move exists and no match is already present.

What board size should a mobile match-3 game use?

An 8 by 8 or 9 by 9 grid fits a phone screen in portrait with room for the move counter and goals. Use blocked cells to make interesting shapes rather than a bigger grid.

On this page

  • The grid and the swap
  • Finding matches
  • Cascades: the loop that makes it feel good
  • Fair boards: spawning and shuffling
  • Level goals make the levels
  • The brief to paste
  • Polish that matters more than you think

Keep reading

More in Games
Editorial ink illustration of a wooden toy figure jumping between two stone ledges, the coin above the gap in ember orange
GamesNovember 22, 2026

How to Make a Platformer Game with AI

A platformer lives or dies on its jump. Here are the numbers behind a jump that feels fair, how to build levels around it, and how to get an AI agent to build both.

7 min read
Editorial ink illustration of a tin wind-up runner on track pieces laid down ahead of it, the next track piece in ember orange
GamesNovember 22, 2026

How to Make an Endless Runner Game

An endless runner is a level generator with a character on top. Get the chunks, the speed curve and the controls right and the rest is art.

6 min read

Read less. Ship more.

Everything in this post is one prompt away. Describe your app and watch it build.

Start building

Apps, games, backends and publishing from one conversation.

Product

  • Features
  • Use cases
  • Pricing
  • Changelog

Resources

  • Blog
  • Docs
  • Support
  • Status
  • Security

Contact

  • w@startbase.ai
  • X / Twitter
  • LinkedIn
  • Instagram

Legal

  • Terms
  • Privacy

© 2026 Startbase. All rights reserved.