ReferenceVerse
Math Clamp
math clamp
Updated
math-clamp in ~90 seconds.Your pirate cannon on the Obsidian Arch just fired, spiking the heat to 150, but instead of exploding, it safely caps at 100.
That’s the Clamp function holding your game state together, pinning any value strictly between a minimum and maximum bound.
We declare our overheating CannonHeat at 150, set our zero and one-hundred limits, and Clamp snaps it right down to the max safe limit.
Reach for Clamp whenever you have a gauge, health bar, or speed that must never cross a hard floor or ceiling.
var CannonHeat : int = 150
MinHeat : int = 0
MaxHeat : int = 100
SafeHeat := Clamp(CannonHeat, MinHeat, MaxHeat)
Build your own lesson with math-clamp
Generate a personalized, compile-checked lesson grounded in this exact reference.
Build a lesson →