Skip to content

TinTinWinata/c-tetris

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

11 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

CTetris - Tetris in C

ctetris

A classic Tetris game implementation written in C with colorful terminal graphics and sound effects.

Features

  • ๐ŸŽฎ Classic Tetris gameplay with 6 different tetromino shapes
  • ๐ŸŽจ Colorful terminal graphics with ANSI color codes
  • ๐Ÿ”Š Sound effects for moves and line clears
  • ๐Ÿ“Š Score tracking system
  • ๐ŸŽฏ Smooth falling mechanics with customizable speed

Game Controls

Key Action
A Move piece left
D Move piece right
S Move piece down (soft drop)
Space Rotate piece
Enter Start game / Continue

How to Play

  1. Compile the game (if you don't have the executable):

    gcc main.cpp config.h shape.h -o ctetris
  2. Run the game:

    ./ctetris
    # or on Windows:
    main.exe
  3. Gameplay:

    • Tetromino pieces fall from the top of the playing field
    • Use the controls to move and rotate pieces
    • Complete horizontal lines to clear them and earn points
    • Game ends when pieces reach the top of the playing field

Scoring

  • Each line cleared awards 500 points
  • Try to achieve the highest score possible!

Requirements

  • Windows: Uses conio.h and windows.h for input handling and sound
  • Compiler: Compatible with GCC, Clang, or MSVC
  • Terminal: ANSI color support recommended for best visual experience

Project Structure

c-tetris/
โ”œโ”€โ”€ main.cpp      # Main game logic and loop
โ”œโ”€โ”€ config.h      # Color definitions and utility functions
โ”œโ”€โ”€ shape.h       # Tetromino shape definitions
โ”œโ”€โ”€ main.exe      # Compiled executable (Windows)
โ””โ”€โ”€ README.md     # This file

Technical Details

  • Grid Size: 18x18 playing field
  • Shapes: 6 unique tetromino types with 4 rotation states each
  • Frame Rate: 30 frames per move cycle
  • Platform: Windows (uses Windows-specific libraries)

Building from Source

To compile the game from source:

gcc main.cpp config.h shape.h -o ctetris -std=c99

Note: This game is designed for Windows systems and uses Windows-specific libraries (conio.h, windows.h). For other platforms, you may need to modify the input handling and sound functions.

Contributing

Feel free to submit issues, feature requests, or pull requests to improve the game!

License

This project is open source. Feel free to use and modify as needed.

About

๐ŸŽฎ Classic Tetris game implementation in C with colorful terminal graphics, sound effects, and smooth gameplay mechanics

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors