--[[Utility classes]] mod = ... class Vec3 new:(x,y,z) => @x = x or 0 @y = y or 0 @z = z or 0 class Vec2 new: (x,y) => @x = x or 0 @y = y or 0 area: () => math.abs(@x * @y) __sub: (a,b) -> Vec2(a.x-b.x,a.y-b.y) __add: (a,b) -> Vec2(a.x + b.x, a.y + b.y) --getmetatable(Vec2).__sub = (a,b) -> --Vec2(a.x-b.x,b.x-b.y) drawable = (c) -> assert(c.sprite or c.anim) anim_co = (a) -> while true a.keyframe = math.floor(am.current_time()*4) % #(a.anim) assert(a.anim[a.keyframe + 1], "Failed to find an appropriate image to draw.") a.node\replace("sprite",am.sprite(a.anim[a.keyframe + 1])\tag "sprite") coroutine.yield() mod["Vec2"] = Vec2 mod["Vec3"] = Vec3 mod