sprig-essentials

raw JSON →
0.5.0 verified Sat May 09 auth: no python

Simplifying the process of creating games and apps for the Sprig. Currently at v0.5.0, under active development with regular releases.

pip install sprig-essentials
error ModuleNotFoundError: No module named 'sprig_essentials'
cause Library not installed or misspelled (hyphen vs underscore).
fix
Run pip install sprig-essentials. Note: import uses underscores, not hyphens.
error AttributeError: module 'sprig_essentials' has no attribute 'Sprite'
cause Old version installed that did not export Sprite; or wrong import path.
fix
Upgrade to latest version: pip install sprig-essentials --upgrade. Then use from sprig_essentials import Sprite.
error TypeError: __init__() takes 1 positional argument but 3 were given
cause Attempting to instantiate Button with old positional arguments (e.g., without callback).
fix
Use new signature: Button(name, callback) with exactly 2 arguments before self? Actually current signature is Button(name, on_press). Check docs.
gotcha The library is very early-stage (v0.5.0); APIs may change without notice. Pin your version.
fix Use `pip install sprig-essentials==0.5.0` in requirements.
breaking In v0.4.0, the Button class was introduced; in v0.5.0, the constructor signature changed. Users upgrading from v0.3.x may break.
fix Update Button instantiation to match new signature: Button('A', lambda: print('Pressed')).
deprecated The old `add_event_listener` method (if used) has been replaced with `add_button`. Check your code for any calls to `add_event_listener`.
fix Replace `add_event_listener` with `add_button` and adjust parameters.

Initialize a game, create a sprite, add a button, and run the game loop.

from sprig_essentials import Sprite, Game, Button
game = Game()
sprite = Sprite('path_to_image.png', x=50, y=50)
game.add_sprite(sprite)
button = Button('A', lambda: print('Pressed'))
game.add_button(button)
game.run()