liveBook · Manning

Chapter 4: Data and logic

What you will learn in chapter 4 of High Performance Unity Game Development

Introduces the survivor game used to illustrate a data-oriented architecture, distinguishing balance, runtime game data, and logic while outlining the example’s gameplay and pooling constraint.

After this chapter you will be able to

What it builds on

Section by section

Introduction

Introduces the survivor game used to illustrate a data-oriented architecture, distinguishing balance, runtime game data, and logic while outlining the example’s gameplay and pooling constraint.

Key terms: balance, game data, logic, board, game loop, survivor/bullet-heaven game, player, enemies, GameObject pool, preallocate

4.1 Simple DOD Architecture

The section introduces a simple data-oriented game architecture that separates fixed Balance data from changing GameData and assigns distinct roles to Logic, Board, and Game.

Key terms: Balance, GameData, tool time, runtime, Logic, static logic functions, Board, Game, game loop, DOD

4.2 The Balance

This section defines which survivor-game settings belong in Balance, why Balance is a class, and how designers can edit its values.

Key terms: Balance, GameData, class, struct, by value, by reference, NumEnemies, EnemyVelocity, EnemyRadius, enemy arrays

4.3 The GameData

The section defines what the survivor game's GameData stores, why some values are omitted, and how player-centered coordinates and Logic-only updates shape its use.

Key terms: GameData, EnemyPosition, PlayerDirection, GameTime, BestTime, MenuState, enemy velocity, enemy direction, player position, balance

4.4 The Logic

This section establishes Logic as a static class whose methods transform data and provide the intended way to modify GameData.

Key terms: Logic, GameData, static functions, DOD

4.4.1 Logic accessibility

This section defines the boundaries of the static Logic class and frames its public methods in terms of the data they receive, change, and return.

Key terms: Logic, static class, deterministic, self-contained, hidden state, GameData, Balance, pure, mutable runtime state, read-only input

4.4.2 AllocateGameData() - Allocating all the data for our game

This section explains how the game allocates its enemy-position data and why its allocation function takes GameData and Balance rather than individual values.

Key terms: AllocateGameData, GameData, Balance, EnemyPosition, deallocating, reference, multithreading

4.4.3 StartGame() - Initializing our gameplay data

StartGame() prepares the existing GameData for each new play session by resetting gameplay values and positioning every enemy.

Key terms: StartGame(), GameData, Balance, menu state, game time, player direction, enemy arrays, getEnemySpawnPosition(), starting locations

4.4.4 Tick() - Handling frame-by-frame gameplay

This section explains how Logic.Tick() processes one frame of gameplay and passes the resulting changes to the Board for display.

Key terms: Logic.Tick(), Board, GameData, balance, gameOver, game time, out of bounds, enemy-to-enemy collision detection and response, game over, explicit names

4.4.5 Handling user input

This section shows how mouse movement and release update the player's direction in GameData, and why those updates belong in static Logic functions.

Key terms: MouseMove(), GameData, mouse-down position, player direction, Tick(), MouseUp(), zero vector, DOD, static logic function, Game

4.4.6 getEnemySpawnPosition() - Placing an enemy within range of the player

This section explains how getEnemySpawnPosition() uses player movement and a configured spawn radius to choose an enemy spawn position.

Key terms: player direction, up vector, spawn radius, 180-degree arc, getEnemySpawnPosition(), GameData.PlayerDirection, Balance.SpawnRadius, Data-In, Transformation, Data-Out

4.4.7 Functions called by Tick()

This section explains the ordered gameplay operations called by Tick(), from moving and repositioning enemies through collision handling, simulated player movement, and game-over detection.

Key terms: Tick(), Board, gameOver, moveEnemies(), balance, delta time, normalized vector, origin, checkEnemyOutOfBounds(), spawn radius

4.5 Conclusion

Summarizes the roles of the five components in the data-oriented game architecture and the implementation choices for Balance, GameData, and Logic.

Key terms: Balance, GameData, Board, Game loop, Logic, deterministic static functions, game data, data-oriented pattern, class, arrays

4.6 Summary

Summarizes how Balance, GameData, and static Logic divide the game’s rules, changing state, and state updates, then gives guidelines for keeping logic functions clear.

Where this is used later

Concepts explained in this chapter

← Chapter 3: Memory allocations and performance Chapter 5: Game board and game loop →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.