game-arch-patterns
Installation
SKILL.md
Game Architecture Patterns
Fixed Timestep Game Loop with Accumulator
# Fixed physics timestep decoupled from variable render rate
# Based on Glenn Fiedler's "Fix Your Timestep!" (2004)
class_name GameLoop extends Node
const PHYSICS_DELTA: float = 1.0 / 60.0 # Fixed 60Hz physics
const MAX_DELTA: float = 0.25 # Spiral-of-death prevention
var _accumulator: float = 0.0
var _previous_time: float = 0.0
var _alpha: float = 0.0 # Interpolation factor for rendering
func _ready() -> void:
_previous_time = Time.get_ticks_msec() / 1000.0