Skip to content

KevOneRedOne/Simplistic-Tetris

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

106 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Logo

Simplistic Tetris V2

TypeScript Vite SCSS Vitest License


Modern rewrite of my first-year Bachelor's project. Rebuilding a fun project to create a production-ready game playable anywhere, anytime, while showcasing clean architecture and modern development practices. Have a break, play tetris !


๐ŸŽฎ Play Live Demo

๐Ÿ“ Original Version | ๐Ÿ“š Documentation

Game Screenshot

๐Ÿ’– Support

If you enjoy this game, please consider supporting the project. Your support helps me dedicate more time and energy to improve and expand the project.

Buy Me a Coffee


๐Ÿ“– About The Project

This project is a modern TypeScript rewrite of my first-year Bachelor's group project. It transforms a simple academic project into a production-ready game that demonstrates:

  • Clean architecture with separation of concerns
  • Modern development practices and patterns
  • TypeScript mastery with strict mode
  • Professional code organization and testing
  • Responsive design and mobile support

โœจ Key Features

  • ๐ŸŽฎ Two Game Modes - Classic (infinite) and Ultra (2-minute challenge)
  • ๐Ÿ‘ป Ghost Piece - See where your piece will land
  • ๐Ÿ’พ Hold System - Save a piece for later use
  • ๐ŸŽจ 4 Themes - Classic, Dark, Neon, Retro
  • ๐ŸŒ i18n Support - French and English with extensible system
  • ๐Ÿ“ฑ Fully Responsive - Adaptive touch controls with gesture support for mobile
  • ๐ŸŽต Audio System - Background music and sound effects
  • ๐Ÿ“Š FPS Counter - Real-time performance monitoring
  • ๐Ÿ† High Scores - Persistent leaderboard per game mode

๐Ÿ› ๏ธ Built With

  • TypeScript 5.x - Strict mode for type safety
  • Vite 6.x - Fast build tool with HMR
  • Vitest - Unit testing framework
  • SCSS - CSS preprocessor with modules
  • Canvas API - Game rendering

๐Ÿš€ Getting Started

Prerequisites

  • Node.js 18+
  • npm or yarn

Installation

  1. Clone the repository

    git clone https://github.com/KevOneRedOne/Simplistic-Tetris.git
    cd Simplistic-Tetris
  2. Install dependencies

    npm install
  3. Start development server

    npm run dev
  4. Open http://localhost:5173

Available Scripts

npm run dev          # Start dev server with HMR
npm run build        # Build for production
npm run preview      # Preview production build
npm test             # Run unit tests
npm run test:ui      # Run tests with UI
npm run lint         # Lint code
npm run format       # Format code with Prettier

๐ŸŽฎ Usage

How to Play

Keyboard Controls

Key Action
โ† โ†’ Move left/right
โ†‘ Rotate piece
โ†“ Soft drop
Space Hard drop
Shift Hold piece
Esc or P Pause game
Enter Restart game

Mobile Controls

  • Swipe left/right โฌ…๏ธโžก๏ธ: Move piece
  • Swipe down โฌ‡๏ธ: Soft drop
  • Swipe up โฌ†๏ธ: Rotate piece
  • Single tap ๐Ÿ‘†: Rotate piece
  • Double tap ๐Ÿ‘†๐Ÿ‘†: Hard drop

๐Ÿ“ฑ Full mobile support with adaptive swipe sensitivity! See Mobile Features Guide for details.

Game Modes

  • ๐ŸŽฎ Classic Mode: Traditional Tetris. Play until game over. Clear lines to level up.
  • โšก Ultra Mode: Time attack. Score maximum points in 2 minutes!

๐Ÿ—๏ธ Architecture

From Monolith to Modular

๐Ÿ”ด Before (V1 - Vanilla JS) - Click to view diagram
graph TD
    A[index.html] --> B[main.js]
    B --> C[Piece.js]
    B --> D[tetrominoes.js]
    B --> E[fps.js]
    B --> F[styles.css]

    C --> G[Mixed Logic:<br/>Game + Rendering + UI]
    D --> G

    style G fill:#f5b5b5,stroke:#c77,stroke-width:2px,color:#333
    style B fill:#f4d190,stroke:#d6a86f,stroke-width:2px,color:#333
    style C fill:#f4d190,stroke:#d6a86f,stroke-width:2px,color:#333
Loading

Characteristics:

  • โŒ Vanilla JavaScript (no typing)
  • โŒ Mixed concerns in single files
  • โŒ No test coverage
  • โŒ Basic CSS styling
  • โŒ Manual FPS counter
  • โŒ French only
