GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - alithz-pro/Tetris-Clone: A feature-rich terminal Tetris game built with C++ as a Basic Programming course final project.

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

2 Commits
2 Commits

Folders and files

NameName
Last commit message
Last commit date
Credits.wav
Credits.wav
 
 
GameData.txt
GameData.txt
 
 
README.md
README.md
 
 
Tetris.cpp
Tetris.cpp
 
 
Tetris.wav
Tetris.wav
 
 
Tetris2.wav
Tetris2.wav
 
 

Repository files navigation

Tetris — C++

A feature-rich terminal-based Tetris game built with C++ as the final project for the Basic Programming course at Shahid Beheshti University.

The project implements the core mechanics of Tetris along with additional gameplay features such as custom board sizes, multiple game modes, hold and upcoming pieces, save/load functionality, a leaderboard, themes, and sound.

Project type: University team project Course: Basic Programming Platform: Terminal / Console Language: C++


Overview

This project is a command-line implementation of Tetris designed to practice fundamental C++ programming concepts through a larger interactive application.

Instead of implementing only the basic falling-block mechanic, the project includes a complete menu-driven game experience with configurable games, persistent data, multiple difficulty modes, and terminal-based visual elements.


Features

Gameplay

  • Seven standard tetromino shapes
  • Random piece generation
  • Piece rotation
  • Horizontal movement
  • Vertical movement
  • Hard drop
  • Hold piece
  • Upcoming-piece preview
  • Collision detection
  • Line completion and removal
  • Score tracking
  • Level progression
  • Increasing game speed
  • Game-over detection

Game Modes

The game provides:

  • Quick Game
  • Custom Game

Custom games allow the player to configure:

  • Player name
  • Board width
  • Board height
  • Game mode

Two gameplay modes are available:

  • Classic
  • Extreme

Custom Board Sizes

The custom game mode allows the player to select the board dimensions instead of being restricted to the standard board.

The implementation validates the entered dimensions before allocating the game board.

The supported ranges in the current implementation are:

  • Width: 6–74
  • Height: 15–45

Game Interface

The terminal interface displays information such as:

  • Player name
  • Score
  • Level
  • Cleared lines
  • Elapsed time
  • Current board
  • Held tetromino
  • Upcoming tetrominoes
  • Keyboard controls

The game also uses ANSI terminal formatting and custom UI functions to create a colored and structured console interface.


Persistence

The game includes local persistence features.

Save & Load

A game can be saved and later loaded through the game's menu system.

Leaderboard

The project maintains a leaderboard using GameData.txt.

Leaderboard functionality includes:

  • Reading saved game/player data
  • Sorting leaderboard entries
  • Displaying scores

This allows scores and game information to persist between executions.


Audio

The project includes WAV audio files:

Tetris.wav
Tetris2.wav
Credits.wav

The game uses the Windows multimedia API to play audio during gameplay and other parts of the application.


Architecture and Implementation

The project is implemented primarily in a single C++ source file:

Tetris.cpp

The code is organized into groups of functions responsible for different parts of the game.

Game State

The main game state is represented by structures including:

  • Game
  • Tetrimino
  • Element
  • Option

The Game structure stores information such as:

player
board dimensions
game mode
theme
score
level
line count
time
game-over state
upcoming pieces
board

Tetromino Generation

The implementation contains separate generators for the seven tetromino types:

I
O
L
J
S
Z
T

New pieces are randomly generated and can be rotated before being placed into the game.

Board Management

The game dynamically allocates memory for its board and for tetromino blocks.

Movement and collision checks are performed before modifying the board state.

Line Clearing

Completed rows are detected and removed, with the rows above them shifted downward and the player's score updated.


Game Flow

A simplified game flow is:

Main Menu
    │
    ├── New Game
    │      │
    │      ├── Quick Game
    │      └── Custom Game
    │
    ├── Load Game
    │
    ├── Leaderboard
    │
    ├── How To Play
    │
    ├── About Us
    │
    └── Exit

During gameplay:

Generate Tetromino
       │
       ▼
Place Piece
       │
       ▼
Read Player Input
       │
       ├── Move
       ├── Rotate
       ├── Hold
       └── Hard Drop
       │
       ▼
Fix Piece
       │
       ▼
Check Completed Rows
       │
       ▼
Update Score / Level
       │
       ▼
Check Game Over
       │
       └── Continue

Controls

The game supports keyboard controls for:

Action Control
Move left Left Arrow
Move right Right Arrow
Move down Down Arrow
Rotate Up Arrow / mode-dependent rotation controls
Hard drop Space
Pause Esc

The exact controls are also displayed inside the game interface.


Technology

Technology Purpose
C++ Game implementation
Windows Console Terminal interface
Windows Multimedia API Audio playback
Standard C++ libraries Core functionality
File I/O Save/load and leaderboard

No external game engine or third-party game framework is required.


Concepts Practiced

This project was created to apply the fundamentals of C++ programming to a larger interactive system.

Concepts practiced include:

  • Variables and data types
  • Functions
  • Structures
  • Arrays
  • Pointers
  • Dynamic memory allocation
  • Dynamic two-dimensional arrays
  • File I/O
  • Random number generation
  • Input validation
  • Control flow
  • Recursion
  • State management
  • Collision detection
  • Basic game-loop design
  • Terminal manipulation
  • Windows-specific APIs

Project Structure

Tetris-Clone/
├── Tetris.cpp
├── GameData.txt
├── Tetris.wav
├── Tetris2.wav
├── Credits.wav
└── README.md

GameData.txt is used by the game for persistent game/leaderboard data.


Building

The original project uses the Windows multimedia library for audio playback.

The repository's original build command is:

g++ .\Tetris.cpp -o "Tetris" -lwinmm

The -lwinmm linker option is required for the Windows multimedia functionality used by the project.

The game is therefore intended primarily for a Windows environment.


Course Context

This project was developed as the final project of the Basic Programming course at Shahid Beheshti University.

It was developed as a team project by:

  • Ali Taherzadeh
  • Sajjad

The project was created during an early stage of learning C++ and software development, before the widespread use of AI-assisted programming tools.

The goal was to apply basic programming concepts to a relatively large interactive program rather than to create a production-level game engine.


Educational Scope

Although the project contains a substantial number of features, it should be understood as an educational console-game project.

It was primarily intended to practice:

C++ fundamentals → memory management → file handling → interactive program design → game logic

rather than modern game-engine development.


Disclaimer

This is an educational implementation inspired by the classic Tetris game.

It is not affiliated with or endorsed by The Tetris Company.


License

No license has been specified for this project.

About

A feature-rich terminal Tetris game built with C++ as a Basic Programming course final project.

Topics

basic-programmingcliconsole-gamecppgame-developmentsbutetristetris-cloneuniversity-project

Resources

Readme
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.