Skip to content

Tilemap Editor - Technical Reference

Level: ⭐⭐⭐ Advanced


Quick Index


Engine Limits

⚠️ Limits Table

ParameterLimitDescription
MAX_TILE_WIDTH32 pxMaximum tile size
MAX_TILE_HEIGHT32 pxMaximum tile size
MAX_MAP_DIM255 tilesMaximum map dimension
MAX_UNIQUE_TILES256Unique tiles per project
MAX_LAYERS8Layers per scene
MAX_SCREEN_WIDTH320 pxScreen width
MAX_SCREEN_HEIGHT240 pxScreen height
MAX_ANIMATIONS64Animations per scene
MAX_ANIMATION_FRAMES256Total frames
MIN_FRAME_COUNT1Minimum frames
MAX_FRAME_COUNT255Maximum frames
MIN_FRAME_DURATION1Minimum duration (ticks)
MAX_FRAME_DURATION255Maximum duration (ticks)

⚠️ Correction: Previous docs said 4 layers. Actual limit is 8 layers.

Screen Resolutions

Landscape:

  • Maximum: 320×240 px
  • Aspect ratio: 4:3

Portrait:

  • Maximum: 240×320 px
  • Aspect ratio: 3:4

File Formats

Supported Formats

FormatExtensionAdvantagesDisadvantages
JSON.pr32sceneHuman-readable, git-friendlyLarge files
Binary.pr32scene.binUp to 335× smaller, 10× fasterNot readable

Binary Format Versions

VersionFeaturesCompatibility
1Basic✅ Compatible
2Tile attributes✅ Compatible
3Palette slots✅ Compatible
4Multi-palette complete✅ Compatible

⚠️ Correction: Previous docs said version 3. Actual is version 4.

Compression Benchmarks

ProjectJSONBinaryReduction
Small (1 scene)2.6 KB355 bytes86%
Medium (3 scenes)227 KB752 bytes99.7%
Large (10 scenes)~1 MB~5 KB99.5%

Performance

OperationJSONBinaryImprovement
Save20ms2ms10×
Load60ms21ms

Project Structure

File Structure

my_project/
├── my_project.pr32scene      # Main file
├── my_project.pr32scene.bin  # Binary version (optional)
├── tile_flag_rules.json   # Custom rules (optional)
└── assets/
    └── tilesets/
        ├── tileset1.png
        └── tileset2.png

Exported Files

output/
├── my_scene.h              # Declarations
├── my_scene.cpp            # Data (palettes, tiles, indices)
├── my_scene_animations.h  # Animation declarations (if any)
├── my_scene_animations.cpp # Animation data (if any)
└── shared_palette.h    # Shared palette (single palette mode)

API Services

Services

ProjectService

python
class ProjectService:
    def create_project(self, name: str, tile_size: int, ...) -> ProjectModel:
        """Create new project"""
    
    def load_project(self, path: str) -> ProjectModel:
        """Load project"""
    
    def save_project(self, project: ProjectModel, binary: bool = False):
        """Save project"""
    
    def export_to_cpp(self, project: ProjectModel, output_dir: str) -> Dict:
        """Export to C++"""

ExporterService

python
class ExporterService:
    def can_export(self) -> bool:
        """Check if user can export (requires valid license)"""
    
    def export_project(self, project, output_dir: str) -> Dict:
        """Export project to C++ files"""
        # Auto-detects single/multi-palette

ValidationService

python
class ValidationService:
    def validate_project(self, project: ProjectModel) -> ValidationResult:
        """Validate full project"""
    
    def validate_animations(self, animations) -> ValidationResult:
        """Validate against limits"""

AnimationService

python
class AnimationService:
    def create_animation(self, name: str) -> TileAnimation:
        """Create animation"""
    
    def link_to_tile(self, animation: TileAnimation, base_tile: int):
        """Link animation to tile"""
    
    def export_animations(self, animations, output_dir: str):
        """Export animations to C++"""

