cpgame
Simple "game" framework for CircuitPython embedded hardware.
Overview
cpgame provides a number of decorators and a simple event loop to provide a responsive framework for building applications and games on embedded hardware using CircuitPython.
Run a function on every "tick" of the event loop:
from cpgame import start, tick
@tick
def loop(now):
...
start()
Blink a Neopixel every second:
@every(1)
def periodic(now):
pixel[0] = RED if int(now) % 2 else OFF
Turn a Neopixel on and off with a button press:
@on(board.BUTTON_A, DOWN)
def pressed(now):
pixel[0] = RED
@on(board.BUTTON_A, UP)
def released(now):
pixel[0] = OFF
Create or reset timers:
@on(board.BUTTON_A)
def flood(now):
pixels.fill(random.choice(COLORS))
delay = random.randint(20, 100) / 10 # between 2 and 10 seconds
after(delay, flood)
@on(board.BUTTON_B)
def halt(now):
cancel(flood)
Play sound:
enable_speaker()
middle_a = sample(440)
@on(board.BUTTON_A)
def noise(now):
play_sound(middle_a, 1)
Roadmap
- Support more boards than Circuit Playground Express.
- Add helper functions for animating NeoPixels, raw audio clips, and LCD displays.
License
aiosqlite is copyright John Reese, and licensed under the
MIT license. I am providing code in this repository to you under an open source
license. This is my personal repository; the license you receive to my code
is from me and not from my employer. See the LICENSE file for details.
Metadata
Release files for cpgame 0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cpgame-0.5.tar.gz | 4.3 kB | Details |
Release files / cpgame-0.5.tar.gz
| Download URL | cpgame-0.5.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7eef8deb3122073d422a5c6c705c28109b822ddf487617ce373bac2ca27ad6f9
|
|
BLAKE2b-256 checksum How to use checksums |
1a770cedda9c5c503b88c90d0f8dd62c9689cbaeff52919f7e610aa8013129f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|