CS50 2D - Lecture 3 - Match 3

CS50 (Harvard University)
CS50 (Harvard University)Apr 24, 2026

Why It Matters

Understanding sprite‑sheet management, tweening, and timer‑driven logic equips developers to create smooth, scalable game mechanics, a cornerstone for modern mobile and indie game production.

Key Takeaways

  • Use sprite sheets and quads to manage tile graphics efficiently.
  • Implement tweening for smooth tile swaps and falling animations.
  • Leverage timers to drive color rotations, level countdowns, and transitions.
  • Detect matches by scanning grid for three identical adjacent tiles.
  • Map each tile to an ID for easy comparison and variant handling.

Summary

The CS50 Week 3 lecture walks students through building a classic Match‑3 game, tracing its roots from Bejeweled to modern Candy Crush variants. It frames the genre’s core mechanic—swapping orthogonal tiles to create three‑in‑a‑row matches—and sets the stage for implementing it in Love2D.

Key technical concepts include using a single sprite sheet sliced into 32 × 32 quads, assigning each quad a numeric ID, and storing the board as a 2D array. The lecture demonstrates tweening to interpolate tile positions during swaps and falls, and timers to animate color cycles, level countdowns, and screen transitions. Match detection is handled by scanning rows and columns for three identical IDs, then refilling gaps with new tiles.

Live code demos highlight the smooth swap animation, the rapid color‑rotation timer on the level label, and the fade‑to‑white transition between game states. The instructor also shows the generateQuads utility that automates quad creation, reinforcing how data‑driven tile IDs simplify both rendering and game logic.

For aspiring developers, the session illustrates how foundational game‑engine techniques—sprite atlases, tweening, timers, and grid algorithms—combine to produce polished, fluid gameplay. Mastery of these patterns equips students to extend the Match‑3 framework into richer titles or apply the same principles to platformers, puzzles, and other interactive experiences.

Original Description

This is Lecture 3 of CS50 2D — explore how to build a smooth & engaging Match-3 game using tile grids, tweening, timers, and color palettes for fluid gameplay and polished visuals.
To take the course for a certificate, register at cs50.edx.org/2d.
***
This is CS50, Harvard University's introduction to the intellectual enterprises of computer science and the art of programming.
***
HOW TO SUBSCRIBE
HOW TO TAKE CS50
Harvard Extension School: https://cs50.harvard.edu/extension
Harvard Summer School: https://cs50.harvard.edu/summer
HOW TO JOIN CS50 COMMUNITIES
HOW TO FOLLOW DAVID J. MALAN
***
CS50 SHOP
***
LICENSE
CC BY-NC-SA 4.0
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License
David J. Malan
malan@harvard.edu

Comments

Want to join the conversation?

Loading comments...