|
retroPy's glitchi
╔══════════════════════════════════════════════════════════════╗
║                    retroPy API Contents                      ║
╚══════════════════════════════════════════════════════════════╝

📦 retroPy
 ├─ 📥  Import
 ├─ 📖  Overview
 ├─ ⚙️  Top-level functions
 ├─ 🧱  Top-level classes
 ├─ 🧩  Top-level submodules
 ├─ 🔧  rpy submodule
 ├─ ▶️  Example
 └─ 📝  Documentation status


📦 API Reference: retroPy

retroPy is the top-level MicroPython module for the engine.

It exposes:

  • timing helpers
  • core engine classes
  • submodules such as disp, draw, kb, and rpy


📥 Import

from retroPy import *

Or:

import retroPy
from retroPy import disp, draw, kb, rpy

📖 Overview

For most projects, retroPy is the main entry point.

It gives you:

  • global timing helpers such as dt() and gTime()
  • engine classes such as sprite, gameObj, map, and gameloop
  • screen, drawing, input, and utility submodules

⚙️ Top-level functions

dt()

Returns gameplay delta time in seconds for the current frame.

This value is intended for frame-rate-independent movement and gameplay logic. It is 0 while the active game loop is paused.

x += 40 * dt()

dt_ms()

Returns gameplay delta time in milliseconds for the current frame. It is 0 while the active game loop is paused.

print(dt_ms())

gTime()

Returns gameplay time in seconds. This time advances while the active game loop is running and freezes while it is paused.

print(gTime())

🧱 Top-level classes

The current retroPy.c registration file exposes these classes:

v2d

A vector class. Detailed documentation depends on its own implementation file.

gameloop

The main game loop class.

See: API: gameloop

textbox

A text box UI/helper class.

See: API: textbox

gameObj

A sprite-backed game object class with movement, animation, collision, and sprite-streaming helpers.

See: API: gameObj

sprite

A sprite class.

See: API: sprite

map

A tilemap class that draws tile layers and can perform simple tile-based movement updates for gameObj instances.

See: API: map

canvas

An off-screen drawing buffer class.

See: API: canvas

timer

A callback timer class.

See: API: timer

🧩 Top-level submodules

disp

Display and framebuffer control.

See: API: disp

draw

Drawing functions and rendering helpers.

See: API: draw

kb

Keyboard / button input helpers.

See: API: kb

rpy

Utility helpers exposed through the rplib_c module.

🔧 rpy submodule

The current rpy submodule exposes the following functions:

rpy.load_sprite_str(text)

Builds a sprite-style bytearray from a specially formatted string.

Use this when sprite content is embedded as text instead of read from a file.

data = rpy.load_sprite_str(sprite_text)

Compatibility alias:

  • rpy.LoadSpriteStr(...)

rpy.is_win()

Returns 1 when built for Windows, otherwise 0.

rpy.is_wasm()

Returns 1 when built for WASM, otherwise 0.

Example

from retroPy import *

def Update():
    if kb.A_down():
        loop.exit()

def Draw():
    draw.text("Hello", 20, 20, 15)

loop = gameloop(Update, Draw)
loop.set_target_fps(30)
loop.run()

Documentation status

This page is based on the top-level module registration file. The current docs set now includes disp, draw, sprite, gameObj, map, canvas, textbox, gameloop, kb, and timer.