Game Development Reference
In-Depth Information
body.testOverlap : This function tests if the physics body intersects with a given
physics body.
body.testPoint : This function can be used to determine if a world point is inside
of the body.
Vector Math
Codea has built-in vector math functionality. There are two types of vector structures: vec2 and
vec3 . The vec2 structure has functions for 2D vector math, and vec3 has functions for 3D math.
The functions available are similar, but vec2 takes two arguments while vec3 takes three arguments.
angleBetween
The angleBetween function returns the angle in radians, and it takes the other point to determine the
angle between the two points, as a vec2 point.
v1 = vec2(100,100)
angle = math.deg(v1:angleBetween(vec2(100,200)))
print(angle)
cross
The cross function returns the cross product between two vec2 types.
v1 = vec2(1,1)
vec = v1:cross(vec2(2,5))
print(vec)
dist
The dist function returns the distance between the two vectors.
v1 = vec2(1,1)
vec = v1:dist(vec2(2,5))
print(vec)
distSqr
The distSqr function returns the squared distance between two vectors.
v1 = vec2(1,1)
vec = v1:distSqr(vec2(2,5))
print(vec)
dot
The dot function returns the dot product of two vectors.
v1 = vec2(1,1)
vec = v1:dot(vec2(2,5))
print(vec)
 
Search WWH ::




Custom Search