blob: 3066d86906d90467b91a4e59765a6f3da078a069 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
--[[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
|