Skip to main content

texastoast

Python RPG engine and Magma Hub I2C layer for magmacrunch game systems.

A tkinter-based 2D game engine inspired by adenosine, with I2C hardware abstraction for Raspberry Pi + Pico "Magma Hub" controllers.

Install

# Basic install (keyboard-only, no hardware)
pip install -e .

# With I2C hardware support (Raspberry Pi)
pip install -e ".[hardware]"

# Development (includes pytest)
pip install -e ".[dev]"

Quick Start

from texastoast import Game, CanvasRenderer, TileMap, Entity, KeyboardInput

game = Game(title="My Game", width=400, height=300, fps=30)
renderer = CanvasRenderer(game.canvas, 400, 300)
keyboard = KeyboardInput(game.root)

tilemap = TileMap([
    [1, 1, 1, 1, 1],
    [1, 0, 0, 0, 1],
    [1, 1, 1, 1, 1],
], tile_size=20, solid_tiles={1})

player = Entity(x=40, y=40, width=14, height=14, speed=100)

def update(dt):
    state = keyboard.poll()
    player.move(state.dx, state.dy, tilemap)
    renderer.camera.follow(player.center_x, player.center_y,
                           map_width=tilemap.width, map_height=tilemap.height)

def render():
    renderer.clear()
    renderer.draw_tilemap(tilemap, {0: "#7cb342", 1: "#5d4037"})
    renderer.draw_rect(player.x, player.y, player.width, player.height, "#e94560")

game.set_update(update)
game.set_render(render)
game.start()

Examples

Example Description
examples/hello_world.py Minimal movement demo
examples/tilemap_demo.py Walk around a larger map
examples/sprite_demo.py Animated character sprites
examples/rpg_demo.py NPCs, dialogue, menus, HUD
examples/game_template.py Full game starting point
examples/magma_hub_demo.py I2C controller input
tools/tile_editor.py Tile map editor GUI

API Reference

Core

from texastoast import Game, Config, GameLoop

game = Game(title="My Game", width=640, height=480, fps=30)
game.set_update(update_fn)  # def update(dt: float): ...
game.set_render(render_fn)  # def render(): ...
game.start()

Rendering

from texastoast import CanvasRenderer, Camera

renderer = CanvasRenderer(game.canvas, 640, 480)
renderer.draw_tilemap(tilemap, {0: "#7cb342", 1: "#5d4037"})
renderer.draw_rect(x, y, w, h, color)
renderer.draw_image(x, y, photo_image)
renderer.draw_hud_text(x, y, text, fill="#fff", font=("Courier", 10))

# Camera
renderer.camera.follow(target_x, target_y, map_width=800, map_height=600)
renderer.camera.set_position(x, y)

World

from texastoast import TileMap, Entity, AABB

# Tile map
tilemap = TileMap(grid_data, tile_size=16, solid_tiles={1, 2})
tilemap = TileMap.from_file("map.json", tile_size=16)
tilemap.save("map.json")
tilemap.get(col, row)  # -> tile_id
tilemap.is_solid(col, row)  # -> bool
tilemap.is_solid_at(world_x, world_y)  # -> bool

# Entity
player = Entity(x=0, y=0, width=16, height=16, speed=100)
player.move(dx, dy, tilemap)  # with collision
player.aabb  # -> AABB for overlap checks
player.collides_with(other_entity)  # -> bool

Input

from texastoast import KeyboardInput, InputState

keyboard = KeyboardInput(game.root)
state = keyboard.poll()

state.up, state.down, state.left, state.right  # bool
state.a, state.b, state.start, state.select     # bool
state.dx, state.dy                               # float (-1, 0, 1)
state.is_any_direction()                         # bool

I2C (Magma Hub)

from texastoast import I2CBus, MagmaHub, MagmaHubInput, CompositeInput

# Direct I2C
bus = I2CBus(1)  # I2C bus number
hubs = MagmaHub.scan_buses(bus_numbers=[1])
hub = hubs[0]
hub.poll()  # -> [ControllerState, ...]

# Input adapter (same interface as KeyboardInput)
hub_input = MagmaHubInput(hub, controller_index=0)
state = hub_input.poll()

# Auto-fallback composite
controls = CompositeInput(keyboard, hub_input)
state = controls.poll()  # uses hub if connected, else keyboard

UI

from texastoast.ui import DialogueBox, Menu, HUD

# Dialogue
dialogue = DialogueBox(game.canvas, 640, 480)
dialogue.show("Hello, world!", speaker="NPC", on_complete=callback)
dialogue.dismiss()

# Menu
menu = Menu(game.canvas, 640, 480)
menu.show(["Play", "Settings", "Quit"],
          on_select=lambda i, label: print(label),
          on_cancel=lambda: menu.hide())
menu.move_up()
menu.move_down()
menu.confirm()

# HUD
hud = HUD(game.canvas, 640, 480)
hud.add_stat("hp", "HP", value=100, max_value=100, color="#e94560")
hud.set_stat("hp", 75)
hud.add_text("score", "Score: 0", 10, 10, fill="#fdd835")
hud.set_text("score", "Score: 100")
hud.render()

Magma Hub Hardware

The Magma Hub is a Raspberry Pico acting as an I2C slave, providing controller input (buttons + joystick) to the Pi master. texastoast abstracts this hardware so games don't need to know about I2C details.

Protocol

Address Data Description
0x00 8-bit Button status (bitmask)
0x01 8-bit Joystick status

Button Bitmask

Bit Button
0 Up
1 Down
2 Left
3 Right
4 A
5 B
6 Start
7 Select

Design Philosophy

  • No opinions — engines provide systems, you wire them together
  • Configurable — pass callbacks and data, don't inherit from base classes
  • Tiny — small, focused modules with minimal dependencies
  • Graceful fallback — I2C hardware is optional, keyboard always works
  • Testable — game logic doesn't depend on tkinter

License

Apache-2.0. Copyright 2026 magmacrunch media.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

texastoast-0.1.1.tar.gz (25.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

texastoast-0.1.1-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: texastoast-0.1.1.tar.gz
  • Upload date:
  • Size: 25.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for texastoast-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1002250e50cd6882d4b51d466b971ade9a00a8cd71d03254a7e51fb6e6139f82
MD5 73a4aa7c238e91a70eb90b5c83e5031b
BLAKE2b-256 5c148f1d1697b83cc424de3303b8a1bb4bc1ece6d207d7464daec71734867943

See more details on using hashes here.

File details

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

File metadata

  • Download URL: texastoast-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 23.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for texastoast-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ef5e8898e729a60c3dec518f1b9e00e2ccf5c0625671ee752aff270ba997fbea
MD5 2cb03ee18736b931034f7a531427f7fc
BLAKE2b-256 50eb9872772e8bcfd04d3e551ed1fe66677786797094fd8b1e47421a645f50d7

See more details on using hashes here.

Release history Release notifications | RSS feed

0.11.2

2 files

0.11.1

2 files

0.11.0

2 files

0.10.0

2 files

0.9.0

2 files

0.8.0

2 files

0.7.0

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.3

2 files

0.1.2

2 files

This release

0.1.1 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page