Defense Grid Run

Defense Grid Run is a Pac-Man-style military defense game that demonstrates the GVA external application interface while providing an entertaining stealth navigation experience for operator training and recreation.

Joystick Required

Defense Grid Run requires a joystick or gamepad to play due to its more complex controls (8-directional movement, EMP activation, pause menu navigation). The standard HMI soft keys provide limited functionality for this game.

Defense Grid Run Welcome Screen

Gameplay in action:

Defense Grid Run Gameplay

Overview

Defense Grid Run is a maze navigation game where players control a stealth drone to collect intel packets while avoiding autonomous defense bots. It showcases:

  • External application registration
  • Display rendering via Qt Quick vector graphics
  • Soft key input handling
  • Game state management
  • AdLib sound synthesis integration
  • GVA alarm system integration

Gameplay

Objective

Navigate the defense grid maze, collect all intel packets, and avoid detection by defense bots. Use EMP bursts strategically to stun enemies and create safe passage.

Controls

Keyboard Controls

Key Function
↑ ↓ ← → Move drone
W A S D Move drone (alternate)
SPACE Activate EMP burst
ESC / P Pause game
ENTER Start game / Select menu
F11 / F Toggle fullscreen

HMI Soft Key Controls

Soft Key Function
1 (↑) Move up
2 (↓) Move down
3 (←) Move left
4 (→) Move right
5 EMP burst
6 Pause / Exit

Scoring

Item Points
Intel Packet 100
Level Bonus Level × 500

Defense Bots

The game features three types of defense bots with different AI behaviors:

Type Appearance Behavior
Patrol Bot Red hexagon Follows fixed patrol routes along corridors
Pursuit Bot Orange hexagon Actively chases player when detected within 150 pixels
Guard Bot Yellow hexagon Moves slowly toward player when they approach

All bots can be temporarily stunned using EMP bursts.

Power-ups

  • EMP Burst: Electromagnetic pulse that stuns all enemies temporarily (3 seconds)
  • Limited charges - use wisely!
  • Earn additional charges by completing levels (max 3)

Game Architecture

Application Flow

sequenceDiagram participant Op as Operator participant HMI as HMI participant DDS as DDS Network participant Game as Defense Grid Run participant Audio as AdLib Synth Note over Game: Game starts Game->>DDS: Register application Game->>DDS: Set operational mode ON Game->>DDS: Set soft key labels Note right of Game: UP, DOWN, LEFT, RIGHT, EMP, PAUSE DDS->>HMI: Update menus Op->>HMI: Select Defense Grid Run HMI->>DDS: Activate app DDS->>Game: Application active Game->>Game: Display title screen Game->>Audio: Start ambient music Op->>HMI: Press ENTER to start HMI->>DDS: Key event (ENTER) DDS->>Game: Start game Game->>Game: Generate maze Game->>Game: Spawn intel packets Game->>Game: Spawn defense bots loop Game loop (60 FPS) Game->>Game: Update player position Game->>Game: Update enemy AI Game->>Game: Check collisions Game->>Game: Update particles & effects alt Intel collected Game->>Audio: Play intel pickup sound Game->>Game: Add score Game->>DDS: Raise score alarm end alt Player hit by bot Game->>Audio: Play hit sound Game->>Game: Lose life Game->>DDS: Raise caution alarm end alt EMP activated Game->>Audio: Play EMP burst Game->>Game: Stun all enemies end end alt All intel collected Game->>Audio: Play level complete Game->>Game: Next level end alt Lives = 0 Note over Game: Game over Game->>Audio: Play game over Game->>DDS: Raise game over alarm Game->>DDS: Display final score end Op->>HMI: Press EXIT HMI->>DDS: Key event DDS->>Game: Deactivate Game->>DDS: Set operational mode OFF

State Machine

stateDiagram-v2 [*] --> Title : App starts Title --> Playing : ENTER pressed Playing --> Paused : ESC/PAUSE Paused --> Playing : Resume selected Paused --> Title : Quit selected Playing --> Victory : All intel collected Victory --> Playing : Next level Playing --> GameOver : Lives = 0 GameOver --> Title : ENTER pressed Title --> [*] : EXIT

Implementation Details

Maze Generation

The game uses a simple but effective maze generation algorithm:

  1. Initialize grid with walls (1s)
  2. Carve paths at odd coordinates (0s)
  3. Create random connections between paths
  4. Ensure starting area (top-left 3×3) is accessible

This creates a classic maze with corridors and intersections suitable for strategic navigation.

Enemy AI

Patrol Bot

// Follows directional movement (up/down/left/right)
// Changes direction on wall collision
// Speed: 80 pixels/second
// Predictable but constant threat

Pursuit Bot

