HGE Engine Overview

Understanding the architecture, features, and capabilities of the HGE 2D game engine.

HGE Engine Overview

What is HGE?

HGE (Haaf's Game Engine) is a hardware accelerated 2D game engine for Windows, designed to make game development fast and straightforward. It handles the complex details of graphics rendering, audio playback, input processing, and resource management so developers can focus on building gameplay.

The engine uses DirectX for rendering, providing smooth performance with features like alpha blending, rotation, and scaling for sprites. A game engine like HGE abstracts away platform-specific complexity, giving developers a consistent API to work with.

Core Components

Graphics System

The rendering system is built on DirectX and provides:

  • Sprite rendering with rotation, scaling, and color modulation
  • Alpha blending for transparency effects
  • Render targets for off-screen rendering and effects
  • Texture management with automatic batching for performance
  • Distortion meshes for advanced visual effects
  • Line and primitive rendering for debugging and UI

Sprites can be loaded from common image formats including PNG, JPG, BMP, and TGA. The engine handles texture loading, caching, and memory management automatically.

Audio System

HGE includes a complete audio subsystem supporting:

  • Music streaming — Play long audio tracks without loading entirely into memory
  • Sound effects — Quick playback of short audio samples
  • Volume and panning control — Adjust audio properties in real-time
  • Multiple simultaneous sounds — Layer effects and music naturally

Audio files can be in WAV, MP3, OGG, or other common formats. The system is designed to be simple to use while still providing the control needed for game audio.

Input Handling

The input system captures:

  • Keyboard — Key states, key presses, and text input
  • Mouse — Position, button states, and wheel input
  • Joystick/Gamepad — Button and axis reading (where supported)

Input can be polled each frame or handled through event callbacks, depending on your game's needs.

Resource Management

HGE provides a resource manager that:

  • Loads assets on demand from disk or archives
  • Caches resources to avoid redundant loading
  • Supports resource scripts for organized asset definitions
  • Handles cleanup when resources are no longer needed

This system keeps asset management organized and efficient, especially as projects grow larger.

Architecture Overview

HGE architecture diagram

HGE uses a simple callback-based architecture:

  1. Initialization — Set up engine parameters and create the window
  2. Frame function — Called each frame for game logic updates
  3. Render function — Called each frame for drawing
  4. Shutdown — Clean up resources when the game exits

This separation keeps logic and rendering organized while allowing flexibility in how you structure your game.

// The frame function handles game logic
bool FrameFunc()
{
    float dt = hge->Timer_GetDelta();
    
    // Update game state
    UpdatePlayer(dt);
    UpdateEnemies(dt);
    CheckCollisions();
    
    // Return true to exit the game
    return hge->Input_GetKeyState(HGEK_ESCAPE);
}

// The render function handles drawing
bool RenderFunc()
{
    hge->Gfx_BeginScene();
    hge->Gfx_Clear(0);
    
    // Draw game elements
    DrawBackground();
    DrawEnemies();
    DrawPlayer();
    DrawUI();
    
    hge->Gfx_EndScene();
    return false;
}

Key Features

Particle System

HGE includes a powerful particle system for creating effects like fire, smoke, explosions, and magic. Particles can be designed using the included particle editor, then loaded and played back in your game with minimal code.

Animation Support

The hgeAnimation class extends sprites with frame-based animation. Define frame layouts in a texture, set timing, and the engine handles playback.

Font Rendering

Bitmap fonts allow text rendering with custom styles. HGE can load font definitions from files, making it easy to use designer-created fonts in your game.

Helper Classes

Beyond the core engine, HGE provides helper classes for common game development needs:

  • hgeSprite — Texture region with rendering methods
  • hgeAnimation — Frame-based sprite animation
  • hgeFont — Bitmap font rendering
  • hgeParticleSystem — Particle effect playback
  • hgeDistortionMesh — Grid-based image distortion
  • hgeStringTable — Localization support
  • hgeGUI — Basic GUI framework

System Requirements

HGE targets Windows systems with DirectX support:

  • Windows OS (XP and later)
  • DirectX 8.0 or later runtime
  • A graphics card with DirectX support

The engine is designed to run well on a wide range of hardware, including older systems.

Typical Use Cases

HGE is well-suited for:

  • 2D arcade games — shooters, platformers, puzzle games
  • Casual games — simple, polished experiences
  • Game prototypes — quick iteration on game concepts
  • Learning projects — understanding game engine architecture

The engine provides enough capability for complete games while remaining approachable for developers learning game programming.

Getting Started

Ready to build something? Here's your path forward:

  1. Read the Downloads page to get the SDK
  2. Follow the IDE setup guide for your environment
  3. Study the API documentation for reference
  4. Explore the demo projects for practical examples

Frequently Asked Questions

  • What programming language does HGE use?

    HGE is a C++ engine. You write your games in C++ using the HGE API.

  • Can I make commercial games with HGE?

    Check the license page for current usage terms and any restrictions.

  • Does HGE support 3D graphics?

    HGE is a 2D engine. While you can achieve some pseudo-3D effects with distortion meshes and layering, it's not designed for 3D rendering.

  • Is HGE still being maintained?

    This documentation portal provides resources for working with HGE. Check the community forum for the latest discussions and activity.

  • How do I get help with HGE?

    Visit the community forum for troubleshooting help, code examples, and discussions with other developers.