Skip to content
/ Tetris Public

Pure C# windows desktop game (playable game attached to repo. Have fun!)

Notifications You must be signed in to change notification settings

ndrada/Tetris

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎲 Tetris Game (WPF / C#)

This is a Tetris game built entirely from scratch using C# and WPF (Windows Presentation Foundation). It features custom block logic, a scoring system, held pieces, and colorful sprite-based graphics.

This was a personal project to strengthen my object-oriented programming skills and deepen my understanding of game loops, UI rendering, and state management in C#.


✨ Features

  • Classic Tetris rules with rotation, hold piece, and scoring
  • 7 tetromino types (I, J, L, O, S, T, Z) each with rotation logic
  • Grid-based collision detection
  • Block queue & held piece functionality
  • Custom game loop
  • Visual design using PNG tile sprites

πŸ“ Project Structure

007-WPF-tetris-game
β”‚
β”œβ”€β”€ Assets/                    # All PNG sprite files (blocks, background, icon)
β”œβ”€β”€ backend/                  # (If needed for expansion, not used here)
β”œβ”€β”€ .vs/, bin/, obj/          # Build folders (ignore)
β”œβ”€β”€ Block.cs                  # Abstract Block class & movement logic
β”œβ”€β”€ BlockQueue.cs             # Handles next piece & randomizer
β”œβ”€β”€ GameGrid.cs               # 2D grid management, full row logic
β”œβ”€β”€ GameState.cs              # Core gameplay logic (score, game over, etc.)
β”œβ”€β”€ IBlock.cs, JBlock.cs...   # Definitions for each tetromino
β”œβ”€β”€ Position.cs               # Simple row/column helper class
β”œβ”€β”€ MainWindow.xaml/.cs       # UI & game loop
└── README.md                 # This file

⚑ Getting Started

Prerequisites

  • Windows OS
  • Visual Studio (2022+ recommended)
  • .NET Desktop Development workload

Run the Game

  1. Clone the repo:
git clone https://github.com/ndrada/Tetris.git
  1. Open the .sln file in Visual Studio
  2. Hit Run (F5) to start playing!

No additional packages or setup needed.


πŸ† Gameplay Highlights

  • Score increases by number of cleared rows
  • Game ends when new block can't spawn
  • You can rotate CW/CCW, move side to side, and hard-drop
  • Hold a piece to save for later (one-time per drop)

πŸ“‹ Learnings & Challenges

  • Implemented OOP principles through abstract classes & inheritance
  • Built logic-heavy systems like block collisions, rotations, and queue shuffling
  • Gained confidence in WPF rendering and UI threading

✨ Future Improvements

  • Add sound effects
  • Implement ghost preview of where block will land
  • Add level progression with increasing speed
  • High score tracking

πŸš€ Made With Love

Built by yours truly to level up my C# and game dev skills. Feel free to fork it, try it, or reach out if you want to roast my game logic haha.

andrada.codes | @ndrada


Thanks for checking it out! ✨

About

Pure C# windows desktop game (playable game attached to repo. Have fun!)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages