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
Intro
Gameplay Programming
Gameplay programming is the code layer between a game engine's reusable systems and the specific rules of one game: what happens when the player presses jump, when a sword hits an enemy, when a quest condition becomes true. The engine supplies rendering, physics, and asset loading. Gameplay programming decides what the game actually does with them, frame by frame.
The game loop and timing
Every real-time game runs a loop that processes input, advances game state, and renders a frame, then repeats. The central design question is how time enters that loop. A variable timestep advances game state by however long the last frame took to render. This is simple, but it makes simulation results depend on frame rate: a physics calculation run in smaller steps on a fast machine accumulates different rounding error than the same calculation run in fewer, larger steps on a slow machine, so the two machines can diverge.
The fixed-timestep pattern fixes this by decoupling simulation from rendering. The loop tracks how much real time has elapsed since the last update in an accumulator variable, often called lag. While that accumulator holds at least one fixed step's worth of time, the loop calls update() and subtracts the step from the accumulator; only after the accumulator runs dry does the loop render a frame, using the leftover fraction of a step to interpolate positions smoothly between the last two simulated states. Gameplay logic and physics run at a constant, predictable rate regardless of how fast the machine renders, which is what makes fixed timestep the standard choice for physics-driven and networked games.
Continue the course
This section is part of the paid course.
See pricing to subscribe, or log in if you already have access.
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/com.unity.inputsystem@1.14/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/com.unity.entities@1.3/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
