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

Install from pypi

pip install tetris_engine

Install directly from this repository

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

Example usage:

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.2.tar.gz (21.4 MB view details)

Uploaded Source

Built Distribution

tetris_engine-0.3.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (239.1 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

File details

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

File metadata

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

File hashes

Hashes for tetris_engine-0.3.2.tar.gz
Algorithm Hash digest
SHA256 3503acfa12e9d96d78666148765c5abe59950e491cdeecdef6c253a710dc6ea4
MD5 707027397fed1b23a07349afd2a9ab20
BLAKE2b-256 39b1cd040f364b14132056b1f047de5b0140dbe64e3918f012ce97d8405063f6

See more details on using hashes here.

File details

Details for the file tetris_engine-0.3.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tetris_engine-0.3.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 db04e1d53109c0f41f5f96fe2a83c90a0cf2a10a48e7bf404159474bd46518e2
MD5 1566659fa521dd20acd8384de138c85f
BLAKE2b-256 14806bc079a38348bd2c94b22c744601252c2bfb5b5e929f9b21592011dc58a1

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