最后活跃于 1734909430

capitalex's Avatar capitalex 修订了这个 Gist 1734909430. 转到此修订

1 file changed, 40 insertions

zombies.nv(文件已创建)

@@ -0,0 +1,40 @@
1 + |#port, on draw zombie
2 + , needs, @draw zombie
3 + , reads, @zombie index|
4 + |#port body, on draw zombies, lua|
5 + local zombies = state.zombies
6 + love.graphics.setColor(0.145, 0.133, 0.169)
7 + love.graphics.circle("fill", zombie.x + 5, zombie.y + 5, zombie.r)
8 +
9 + love.graphics.setColor(0.882, 0.314, 0.282)
10 + love.graphics.circle("fill", zombie.x, zombie.y, zombie.r)
11 + love.graphics.setColor(1, 1, 1)
12 +
13 + |#port, on zombie track player
14 + , needs, @zombie track player
15 + , reads, @zombie index|
16 + |#port body, on zombie track player, lua|
17 + local player = state.player
18 + local zombie = state.zombies[zombie_index]
19 + zombie.angle = math.atan2(player.y - zombie.y, player.x - zombie.x)
20 +
21 + |#port, on move zombie
22 + , needs, @move zombie
23 + , reads, @zombie index|
24 + |#port body, on move zombie, lua|
25 + local zombie = state.zombes[zombie_index]
26 + zombie.x = zombie.x + state.dt * math.cos(zombie.angle) * 310
27 + zombie.y = zombie.y + state.dt * math.sin(zombie.angle) * 310
28 +
29 + |#port, on get zombie count, needs, @get zombie count|
30 + @zombie count
31 + |#port body, on get zombie count, lua|
32 + counters["@zombie count"] = #state.zombies
33 +
34 + |#port, on is zombie dead
35 + , needs, @is zombie dead
36 + , reads, @zombie index|
37 + @zombie is dead
38 + |#port body, on is zombie dead, lua|
39 + local zombie = state.zombies[zombie_index]
40 + counters["@zombie is dead"] = zombie.dead and 1 or 0
上一页 下一页