Connect 4 Foundations

Master Connect 4 while learning core CS skills. Each section maps real gameplay to programming concepts you’ll reuse in bigger projects.

Connect 4 lesson Overview

  • State: board, turns, timers
  • UI: responsive 6×7 grid
  • Flow: start, play, win, restart

What to Learn

A fast tour of the skills you’ll build: state-driven UI, event handling, animations, and the full game loop.

Object-Oriented Programming

  • Player, GameBoard, Game classes
  • Encapsulation & single responsibility
  • Timers and UI coordination

Organize Your Code

Refactor the game into classes so logic is clean, testable, and easy to extend.

Algorithms

  • Win detection in 4 directions
  • Landing-row calculation
  • Winning-coordinates highlight

Problem-Solving

Implement efficient checks for four-in-a-row, compute landing spots, and return winning cells for visual feedback.

Learning Challenges

  • Undo stack & move history
  • Settings + localStorage
  • Scoreboard & keyboard controls

Apply & Extend

Ship features that deepen understanding—persistence, accessibility, and polish. Stretch goal: basic AI.