Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Camera ¶
type Camera struct { Target Target MaxDist float64 MaxSpeed float64 Ease geo.EaseFn // Shaker is optional. Set its fields and call the Camera's StartShake functions. If // Shaker.Falloff is nil then the Shaker's ShakeConst is used. Shaker geo.Shaker // contains filtered or unexported fields }
Camera manages a 2-D camera. If its distance from Target is greater than MaxDist when Update is called then its position is moved directly toward the target so that the distance is equal to MaxDist. If the Camera is less than MaxDist then its velocity is directly toward the Target with a magnitude that is a percentage of MaxSpeed determined by the Ease function. The Ease function is given the ratio <distance to Target>/MaxDist and the return value is multiplied by MaxSpeed.
func New ¶
New creates, initializes, and returns a new Camera. The parameters width and height are the dimensions of the image tha Camera will be used to draw to. The default Ease fuction is linear, MaxSpeed=0, and MaxDist=0. This results in perfectly sticking to the Target, though MaxDist=0 on its own is sufficient for that behavior.
func (*Camera) ScreenCoords ¶
ScreenCoords takes a position in world coordinates and returns its position on the screen.