// Detects player within 150 pixel radius
// Actively chases player using simple pathfinding
// Speed: 100 pixels/second
// Raises alert level when pursuing

Guard Bot

// Stationary until player approaches within 90 pixels
// Moves slowly toward player when detected
// Speed: 56 pixels/second (70% of patrol speed)
// Guards key areas and corridors

Vector Graphics

All game elements are rendered using Qt Quick Shapes for crisp, scalable graphics:

  • Stealth Drone: Diamond shape with directional indicator and pulsing core
  • Defense Bots: Hexagons with colored outlines and scanner eyes
  • Intel Packets: Rotating squares with "I" symbol and pulsing glow
  • Maze Walls: Rectangles with grid pattern and neon borders
  • EMP Effect: Expanding circular pulse with cyan glow

HUD Layout

The HUD displays information in all four corners to keep the central playfield clear:

Top-Left:

  • Current score (8-digit display)
  • High score
  • Current level

Top-Right:

  • Lives remaining (drone icons)
  • EMP charges (3 max)

Bottom-Left:

  • Intel collected / total

Bottom-Right:

  • Game timer (MM:SS format)
  • Alert level bar (0-3 scale)

Top-Center:

  • Radar pulse animation
  • Sweeping radar arm

Sound Integration

Defense Grid Run uses the AdLib synthesizer for authentic retro sound effects:

Sound Cue Trigger Description
Ambient music Gameplay start Continuous low-intensity background
Radar ping Every 2 seconds Brief electronic pulse
Intel pickup Collectible obtained Success chime
EMP burst EMP activation Sharp electronic blast
EMP fade EMP expiring Descending tone
Enemy stunned Bot hit by EMP Impact sound
Player detected Bot pursuit starts Warning alarm
Player hit Collision with bot Damage sound
Level complete All intel collected Victory fanfare
Game over Lives depleted Defeat tone

Running the Game

From HMI

  1. Start GVA services:
./run_gva_defense_grid_run.sh
  1. Navigate to Function Select in HMI
  2. Select "External Apps"
  3. Choose "Defense Grid Run"
  4. Press ENTER to start

Standalone (Development)

cd build/bin
./gva-qt6-app-defense-grid-run

The game will start in fullscreen mode. Use F11 or F key to toggle fullscreen.

Building

Defense Grid Run is built as part of the LDM SDK:

./build.sh

Requirements

  • Qt6 (Core, Gui, Qml, Quick, QuickControls2)
  • C++17 compiler
  • CMake 3.16+
  • Optional: Qt6 Multimedia for enhanced sound
  • Optional: ldm10 for DDS integration

Build Targets

cd build
make gva-qt6-app-defense-grid-run

Configuration

Game settings are optimized for 60 FPS gameplay:

Setting Value
Player Speed 150 px/s
Patrol Bot Speed 80 px/s
Pursuit Bot Speed 100 px/s
Guard Bot Speed 56 px/s
EMP Duration 3 seconds
EMP Cooldown 10 seconds
Detection Range 150 pixels
Starting Lives 3
Starting EMP 1 charge
Cell Size 32 pixels
Radar Interval 2 seconds

Educational Value

Defense Grid Run demonstrates several GVA integration concepts:

  1. Registration - Proper LDM10 application lifecycle with resource ID allocation
  2. Display Rendering - Pure vector graphics using Qt Quick Shapes
  3. Input Handling - Dual input system (keyboard + HMI soft keys)
  4. State Management - Complex game state machine with pause/resume
  5. Sound Integration - AdLib synthesizer for retro sound effects
  6. Alarm System - GVA alarm raising for game events (player hit, score updates, game over)
  7. Resource Management - Clean shutdown with operational mode transitions
  8. AI Implementation - Three distinct enemy behavior patterns
  9. Collision Detection - Grid-based maze collision system
  10. Particle Effects - Dynamic particle system for visual feedback

Code Structure

Developers can learn from the modular architecture:

  • GameController: Core game logic with fixed timestep (60 FPS)
  • GameWindow: Qt Quick window with keyboard/mouse input
  • RegistrationManager: DDS integration for HMI communication
  • QML Components: Reusable vector graphics components
  • MazeLogic.js: Maze generation and pathfinding utilities

Tips & Strategies

  • Listen for radar pings to time your movements
  • Use EMP strategically - charges are limited!
  • Pursuit bots are fastest - avoid when possible
  • Guard bots block corridors - plan your route
  • Alert level rises when detected - enemies become more aggressive
  • Collect all intel for maximum score and level bonus
  • Corner camping can be effective but risks getting trapped

License

Copyright (c) 2025, Astute Systems PTY LTD

Licensed under the commercial licence provided in the root source directory.