SpriteAnimation.lua
Tile.lua
Neo3D.lua
QuadTree.lua
Widget.lua
Sprite.lua
Collision.lua
OEntity.lua
Button.lua
Graphics2D.lua
InputField.lua
LuaUnit.lua
Tests.lua
OCamera.lua
Object3d.lua
class.lua
OLight.lua
SpriteSheet.lua
OSound.lua
Utils.lua
Canvas.lua
Label.lua
Api.lua

Utilities

This file contains various utility functions.

function Utils.vectorLength(dx,dy)

Calculates the length of the given vector

Parameter

dx

The X component

dy

The Y component

Return: The length as a number.

function Utils.distanceBetween(a,b)

Calculates the distance between two vec2's

FIXME: Should use plain arrays instead of "a.x" etc.

Parameter

a

The first vector

b

The second vector

Return: The distance as a number.

function Utils.angleBetween(a,b,asDegrees)

Calculates the angle (in radians) between an two vectors.
The angle is calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)

Parameter

a

The first vector as vec2

b

The second vector as vec2

asDegrees

A boolean specifying the return format (degrees vs. radians)

Return: The angle in radians or degrees

function Utils.round(value)

Round a number towards zero

Parameter

value

A number

Return: The rounded number as an integer

function Utils.clamp(value,min,max)

Clamps a number between the given limits

Parameter

value

The value

min

The minimal value

max

The maximal value