← Devblog

Sprite tool added

A new developer tool for inspecting game sprites and animations in real-time. The sprite tool provides a visual interface for browsing texture packs, viewing individual sprites, and testing animations — essential for debugging graphics issues and verifying asset loading.

Sprite tool demo

Initial Implementation

The sprite tool was developed over three days in January 2025, starting with basic infrastructure (January 8) and rapidly expanding with features. The initial commit created src/dev/sprite_tool.cpp with 64 lines of ImGui-based UI code that displayed image pack names and animation entries in a tree view.

The tool integrates with the existing imagepak_holder system, iterating through g_image_data->common to enumerate all loaded texture packs. Each pack exposes a names() list containing animation identifiers like "walk_n", "work", "base", etc.

Core Features

The sprite tool window displays a two-column table with expandable tree nodes:

Progressive Enhancements

Three rapid iterations (January 9-10) added critical functionality:

Walk Animation System

The walk animation feature required special handling because character movement sprites consist of 8-12 frames per direction (north, east, south, west). The tool now:

This required adding a new sprite_frame_count() helper to src/graphics/image.h to query frame metadata from the image system.

Use Cases

The sprite tool proved immediately useful for several development tasks:

Technical Implementation

The tool uses ImGui's table and tree node APIs for the UI structure:

if (ImGui::BeginTable("split", 2, ImGuiTableFlags_BordersOuter | ImGuiTableFlags_Resizable)) {
    for (const auto &imgpak : g_image_data->common) {
        if (imgpak.name.empty()) continue;

        bool pack_open = ImGui::TreeNodeEx(imgpak.name, ImGuiTreeNodeFlags_DefaultOpen);
        if (pack_open) {
            // Display animations and sprites
            ImGui::TreePop();
        }
    }
    ImGui::EndTable();
}

The tool is registered with the debug console system via ANK_REGISTER_PROPS_ITERATOR(dev_sprite_tool), making it accessible through the in-game developer menu. A checkbox toggle controls visibility: ImGui::Checkbox("Sprites", &_debug_sprites_open).

Integration with Debug Console

The sprite tool follows the same pattern as other debug tools in the engine. It's invoked from src/platform/akhenaten.cpp and integrates with the widget/debug_console.h system. The two-phase rendering (header checkbox, then content window) allows the tool to be toggled on/off without losing state.

Future Enhancements

Later commits (not part of the initial January 10 release) added even more features:

Result

The sprite tool significantly improved the development workflow for graphics-related tasks. What previously required manual inspection of .sg3 files or trial-and-error with image IDs can now be done visually in seconds. The tool remains one of the most frequently used debug utilities during active development.

← Previous: Works in browser Next: Base class for Hyena animal →