Computer Application
Computer game
Gamification
Habitica
Gather.town
Emergence
Progression
Gameplay
Mechanics
System
Level
Space
Objects
Actions
Rules
Quake source code: link
Fixed time step
Variable time step
Adaptive time step
Object A reads previous state of Object B and Object B reads previous state of Object C
Scene Graph
Scene Manager
Everything that is specific to the game (and not to the engine).
Any piece of data which is in a format that can be used by the game engine.
All media elements that are presented to the player and protected by copyright.
Provides access to all resources (~assets)
Manages lifetime of each resource
Ensures that only one copy of each resource exists in memory
Loads required resources and unloads those no longer needed
Handles streaming
Level loading
Air locks
World streams
JPEG
PNG
TGA
SVG
Types
Formats
Diffuse
Displacement
Normal
Volumetric
Tileable
Sprite atlas
Sprite
Spritesheet
Sprite atlas
Domain Model
Presentation Model
Physics model
AI model
Networking model
Entity
Component
System
Attribute
By modifying the container object's state
By direct calls
By using a message broker
Unicast
Multicast
Broadcast
Example: Pacman actions
Individual units
Battle formation
1 | const getPlayer(scene: Scene) => scene.findObjectByName('player'); |
2 | |
3 | const getAllUnits(scene: Scene) => scene.findObjectsByTag('unit_basic'); |
4 | |
5 | const getAllUnitsWithinRadius(scene: Scene, pos: Vector, radius: number) => { |
6 | return getAllUnits(scene).filter(unit => unit.pos.distance(pos) <= radius); |
7 | } |
8 | |
9 | const getAllExits(scene: Scene) => { |
10 | const doors = scene.findObjectsByTag('door'); |
11 | return doors.filter(door => !door.locked); |
12 | } |
1 | // stateless, the creature will jump each frame |
2 | updateCreature() { |
3 | if(eventSystem.isPressed(KeyCode.UP)) { |
4 | this.creature.jump(); |
5 | } |
6 | } |
7 | |
8 | // introduction of a state |
9 | updateCreature() { |
10 | if(eventSystem.isPressed(KeyCode.UP) && this.creature.state !== STATE_JUMPING) { |
11 | this.creature.changeState(STATE_JUMPING); |
12 | this.creature.jump(); |
13 | } |
14 | } |
1 | class Builder { |
2 | private _position: Vector; |
3 | private _scale: Vector; |
4 | |
5 | position(pos: Vector) { |
6 | this.position = pos; |
7 | return this; |
8 | } |
9 | |
10 | scale(scale: Vector) { |
11 | this.scale = scale; |
12 | return this; |
13 | } |
14 | |
15 | build() { |
16 | return new GameObject(this._position, this._scale); |
17 | } |
18 | } |
19 | |
20 | new Builder().position(new Vector(12, 54)).scale(new Vector(2, 1)).build(); |
Prefabs in Unity
1 | class UnitFactory { |
2 | |
3 | private pikemanBuilder: Builder; // preconfigured to build pikemans |
4 | private musketeerBuilder: Builder; // preconfigured to build musketeers |
5 | private archerBuilder: Builder; // preconfigured to build archers |
6 | |
7 | public spawnPikeman(position: Vector, faction: FactionType): GameObject { |
8 | return this.pikeman.position(position).faction(faction).build(); |
9 | } |
10 | |
11 | public spawnMusketeer(position: Vector, faction: FactionType): GameObject { |
12 | return this.musketeerBuilder.position(position).faction(faction).build(); |
13 | } |
14 | |
15 | public spawnArcher(position: Vector, faction: FactionType): GameObject { |
16 | return this.archerBuilder.position(position).faction(faction).build(); |
17 | } |
18 | } |
Assets
Asset categories
Dynamics
Features
Attenuation
Occlusion
Obstruction
Uniform distribution
Gaussian (normal) distribution
Uniform distribution
Gaussian distribution
Seed
Loot
Spinning
Rarity Slotting
Random encounter
Perlin Noise
Simplex Noise
Worley Noise
Bounding volume
Spatial data structure
Implementations
Oct-tree
Uniformed graph searches
Cost-based graph searches
Improvements
Addition and subtraction
Vector addition and subtraction
Magnitude
Magnitude of a vector
Normalization
Normal vector
Dot product
Cross product
Projection
Seek
Flee
Arrive
Pursuit
Evade
Wander
Path follow
Body
Rigid Body
Soft body
Shape
Fixture
Constraint
Sensor/Phantom
Rag doll
Destructible object
rope
revolute
prismatic
cone-twist
Applications
Sphere
Capsule
AABB
OBB
k-DOP
Compound shapes
Convex hull
SAT (separating axis theorem)
Stepped world
Continuous Collision Detection (CCD)
Euler angles
Quaternions
Model Space
World Space
View/Camera Space
Clip Space
View/Screen Space
Perspective projection
Orthographic projection
Applications
Main methods
Vertex
Fragment
Texture
Occlusion
Z-Fighting
Culling
Vertex shader
Geometry shader (optional)
Tessellation shader (optional)
Pixel (fragment) shader
ASCIIdent
Compute shader
LOD
Texture mapping
Baking
Textured scene
Baked lights
Result
Game AI features and limits
Game AI properties
1 | // Doom 2: find player to chase |
2 | void A_Look (mobj_t* actor) { |
3 | mobj_t* targ; |
4 | actor->threshold = 0; // any shot will wake up |
5 | targ = actor->subsector->sector->soundtarget; |
6 | if (actor->flags & MF_AMBUSH){ |
7 | if (P_CheckSight (actor, actor->target)) |
8 | goto seeyou; |
9 | } else goto seeyou; |
10 | |
11 | if (!P_LookForPlayers (actor, false)) return; |
12 | // go into chase state |
13 | seeyou: |
14 | P_ChasePlayer(); |
15 | } |
Node Type | Success | Failure | Running |
---|---|---|---|
Selector | If one child succeeds | If all children fail | If one child is running |
Sequence | If all children succeed | If one child fails | If one child is running |
Decorator | It depends | It depends | It depends |
Parallel | If N children succeed | If M-N children succeed | If all children are running |
Action | When completed | Upon an error | During completion |
Condition | If true | If false | Never |
Planning
Supervised learning
Unsupervised learning
Reinforcement learning
Main elements
Other features
Resource Control
Tech tree
Build order (opening)
Fog of war
Micromanagement
Tactics
Strategy
Stream
Snapshot
Event
Action
Procedure Call
Connection messages
Beacon
switch(actionType) {
case OBJECT_CREATED:
int objectType = reader->ReadDWord();
auto factory = creatorManager->FindObjectFactory(objectType);
auto newInstance = factory->CreateInstance(reader); // parse parameters
objects.push_back(newInstance);
break;
case OBJECT_DELETED:
int objectId = reader->ReadDWord();
sceneManager->removeObjectById(objectId);
...
}
Source engine's approach
Wrong
Correct
Time dilation
Deterministic prediction
Dead reckoning
Server-side rewind