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-0.1.1.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-0.1.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: simple_gamestates-0.1.1.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-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a8f71f4954cc4e83da9a851440e3a24d67b136f48b824eb227fa304051fd7a6b
MD5 7292335331cd9d663984678f4c3c3a6d
BLAKE2b-256 cb7d3cdf36bcc1dbd34d5646e3b3f796ba54e120ed06776d4a86f72c12304aee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for simple_gamestates-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 064fbcdb51c9c671b1bf5af1d4867d66913069c56e3b18cae6d2d6e88517c66b
MD5 7e4e91fb894675eff1986a0576f75c0c
BLAKE2b-256 56baf2f4d4f79675c1ade0c55b59a52a4f7260320f40438941ed1e5cc6389f7c

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