structVec2
struct Vec2
x: float
y: float
endvec: 2D points and directions for games. use "vec.jamo"
A Vec2 is an x and a y. Every method gives back a new Vec2 and leaves the one it's called on alone, so p.plus(speed) doesn't change p. Angles are in radians, counting from the x axis toward the y axis, so on a screen, where y goes down, a growing angle turns clockwise.
struct Vec2
x: float
y: float
endfunc vec2(x: float, y: float): Vec2
func vec2_from_angle(angle: float, length: float): Vec2
A direction of the given length, like vec2_from_angle(pi() / 2.0, 3.0) for 3 straight down a screen
func Vec2.plus(other: Vec2): Vec2
func Vec2.minus(other: Vec2): Vec2
func Vec2.times(amount: float): Vec2
func Vec2.dot(other: Vec2): float
func Vec2.length(): float
func Vec2.distance(other: Vec2): float
func Vec2.normalized(): Vec2
The same direction with a length of 1. A Vec2 of length 0 has no direction, so it stays 0
func Vec2.angle(): float
The angle it points at, from -pi to pi
func Vec2.rotated(angle: float): Vec2
func Vec2.lerp_to(other: Vec2, part: float): Vec2
Part of the way to other: 0.0 gives this one, 1.0 gives other
func Vec2.limited(longest: float): Vec2
At most this long, keeping its direction, for things like a top speed