← Back to Documentation Index

👾 Sprite System

Retro-style 8×8 sprite rendering with animations and transformations

📋 Overview

The Sprite System provides classic 2D sprite rendering perfect for retro games. Sprites are 8×8 pixel tiles that can be animated, flipped, and layered.

💡 Key Features
  • 8×8 Tile System - Classic retro sprite size
  • Sprite Sheets - Multiple sprites in one image
  • Animations - Frame-based sprite animation
  • Transformations - Flip horizontal/vertical
  • Layering - Z-index support for sprite ordering

🎨 Sprite Functions

spr(spriteIndex, x, y, flipX, flipY)

Draws a sprite from the sprite sheet.

spriteIndex number - Sprite number in sheet (0-255)
x, y number - Screen coordinates
flipX boolean - Flip horizontally (default: false)
flipY boolean - Flip vertically (default: false)
Returns: void - No return value
Example:
spr(5, playerX, playerY, facingLeft); // Draw player sprite
loadSpriteSheet(imageUrl)

Loads a sprite sheet image.

imageUrl string - Path to sprite sheet PNG
Returns: Promise - Promise that resolves when loaded
Example:
await loadSpriteSheet("/sprites/characters.png");