Son aktivite 1734926456

zombie-more-vera.nv Ham Playground
1|#port, on draw zombie
2 , needs, @draw zombie
3 , reads, @zombie index|
4|#port body, on draw zombie, lua|
5 print("DRAWING ZOMBIE", zombie_index)
6 local zombie = state.zombies[zombie_index]
7 love.graphics.setColor(0.145, 0.133, 0.169)
8 love.graphics.circle("fill", zombie.x + 5, zombie.y + 5, zombie.r)
9
10 love.graphics.setColor(0.882, 0.314, 0.282)
11 love.graphics.circle("fill", zombie.x, zombie.y, zombie.r)
12 love.graphics.setColor(1, 1, 1)
13
14|#port, on zombie track player
15 , needs, @zombie track player
16 , reads, @zombie index|
17|#port body, on zombie track player, lua|
18 local player = state.player
19 local zombie = state.zombies[zombie_index]
20 zombie.angle = math.atan2(player.y - zombie.y, player.x - zombie.x)
21
22|#port, on move zombie
23 , needs, @move zombie
24 , reads, @zombie index|
25|#port body, on move zombie, lua|
26 local zombie = state.zombes[zombie_index]
27 zombie.x = zombie.x + state.dt * math.cos(zombie.angle) * 310
28 zombie.y = zombie.y + state.dt * math.sin(zombie.angle) * 310
29
30|#port, on check zombie hit player
31 , needs, @check zombie hit player
32 , reads, @zombie index|
33 , @zombie hit player
34
35|#port body, on check zombie hit player, lua|
36 local player = state.player
37 local zombie = state.zombies[zombie_index]
38
39 local min_distance = player.r + zombie.r
40 local distance = math.sqrt((player.x - zombie.x) ^ 2 + (player.y - zombie.y) ^ 2)
41 local hit = distance < min_distance
42
43 counters["@zombie hit player"] = hit and 1 or 0
44 zombie.dead = hit
45
46|#port, on get zombie count, needs, @get zombie count|
47 @zombie count
48|#port body, on get zombie count, lua|
49 print("ZOMBIE COUNT")
50 counters["@zombie count"] = #state.zombies
51
52|#port, on is zombie dead
53 , needs, @is zombie dead
54 , reads, @zombie index|
55 @zombie is dead
56|#port body, on is zombie dead, lua|
57 local zombie = state.zombies[zombie_index]
58 counters["@zombie is dead"] = zombie.dead and 1 or 0
59
60
61|_| Handling important counters
62|clear @zombie index|
63 clearing @zombie index:9007199254740991
64
65|clearing @zombie index, @zombie index|
66 , clearing @zombie index
67|clearing @zombie index|
68
69|restoring @zombie index, temporary @zombie index|
70 restoring @zombie index, @zombie index
71|restoring @zombie index|
72
73|restore @zombie index|
74 , restoring @zombie index:9007199254740991
75
76|clear @zombie count|
77 clearing @zombie count:9007199254740991
78
79|clearing @zombie count, @zombie count|
80 , clearing @zombie count
81|clearing @zombie count|
82
83|restoring @zombie count, temporary @zombie count|
84 restoring @zombie count, @zombie count
85|restoring @zombie count|
86
87|restore @zombie count|
88 , restoring @zombie count:9007199254740991
89
90
91
92|_| bounds check @zombie index
93|comparing @zombie index to @zombie count, @zombie index, @zombie count|
94 , temporary @zombie index
95 , temporary @zombie count
96 , comparing @zombie index to @zombie count
97
98|comparing @zombie index to @zombie count, @zombie count|
99 , temporary @zombie count
100 , result @zombie index < @zombie count
101
102|comparing @zombie index to @zombie count, @zombie index|
103 , temporary @zombie index
104 , result @zombie index > @zombie count
105
106|comparing @zombie index to @zombie count|
107
108|get compare @zombie index to @zombie count result, result @zombie index < @zombie count|
109 , @zombie index < @zombie count
110
111|get compare @zombie index to @zombie count result, result @zombie index > @zombie count|
112 , @zombie index > @zombie count
113
114|get compare @zombie index to @zombie count result|
115 , @zombie index = @zombie count
116
117|clearing excess results, result @zombie index < @zombie count|
118 , clearing excess results
119|clearing excess results, result @zombie index = @zombie count|
120 , clearing excess results
121|clearing excess results, result @zombie index > @zombie count|
122 , clearing excess results
123|clearing excess results|
124
125|clear excess results|
126 , clearing excess results:9007199254740991
127
128|clean up compare @zombie index to @zombie count|
129 , restore @zombie index
130 , restore @zombie count
131 , get compare @zombie index to @zombie count result
132 , clear excess results
133
134|compare @zombie index to @zombie count|
135 , comparing @zombie index to @zombie count:9007199254740991
136 , clean up compare @zombie index to @zombie count
137
138
139|_| The loop needed for drawing zombies
140|set up draw zombies loop|
141 , @zombie index
142 , @get zombie count
143 , compare @zombie index to @zombie count
144
145|drawing zombie, @zombie index > @zombie count|
146|drawing zombie, @zombie index = @zombie count|
147 , @draw zombie
148
149|drawing zombie, @zombie index < @zombie count|
150 , @draw zombie
151 , draw next zombie
152
153|draw next zombie|
154 , @zombie index
155 , drawing zombie
156 , compare @zombie index to @zombie count
157
158|clean up draw zombies loop|
159 , clear @zombie index
160 , clear @zombie count
161
162
163|_| trigger for drawing zombies
164|draw zombies|
165 , clear @zombie index
166 , set up draw zombies loop
167 , drawing zombie
168 , clean up draw zombies loop