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.2.tar.gz (5.0 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.2-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: simple_gamestates-0.1.2.tar.gz
  • Upload date:
  • Size: 5.0 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.2.tar.gz
Algorithm Hash digest
SHA256 ca0fb1c9f65c7ebb132b7f521f341a03fc95977580ceb0acc4796e49b7b80d68
MD5 afa8b76b55ab1460a978b9424f1eb23f
BLAKE2b-256 0624c1d8e4340bd61bbe6570d00d037f0cfcedd4bd41d1f8aff7d982cf1321d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for simple_gamestates-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d48ffccdbb39994306dd3322790303e6672fb49b24c655e830f1aa9737fbb816
MD5 5cd777d07d1b942418e0eba8a3b0dcc8
BLAKE2b-256 82402fd032e2dd0e78c730821ac937ae1c639897f48f263f11e7085662216714

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