Skip to main content

A simple and abstract state machine manager for Python game development.

Project description

simple-gamestates

A simple, abstract, and robust State Machine Manager designed for modular game development in Python (e.g., Pygame, Arcade).

This library helps organize your game logic by separating different game phases (Menu, Level 1, Pause Screen, Game Over) into distinct, manageable State objects.

Features

  • Stack-based Management: Easily pause a state (e.g., main game) and push a new state on top (e.g., pause menu), and seamlessly return when popped.
  • Abstract State Interface: Enforces clear methods (startup, cleanup, update, draw, handle_input) for structured code.
  • Framework Agnostic: Designed to integrate with any Python game framework or engine.

Installation

pip install simple-gamestates

Usage Example

from pystatemachine.manager import State, StateManager

class MenuState(State):
    def startup(self, data=None):
        print("Menu loaded!")
    
    def update(self, dt):
        # Handle menu animations
        pass
    
    def draw(self, screen):
        # Draw menu background
        pass
        
    def cleanup(self):
        print("Menu exited.")

manager = StateManager()
manager.push_state(MenuState)

# In your main loop:
# manager.update(dt)
# manager.draw(screen)

License

MIT License

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

simple_gamestates-2.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

simple_gamestates-2-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file simple_gamestates-2.tar.gz.

File metadata

  • Download URL: simple_gamestates-2.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for simple_gamestates-2.tar.gz
Algorithm Hash digest
SHA256 03b01c5ee90f5be096aa097d6195f963a94aad5dab98d56f0ee699d01b630f0c
MD5 ab8eb7c9e1875a8084d70a287d4ce812
BLAKE2b-256 fc79316a965e13b35755214e5fc232b9eb8f7f643e398dc0837c0db3cb024b5c

See more details on using hashes here.

File details

Details for the file simple_gamestates-2-py3-none-any.whl.

File metadata

  • Download URL: simple_gamestates-2-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for simple_gamestates-2-py3-none-any.whl
Algorithm Hash digest
SHA256 f47d69ab7b8c024bb8878bac32e18a71e894b64dc939adcc769171fbec75ad2d
MD5 3384b39b93a0af7a3ddee07d0d8e6656
BLAKE2b-256 197f3a39281715f0e8e0be14526185c6d539fd06d64f52546e5ad0a6d8bc899f

See more details on using hashes here.

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