Functional Tetris

Scala  //  Functional Programming  //  Object-Oriented Programming

01. Overview

Engineered a Scala-based implementation of the classic game Tetris, emphasizing high-level functional programming patterns and elegant architectural design. The project focuses on building a robust game engine that handles complex geometric transformations and state transitions without relying on side effects or mutable state.

The implementation features a complete set of tetrominoes (I, J, L, O, S, T, Z), each with specialized rotation behaviors and anchor-based positioning logic.

02. Engineering & Design Patterns

The project leverages a hybrid approach, combining the strengths of functional immutability with object-oriented subclassing to solve complex game logic problems.

03. Technical Rigor

The primary challenge was ensuring consistent behavior for tetrominoes that do not rotate around a single central block, such as the I and O pieces.

By representing pieces as sets of points relative to a dynamic anchor (rather than a fixed grid), I was able to implement a mathematically consistent rotation system across all piece types. This project demonstrates the ability to translate complex, real-time requirements into a clean, modular Scala codebase that prioritizes maintainability and logical correctness.

View Source on GitHub