Gameplay Programming
Gameplay programming is the code that turns a game engine into a playable game: character movement, AI decisions, menus reacting to input, and the rules that decide what happens when things collide.
itSoftware engineering | OpenSkills.info
Recommended first:game-engine-fundamentals
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Don't Panic
Don't Panic — Gameplay Programming
Gameplay programming is the bit that tells an engine what the game means. The engine can draw a heroic sword, load an extremely heroic sword texture, and simulate the sword falling down some stairs. Gameplay code decides whether it hits an enemy, opens a door, or becomes a pickup that immediately causes three more problems.
The useful mental model starts with time. A game loop reads input, changes state, and renders the result. Fixed timestep means the simulation advances in equal-sized steps even when rendering does not. The renderer produces time; the simulation consumes whole steps from an accumulator. That separation keeps physics and rules predictable instead of making them depend on whichever machine had a busy afternoon.
Then comes composition. A character is not obliged to become a gigantic class containing movement, health, sound, collision, and a small cupboard for unrelated features. Components split those responsibilities into pieces attached to an object, node, or entity. The pieces still need a way to cooperate, which is where shared state, direct references, and messages earn their keep—and occasionally conceal the order in which something happened.
Conditional behavior needs a shape too. A finite state machine gives a character one active mode, such as grounded, jumping, or ducking, with defined transitions. It prevents the classic situation where a character is both crouching and standing because several booleans have formed a committee. When NPC decisions need layered alternatives rather than a short list of modes, a behavior tree combines choices, sequences, tasks, and a blackboard of shared facts.
Input and reactions are deliberately indirect. A command lets a physical button become an action such as Jump, so rebinding changes a mapping rather than the gameplay rule. An observer or signal lets UI, sound, and achievements react to an event without the combat code knowing their addresses. Physics then reports contact; gameplay decides whether it is a solid collision or a trigger for a pickup, checkpoint, or zone. This is the point at which a game stops being a collection of systems and starts behaving like somebody planned it.
Read the intro for the complete architecture and engine comparisons. Use the slides to keep the loop, components, state, and event relationships in one view. The cheatsheet is for callback order and quick comparisons. The practice reference supplies pattern skeletons; the exercise makes their timing and trigger behavior visible in a small scene. Field Notes covers the expensive surprises hiding behind otherwise sensible abstractions.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://gameprogrammingpatterns.com/contents.html
Supports
- Catalog of design patterns referenced throughout the course
- https://gameprogrammingpatterns.com/game-loop.html
Supports
- Fixed-timestep accumulator pattern and why a variable timestep destabilizes physics/networking
- https://gameprogrammingpatterns.com/update-method.html
Supports
- Update Method pattern, collection-modification-during-iteration pitfall, sequential update order dependency
- https://gameprogrammingpatterns.com/state.html
Supports
- Finite state machines, the State design pattern, hierarchical and concurrent state machines, FSM limits vs. behavior trees
- https://gameprogrammingpatterns.com/component.html
Supports
- Component pattern, composition over inheritance, component communication approaches, relation to ECS
- https://gameprogrammingpatterns.com/observer.html
Supports
- Observer pattern mechanics and typical uses (achievements, UI, audio)
- https://gameprogrammingpatterns.com/command.html
Supports
- Command pattern for input remapping, undo/redo, and replay/AI reuse
- http://docs.unity3d.com/Manual/execution-order.html
Supports
- Unity script execution order (Awake, OnEnable, Start, FixedUpdate, Update, LateUpdate, OnDisable, OnDestroy)
- https://docs.unity3d.com/Packages/[email protected]/manual/Workflow-Actions.html
Supports
- Action-based input workflow, Input Actions, Bindings, device-independent gameplay code
- https://docs.unity3d.com/Manual/class-ScriptableObject.html
Supports
- ScriptableObject as a data container distinct from MonoBehaviour, used for data-driven design
- https://docs.unity3d.com/2022.3/Documentation/Manual/collider-interactions-other-events.html
Supports
- Collision vs. trigger event requirements and OnCollisionEnter/OnTriggerEnter callback behavior
- https://docs.unity3d.com/Packages/[email protected]/manual/index.html
Supports
- Unity Entities package as a data-oriented ECS implementation
- https://dev.epicgames.com/documentation/en-us/unreal-engine/gameplay-framework-in-unreal-engine
Supports
- Actor, Pawn, Character, Controller (PlayerController/AIController), GameMode, GameState, PlayerState, HUD and their ownership relationships
- https://dev.epicgames.com/documentation/en-us/unreal-engine/behavior-trees-in-unreal-engine
Supports
- Behavior Tree and Blackboard structure and use for AI decision-making
- https://docs.godotengine.org/en/stable/getting_started/step_by_step/signals.html
Supports
- Signals as Godot's Observer-pattern implementation; declaring, emitting, and connecting signals
- https://docs.godotengine.org/en/stable/tutorials/scripting/pausing_games.html
Supports
- SceneTree.paused and per-node process_mode for pause handling
- https://docs.godotengine.org/en/stable/tutorials/animation/animation_tree.html
Supports
- AnimationNodeStateMachine transitions and code-driven state control via travel()
- https://www.gamedeveloper.com/design/the-pac-man-dossier
Supports
- Pac-Man ghost scatter/chase/frightened state machine (1980 timeline milestone)
- https://en.wikipedia.org/wiki/QuakeC
Supports
- QuakeC as a 1996 scripting language separating Quake's game logic from engine code
- https://en.wikipedia.org/wiki/Unreal_Engine_1
Supports
- Original Unreal's May 1998 release and UnrealScript as its gameplay scripting language
- https://www.lua.org/history.html
Supports
- Grim Fandango as one of the first commercial games built on Lua
- https://en.wikipedia.org/wiki/Grim_Fandango
Supports
- Grim Fandango's October 1998 release date and its GrimE engine built on Lua
- https://www.gamedeveloper.com/programming/gdc-2005-proceeding-handling-complexity-in-the-i-halo-2-i-ai
Supports
- Halo 2 AI architecture and its influence on the adoption of behavior trees in game AI
- https://en.wikipedia.org/wiki/Unity_(game_engine)
Supports
- Unity 1.0's June 2005 release at Apple WWDC and its goal of accessible engine tooling
- https://en.wikipedia.org/wiki/Unreal_Engine_4
Supports
- Unreal Engine 4's March 2014 release and Blueprint visual scripting as a Kismet successor
- https://unity.com/blog/community/unity-unveils-2018-roadmap-at-gdc
Supports
- Unity's GDC 2018 announcement of ECS, the C# Job System, and the Burst compiler as "performance by default"
- https://github.com/sindresorhus/awesome
Supports
- Discovery of the MagicTools game-development awesome list
- https://github.com/ellisonleao/magictools
Supports
- Discovery of EnTT, Fluent Behaviour Tree, Ink, and DotRecast as ecosystem tooling
- https://github.com/skypjack/entt
Supports
- EnTT as a C++ ECS library and its entity/component/system model
- https://github.com/ashleydavis/Fluent-Behaviour-Tree
Supports
- Fluent Behaviour Tree as a C# behavior tree library with a fluent builder API
- https://www.inklestudios.com/ink/
Supports
- Ink as a scripting language for branching interactive narrative
- https://github.com/ikpil/DotRecast
Supports
- DotRecast as a C# port of Recast & Detour for navmesh generation and pathfinding
- https://box2d.org/
Supports
- Box2D as a 2D physics engine providing collision detection and rigid body dynamics
- https://unity.com/
Supports
- Unity Landscape entry
- https://www.unrealengine.com/
Supports
- Unreal Engine Landscape entry
- https://www.unrealengine.com/license
Supports
- Unreal Engine licensing model (free with royalty above revenue threshold, source available)
- https://godotengine.org/
Supports
- Godot Landscape entry
- https://gamemaker.io/
Supports
- GameMaker Landscape entry and its object/event gameplay model
- https://www.construct.net/
Supports
- Construct Landscape entry and its visual event-sheet model
- https://defold.com/
Supports
- Defold Landscape entry, its Lua scripting, and free/open licensing
- https://www.cocos.com/creator
Supports
- Cocos Creator Landscape entry and its TypeScript component model
- https://create.roblox.com/docs/luau
Supports
- Roblox Studio Landscape entry and Luau as its gameplay scripting language
- https://bevy.org/
Supports
- Bevy Landscape entry and its Rust ECS architecture
- https://o3de.org/
Supports
- O3DE Landscape entry, its Gems system, and open-source licensing
- https://hutonggames.com/
Supports
- PlayMaker Landscape entry as a visual finite-state-machine editor for Unity
- https://odininspector.com/
Supports
- Odin Inspector Landscape entry and its Unity serialization/inspector extension role
- https://opsive.com/products/behavior-designer/
Supports
- Behavior Designer Landscape entry as a Unity behavior tree editor
- https://www.yarnspinner.dev/
Supports
- Yarn Spinner Landscape entry, its dialogue scripting language, and engine integrations
- https://www.articy.com/en/
Supports
- articy:draft Landscape entry and its narrative-data export role
- https://gafferongames.com/post/fix_your_timestep/
Supports
- Fixed-timestep accumulator behavior under variable render rates, interpolation, and the need to cap an excessive frame-time contribution
- https://www.gamedeveloper.com/programming/designing-for-predictability
Supports
- Explicit component update order, pause-transition divergence, and replay compatibility when gameplay constants change
- https://www.gamedeveloper.com/programming/programming-responsiveness
Supports
- How input, logic, physics, events, rendering, and buffering accumulate visible input latency
- https://www.gamedeveloper.com/business/the-game-is-the-boss-a-i-resogun-i-postmortem
Supports
- Dependency-resolved gameplay tasks and repeated-input CRC checks for detecting deterministic simulation divergence
