Skip to content

Anakior/blocky

Repository files navigation

Blocky 🧩

Blocky is a modern and dynamic reinterpretation of the famous puzzle game, developed in C++ using the SFML library.

Beyond a simple clone, this project is a technical demonstration implementing a complete ECS (Entity Component System) architecture, an event system, particle effects, and enhanced gameplay mechanics (bonuses, penalties).

✨ Features

  • Modern Gameplay Mechanics: Enhanced piece rotation, wall kicks, and other improvements for a fluid experience.
  • 🃏 Card System: Collect cards that apply powerful modifiers to your game.
  • 🎨 Advanced Shader Effects: Visual enhancements with shaders for a more dynamic experience.
  • Special Effects System:
    • 💣 Bomb: Destroys a zone of blocks around it.
    • Speed Boost: Temporarily accelerates piece falling speed.
    • 💰 Coin: Awards coin to purchase cards.
    • 🧊 Ice: Block a line before it shatter.
    • 🌈 Color Bomb: Destroys blocks by color.
    • 🔥 Hellfire Mode: A high-risk, high-reward state where standard Tetrominoes are replaced by complex Pentominoes (5-block pieces). This mode increases scoring potential but significantly ramps up the difficulty with trickier shapes and intense visual effects.
  • Custom ECS Engine: Architecture based on Entities, Components, and Systems for performant and decoupled game management.
  • Particle System: Visual effects during line destruction or bonus activation.
  • State Management: Smooth navigation between menus, gameplay, pause, and game over screens via a State Machine.
  • Persistent High Scores: Saving and loading of high scores (secured via SHA-256 hashing).
  • Audio & Music: Sound manager for sound effects and background music.

🃏 Cards

As you progress, you will be offered a choice of cards. These cards grant permanent bonuses, or introduce new challenges. Choose wisely to build synergies and achieve a new high score.

The cards are divided into several categories:

  • Pieces: Affects the pieces you get.
  • Hellfire: Related to a special "Hellfire" mode.
  • Score: Modifies how you earn points.
  • Effects: Interacts with the special effects system.
  • Risk: High-risk, high-reward modifiers.
  • Board: Modifies the game board itself.
Nom Effet Rareté Catégorie
I-Strong More I pieces, Tetris score -50% Uncommon Pieces
Wiggle's Feast More S and Z pieces. Tetris scores +25% Common Pieces
Storm I Rain of I pieces Rare Pieces
Inferno Hellfire duration +50%. Hellfire bonus +50% Rare Hellfire
Peaceful Coward! Uncommon Hellfire
Pyromancer Search for the secret key Common Hellfire
High Stakes Score multiplier +50% Rare Score
Slow & Steady Game Speed decreases by 25% Uncommon Score
Demolition More boom Common Effects
Ice Age It's cold, no? Common Effects
Purist No effects can be applied Rare Risk
Glass Cannon Score bonus +100%. Game over threshold 15 lines Uncommon Risk
Gambler Gambler mode enabled Rare Risk
Gravity Shift Newton disagrees Uncommon Board
Clean-Up Crew It's time to clean your room Common Board

🎮 Controls

Key Action
Left / Right Arrow Move piece laterally
Down Arrow Soft Drop (Accelerate fall)
Up Arrow Rotate piece
Space Hard Drop (Instant fall)
C Hold Pieces
P Pause game
Esc Quit / Return to menu

🛠️ Installation and Build

Prerequisites

  • C++ Compiler compatible with C++20 (GCC, Clang, MSVC).
  • CMake (version 3.10 or higher).
  • SFML (version 3.0.2).

Build Instructions

  1. Clone the repository:

    git clone [https://github.com/anakior/blocky.git](https://github.com/anakior/blocky.git)
    cd blocky
  2. Create the build directory:

    mkdir build
    cd build
  3. Configure and Compile:

    cmake ..
    cmake --build .
  4. Run the game:

    • Windows: .\Debug\Blocky.exe (or .\Blocky.exe depending on config).
    • Linux/Mac: ./Blocky

Note: Ensure that the resources/ and assets/ folders are located at the same level as the executable or in the working directory when launching.

🧪 Unit Tests

This project includes a suite of unit tests to ensure the stability of the core logic (Board, ECS, Score Manager, etc.), powered by Catch2.

Running Tests

  1. Build the tests (usually done automatically with the main build):

    cmake --build . --target blocky_tests
  2. Execute the tests: You can run the test executable directly or use CTest:

    # Option 1: Direct execution
    ./tests/blocky_tests
    
    # Option 2: Using CTest
    ctest --output-on-failure

🏗️ Technical Architecture

This project stands out for its robust software architecture:

  • ECS (Entity Component System): The core of the game (src/ecs/). Separates data (Components) from logic (Systems).
    • Components: Position, Velocity, Sprite, Collision, etc.
    • Systems: RenderSystem, PhysicsSystem, ParticleSystem, etc.
  • State Pattern: Screen management (src/states/) allowing clean transitions between StartState, PlayingState, PauseState, etc.
  • Event Bus: An EventManager allows different parts of the code to communicate without tight coupling (e.g., triggering a sound when a line is cleared).
  • Resource Manager: Optimized loading of textures, fonts, and sounds to avoid memory duplication.

📚 Libraries Used

  • SFML - Graphics, Windowing, Audio.
  • nlohmann/json - JSON configuration file parsing.
  • PicoSHA2 - Cryptographic hashing for score security.
  • Catch2 - Unit testing framework.

📄 License

This project is licensed under the PolyForm Noncommercial License 1.0.0, which prohibits any commercial use.
See the LICENSE file for full details.

👤 Author

Anakior

🎨 Graphics

Clyran


Made with ❤️ and a lot of C++.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors