Skip to main content

Tetris with Apulian elements - a Software Engineering project.

Project description

OrecchietTetris

An exact copy of the Tetris game, with Apulian elements. Built as a Software Engineering university project.

Features

  • Classic Tetris gameplay with all 7 standard tetrominoes (I, O, T, S, Z, J, L)
  • Tetromino rotation, hard drop, and shadow piece (ghost piece preview)
  • Hold slot — store the current piece and swap it back in at any time
  • Observer pattern architecture decoupling game logic from the GUI
  • Formal interfaces (ITetromino, IBoard, ITetris) for clean dependency inversion
  • Automated testing via GitHub Actions (Windows, macOS, Ubuntu)
  • Automatic releases to PyPI via semantic-release on pushes to master
  • Automatic dependency updates via Renovate

Requirements

  • Python >= 3.11
  • Node >= 20 and npm >= 10.8 (for semantic-release)
  • Poetry (dependency manager)

Installation

  1. Clone the repository:

    git clone https://github.com/unibo-dtm-se-2425-OrecchietTetris/OrecchietTetris-artifact
    cd OrecchietTetris-artifact
    
  2. Install Poetry if you don't have it yet:

    pip install -r requirements.txt
    
  3. Install the project's dependencies:

    poetry install
    npm install
    
  4. (Optional) Install pre-commit hooks for commit-message linting:

    poetry run poe hooks
    

Usage

Run the game:

poetry run OrecchietTetris

or alternatively:

python -m OrecchietTetris

Development

Run tests

poetry run poe test

Run a single test file or test case:

poetry run pytest -v tests/model/test_tetromino.py
poetry run pytest -v tests/model/test_tetromino.py::test_rotations

Coverage

poetry run poe coverage

Lint & type check

poetry run poe flake8
poetry run poe mypy

Project structure

OrecchietTetris-artifact/
├── OrecchietTetris/
│   ├── model/
│   │   ├── interfaces.py       # ITetromino, IBoard, ITetris abstract interfaces
│   │   ├── tetromino.py        # ShapeType enum and Tetromino(ITetromino)
│   │   ├── board.py            # Board(IBoard) — fixed grid engine
│   │   └── tetris.py           # Tetris(Subject, ITetris) — game orchestrator
│   ├── gui/
│   │   └── TetrisGui.py        # GUI layer (Observer)
│   ├── utils/
│   │   └── observer_subject.py # Observer pattern base classes
│   ├── __init__.py
│   └── __main__.py
├── tests/
│   └── model/
│       └── test_tetromino.py
├── pyproject.toml
└── README.md

Architecture

The project uses the Observer pattern to decouple game logic from the view, with abstract interfaces for dependency inversion:

  • ITetromino, IBoard, ITetris — abstract interfaces defined in model/interfaces.py; ITetris inherits from Subject so the observer contract is part of the interface itself
  • Tetris(ITetris) — game orchestrator; fires observer events on every state change
  • TetrisGui(Observer) — reacts to game events via update(event_type, data)
  • Board(IBoard) — pure grid engine (collision detection, line clearing)
  • Tetromino(ITetromino) — falling piece with clockwise rotation

Observer events fired by Tetris

Event When Data
board_updated piece moved, rotated, or locked None
new_piece new piece spawned ITetromino
hold_updated hold slot changed ITetromino | None
lines_cleared lines removed int
score_updated score changed int
game_over spawn blocked None
paused / resumed pause toggled None

Releases

Releases are automated via GitHub Actions when pushing to master. Commit messages must follow the Conventional Commits specification for semantic-release to compute version numbers correctly (e.g. feat:, fix:, chore:).

License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

orecchiettetris-0.3.1.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

orecchiettetris-0.3.1-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file orecchiettetris-0.3.1.tar.gz.

File metadata

  • Download URL: orecchiettetris-0.3.1.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for orecchiettetris-0.3.1.tar.gz
Algorithm Hash digest
SHA256 8adca1847999940a2a7580c1d03c6503d4e5b5c19e1f1ca8b92ec8e6fb01a5f4
MD5 f45902fcca443b5e53edb9d5be19b1d5
BLAKE2b-256 43c4f02259984755e0bf453fb8af4c18b6b9ca6b392a02aeb792eed30cc025d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for orecchiettetris-0.3.1.tar.gz:

Publisher: deploy.yml on unibo-dtm-se-2425-OrecchietTetris/OrecchietTetris-artifact

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file orecchiettetris-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for orecchiettetris-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b432a7a45b99dbcb82e2c8447642eb445aaf21133e99c0651a3b99d84dd3bf02
MD5 feacdf0d16e27a594d0b2e9a9b503c86
BLAKE2b-256 7e1410765125e543810cd06f56a4ab06861a86c248deafdf41b00998fd9a4ead

See more details on using hashes here.

Provenance

The following attestation bundles were made for orecchiettetris-0.3.1-py3-none-any.whl:

Publisher: deploy.yml on unibo-dtm-se-2425-OrecchietTetris/OrecchietTetris-artifact

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page