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.0.tar.gz (24.8 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.0-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: texastoast-0.1.0.tar.gz
  • Upload date:
  • Size: 24.8 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.0.tar.gz
Algorithm Hash digest
SHA256 f76120e486b11a0b0bf33868d8a1d8b3387b1baa7a8b4c3af8dcb01631f01303
MD5 5aba9af3793b19867f9e03242d54679f
BLAKE2b-256 7a9e4d09477176aac3b74c88abf1ec30f9b903a058b2e7c2b49473e5eb90b875

See more details on using hashes here.

File details

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

File metadata

  • Download URL: texastoast-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.3 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c3d25db92e06a5b211e75dbd5f3492dbd5bbfd25d130c356ea2db90dc4aad286
MD5 4d598f03bddb6d7373d54ea488e0d6ec
BLAKE2b-256 34e1305cde7583a397d79bef724da3be0e36060e492971a8ede732916075d4be

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

0.1.1

2 files

This release

0.1.0 This release

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