-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdagger.moon
More file actions
63 lines (46 loc) · 1.03 KB
/
dagger.moon
File metadata and controls
63 lines (46 loc) · 1.03 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class Dagger extends Entity
lazy sprite: -> Spriter "images/dagger2.png", 10, 10
w: 2
h: 8
ox: 4
oy: 1
on_ground: false
new: (x,y, vel, @callback) =>
super x, y
@anim = @sprite\seq { 0,1,2,3,4,5,6 }, 0.05
@stopped = @sprite\seq { 7 }
@vel = vel
update: (dt, @world) =>
@anim\update dt
@vel += @world.gravity * dt
-- air resistance
if @vel[1] != 0
@vel[1] = dampen @vel[1], dt * 20
vx, vy = unpack @vel
cx, cy = @fit_move vx * dt, vy * dt, @world
if cy
if @vel[2] > 0
@vel[1] = 0
if not @on_ground
AUDIO\play "clink"
@callback and @callback!
@on_ground = true
@vel[2] = 0
if cx
if @vel[1] != 0
AUDIO\play "clink"
@vel[1] = -@vel[1] / 1.5
true
draw: =>
if @shader
@shader\render @\draw_without_shader
else
@draw_without_shader!
draw_without_shader: =>
if @on_ground
@stopped\draw @x - @ox, @y - @oy
else
@anim\draw @x - @ox, @y - @oy
{
:Dagger
}