Skip to main content

A tetris engine written in rust

Project description

Tetris

Rust .github/workflows/CI.yml

A tetris engine python package powered by rust

  • Handles the tetris game logic for you so you can focus on building a tetris interface
  • Provides flexibility for the game loop, allowing you to define the game loop entirely or run a built-in game loop thread in the background
  • The built-in, multithreaded game loop capability makes use of rust's safe concurrency offering

Tetris

Install the package

pip install http://www.github.com/peter-lucia/tetris_engine/archive/main.zip
from time import sleep

from tetris_engine import Tetris, Direction

def run_singlethreaded():
    """
    You control the game loop as well as the game speed
    """
    tetris = Tetris()
    while tetris.is_game_running():
        tetris.move(direction=Direction.Down.value)
        for row in tetris.read_game():
            print(row)
        print()
        sleep(1)
        

def run_multithreaded():
    """
    You control the user controls of the game but the 
    game loop runs in a background thread 
    """
    tetris = Tetris(multithreaded=True)
    while tetris.is_game_running():
        tetris.read_game()
        for row in tetris.read_game():
            print(row)
        print()
        sleep(.5)

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

tetris_engine-0.3.1.tar.gz (236.7 kB view details)

Uploaded Source

Built Distribution

tetris_engine-0.3.1-cp38-cp38-macosx_10_7_x86_64.whl (221.8 kB view details)

Uploaded CPython 3.8 macOS 10.7+ x86-64

File details

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

File metadata

  • Download URL: tetris_engine-0.3.1.tar.gz
  • Upload date:
  • Size: 236.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.14.15

File hashes

Hashes for tetris_engine-0.3.1.tar.gz
Algorithm Hash digest
SHA256 b91b6f0af831224a0c755526f2836a04a90b0844bd4ae3f78ea7c1deb8b71156
MD5 c882c16cbdbd5818a8bde5f7f5982a68
BLAKE2b-256 fd960bbe8ee722cfff6cc392d864b3277fb028a0d7b887edd9cf48f56fbc44be

See more details on using hashes here.

File details

Details for the file tetris_engine-0.3.1-cp38-cp38-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for tetris_engine-0.3.1-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 9935bacce4fa5081009181c9f1e16588e89252226bd7145e3ece4ce24c6be4e6
MD5 c9ebeb4ce056e1a350fc2c5695fe03a4
BLAKE2b-256 0243dd2f142f54bf24b13d15de6de471361e4458f77093b6319a610e204cec62

See more details on using hashes here.

Supported by

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