Classic Tetris in Lua

Grid-based Falling Blocks Game • LOVE 2D Engine

Project Overview

I developed a classic Tetris-style falling blocks game in Lua, using the LOVE 2D game engine. The gameplay includes increasing difficulty with level selection, accurate scoring, line clearing, and real-time piece rotation and movement. A custom grid system tracks every block’s position and supports all traditional Tetris shapes.

The user interface features a start and settings menu, level selector, persistent top scores for each level, and live display of the next block. The project demonstrates structured Lua code for grid management, collision detection, input handling, and modular game state.

Tetris Lua Menu Screenshot Tetris Lua Gameplay Screenshot

Menu and gameplay screens from my Lua Tetris implementation.

Main Features

Sample Code Highlights

-- Detect and handle line clearing
for y = 1, grid.height do
  if grid:checkRowFull(y) then
    grid:clearRow(y)
    calcScore(lines_cleared)
    determineLevel(LINES_CLEARED)
  end
end

-- Piece movement and rotation
if key == "left" then
  DIRECTION = DIRECTIONS.LEFT
  if not checkWallCollision() and not checkHorizontalCollision() then
    Xvalue = Xvalue - 1
  end
elseif scancode == "a" then
  ROTATION_DIR = ROTATION.COUNTERCLOCKWISE
  if canRotate() then rotateShape() end
end

Possible Future Improvements