Game-state

Latest version: v2.0.0

Safety actively analyzes 722491 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

2.0.0

This version is a complete rewrite of the library offering lot more optimization and features.

There are a lot of breaking changes including the entire game structure and is not backward compatible to v1.

New-
- Added state and global listeners: `on_setup`, `on_enter` & `on_leave`.
- Added state processors: `process_event` & `process_update`.
- Added `is_running` attribute to the `StateManager`.
- `StateManager.load_state` will raise `StateError` if the class passed is not subclassed from State.
- Changed the following methods to properties in the `StateManager`-
- `get_current_state` method to `current_state` property
- `get_last_state` method to `last_state` property
- `get_state_map` method to `state_map` property

Removed-
- Removed `__slots__` from the `StateManager` allowing users to add their own attributes to it.
- Removed the following methods of the `StateManager`-
- `run_state`
- `update_state`
- Removed the following methods from the State class-
- `run`
- `setup`
- Removed the following exceptions-
- `ExitGame` error
- `ExitState` error

Additionally, there is a complete redesign of the library's code. Check the official guide for more information-
https://game-state.readthedocs.io/en/latest/guide.html

**Full Changelog**: https://github.com/Jiggly-Balls/game-state/compare/v1.1.3...v2.0.0

1.1.3

This update just changes the raised error from `AssertionError` to `StateError` in the `StateManager.change_state` method.

**Full Changelog**: https://github.com/Jiggly-Balls/game-state/compare/v1.1.2...v1.1.3

1.1.2

New-
- Full support for python versions 3.8 - 3.13
- Added `state_name` to the `__init_subclass__` of `State`. Now you can pass in the name of your own subclassed `State` like so-
py
class MyState(State, state_name="My Screen"):
If you don't pass in this argument the state name will be the name of the subclass.
pass

This also means that you will have to pass the same name of the `state_name` to when you're changing states.

Removed-
- Removed `State.clock` (The pygame clock).

1.1.1

The third release of the library.

Fixes-
- Fixes in both `game_state.State` and `game_state.StateManager`'s docstrings

New-
- Made attributes of `game_state.StateManager` (`__states`, `__current_state`, `__last_state`) from non-public to protected, meaning you can now subclass and create your own StateManager.

1.1.0

The second release of the library.

Links

Releases

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.