C++ Export

Requirements

⚠️ Important: C++ export requires a valid license.

  • No license: Button shows 🔒
  • Other features work without license

Export Options

OptionDescriptionRecommended
C++ NamespaceNamespace for codeProject name
Color DepthBit depth (auto-detect)Auto-detect
Store in FlashSave to PROGMEM✅ Always
Legacy FormatWithout Flash attributesCompatibility only

Export Mode

ModeTriggerGenerated
Single PaletteAll layers use P0Shared palette
Multi-PaletteAny layer P1-P7Per-slot palettes

Generated Files

Single Palette

cpp
// level1.h
extern const uint16_t TILEMAP_PALETTE_DATA[];
extern const pixelroot32::graphics::Sprite4bpp TILESET_SPRITES[];
extern const pixelroot32::graphics::TileMap layer_foreground;

// level1.cpp
static const uint16_t TILEMAP_PALETTE_DATA[] = { /* RGB565 */ };
static const pixelroot32::graphics::Sprite4bpp TILESET_SPRITES[] = { /* tiles */ };
static const uint8_t LAYER_FOREGROUND_INDICES[] = { /* indices */ };

void init() {
    layer_foreground.palette = TILEMAP_PALETTE_DATA;
    layer_foreground.tiles = TILESET_SPRITES;
    layer_foreground.indices = LAYER_FOREGROUND_INDICES;
}

Multi-Palette

cpp
// level1.h
// setBackgroundCustomPaletteSlot(1, PLATFORMS_PALETTE);
extern const uint16_t PLATFORMS_PALETTE[];
extern const uint16_t STAIRS_PALETTE[];
extern const pixelroot32::graphics::Sprite4bpp PLATFORMS_TILESET_SPRITES[];

// level1.cpp
void init() {
    setBackgroundCustomPaletteSlot(1, PLATFORMS_PALETTE);
    setBackgroundCustomPaletteSlot(2, STAIRS_PALETTE);
}

Engine Integration

Single Palette:

cpp
#include "level1.h"

level1::init();
renderer.drawTileMap(level1::layer_background, x, y);

Multi-Palette:

cpp
#include "level1.h"

level1::init();  // Registers palettes
renderer.drawTileMap(level1::background, 0, 0);
renderer.drawTileMap(level1::platforms,  0, 0);

Attributes/Flags:

cpp
// Query attributes
const char* type = level1::get_tile_attribute(0, x, y, "type");

// Query flags
uint8_t flags = level1::behavior_layer_background[y * width + x];
if (flags & TILE_SOLID) { /* collision */ }

Animations:

cpp
level1::get_animation_manager().step();
renderer.drawTileMap(level1::layer_background, x, y);

Data Formats

Palette

  • Format: RGB565
  • Size: 16 colors max
  • Index 0: Transparent (multi-bpp)

Tiles

BPPPer RowColors
1 bpp1 byte2
2 bpp2 bytes4
4 bpp4 bytes16

Index Map

  • 1 byte per cell (uint8_t)
  • Value -1 (editor) = Index 0 (export) = Empty

BPP Auto-Detection

Colors UsedBPPMaximum
1-21 bpp2
3-42 bpp4
5-164 bpp16

Compatibility

Dependencies

PackageMinimum Version
Python3.8+
Tkinter8.6+
ttkbootstrap1.0+
Pillow9.0+

Target Hardware

  • ESP32 (PixelRoot32 engine)
  • Flash: 4MB minimum recommended
  • RAM: 520KB minimum

Glossary

TermDefinition
ENGINE_LIMITSEngine limit constants
ProjectModelProject class
SceneModelScene model
LayerModelLayer model
TileAnimationTile animation model
RGB565Color format (5+6+5 bits)
BPPBits per pixel
PROGMEMESP32 flash storage
Sprite4bpp4bpp sprite
TileMapExported tilemap structure

Released under the MIT License.