๐ŸŸข After (V2 - TypeScript Modern) - Click to view diagram
graph TD
    A[index.html] --> B[main.ts]

    B --> C[Core Layer]
    B --> D[Rendering Layer]
    B --> E[UI Layer]
    B --> F[Input Layer]
    B --> G[i18n Layer]

    C --> C1[GameEngine.ts]
    C --> C2[Board.ts]
    C --> C3[Tetromino.ts]
    C --> C4[CollisionDetector.ts]
    C --> C5[ScoringSystem.ts]
    C --> C6[GameModes.ts]

    D --> D1[CanvasRenderer.ts]
    D --> D2[AnimationEngine.ts]
    D --> D3[ThemeManager.ts]

    E --> E1[UIManager.ts]
    E --> E2[AudioManager.ts]
    E --> E3[HighScoreManager.ts]
    E --> E4[FPSCounter.ts]

    F --> F1[InputHandler.ts]

    G --> G1[i18n.ts]
    G --> G2[locales/]

    H[Tests] --> C

    style C fill:#8fc994,stroke:#5a9,stroke-width:2px,color:#fff
    style D fill:#7ba4db,stroke:#4a8ad6,stroke-width:2px,color:#fff
    style E fill:#d9a7c7,stroke:#c77aa4,stroke-width:2px,color:#fff
    style F fill:#f4c790,stroke:#d6a86f,stroke-width:2px,color:#333
    style G fill:#c9a0dc,stroke:#a67bc8,stroke-width:2px,color:#fff
    style H fill:#8b9dc3,stroke:#6a7fa8,stroke-width:2px,color:#fff
Loading

Characteristics:

  • โœ… TypeScript strict mode
  • โœ… Clean separation of concerns
  • โœ… Unit tests (Vitest)
  • โœ… Modern SCSS architecture
  • โœ… Integrated FPS counter
  • โœ… Multi-language (FR/EN)
  • โœ… Optimized Vite build

Architecture Principles

  1. Separation of Concerns - Game logic, rendering, and UI are independent
  2. Testability - Pure functions and dependency injection
  3. Immutability - Game state updates create new objects
  4. Event-Driven - Loose coupling through event emitters
  5. SOLID Principles - Single responsibility, open for extension

Design Patterns

  • ๐Ÿญ Factory Pattern (Tetromino creation)
  • ๐Ÿ‘๏ธ Observer Pattern (Event-driven game events)
  • ๐Ÿ”’ Singleton Pattern (i18n, ThemeManager)
  • ๐ŸŽฏ Strategy Pattern (Game modes)
  • ๐Ÿ“ฆ Module Pattern (Organized file structure)

๐Ÿ“š Documentation


๐Ÿงช Testing

Quick Start

# Run all tests
npm test

# Run tests with UI
npm run test:ui

# Generate coverage report
npm run test:coverage

# View coverage HTML
open coverage/index.html

Test Suite

Test Type Files Tests Coverage
Unit Tests 7 170 30-95%
E2E Tests - Planned -

Coverage Highlights:

  • โœ… GameEngine: 77.18% (36 tests)
  • โœ… UIManager: 95.72% (43 tests)
  • โœ… AnimationEngine: 96.22% (25 tests)
  • โœ… InputHandler: 74.41% (22 tests)
  • โœ… Board: 66.34% (13 tests)
  • โœ… Tetromino: 82.5% (15 tests)
  • โœ… ScoringSystem: 38.88% (16 tests)

Tested Functionality:

  • โœ… Board state management and collision detection
  • โœ… Game engine orchestration and event system
  • โœ… Scoring calculations and level progression
  • โœ… Tetromino rotation and movement
  • โœ… Input handling (keyboard and touch)
  • โœ… UI management and modal system
  • โœ… Animation system and particle effects

See Testing Guide for detailed information.


๐Ÿ” SEO & discoverability

The site is set up for search engines and crawlers:

  • Meta & Open Graph: Title, description, and social cards are set in index.html; align with the main tagline when changing copy.
  • robots.txt (public/robots.txt): Allows indexing of the app and static assets; disallows /reports/ and /assets/ (build artifacts). Points to the sitemap.
  • sitemap.xml (public/sitemap.xml): Single-page sitemap with alternates and image entries. Update lastmod when you make meaningful content or SEO changes.
  • Structured data: JSON-LD for VideoGame, WebApplication, WebSite, and BreadcrumbList is included in the main HTML.

๐Ÿค Contributing

This is a portfolio project, but suggestions and feedback are welcome! Feel free to open an issue or submit a pull request.

How to Contribute

  1. ๐Ÿ› Report Bugs: Use the bug report template
  2. ๐Ÿ’ก Suggest Features: Use the feature request template
  3. ๐Ÿ”ง Submit PRs: Follow the pull request template

For more details, see our Contributing Guide.


โ˜• Support

If you enjoy this game, consider supporting the project:


๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ™ Acknowledgments

This project is a modern rewrite of my first-year Bachelor's group project. The original V1 project was built with the help of the following resources:

Tutorials & Learning Resources

Original Project Contributors

The original V1 project was a group effort with:

  • Me (KevOneRedOne)
  • Djoudi Yanis (Tadayoshi123)
  • Moren Yohan (BoSswosile)

โญ Star this repo if you found it interesting or useful for your learning journey!

About

Modern TypeScript rewriteA Retro Tetris game with clean architecture, responsive design, and mobile support. Playable anywhere, anytime.

Topics

Resources

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

Sponsor this project

Used by

Contributors

Languages