capitalex gist felülvizsgálása . Revízióhoz ugrás
1 file changed, 26 insertions
circle.mira(fájl létrehozva)
@@ -0,0 +1,26 @@ | |||
1 | + | update circle $id $dt, | |
2 | + | circle $id has timer of $t, | |
3 | + | circle $id has $circle-size $orbit-x $orbit-y $radius $speed?: | |
4 | + | @expr eval $t-task [%1 + %2] $dt $t, | |
5 | + | @expr eval $x-task [cos((%1 + %2)* %3) * %4 + %5] $dt $t $speed $radius $orbit-x, | |
6 | + | @expr eval $y-task [sin((%1 + %2)* %3) * %4 + %5] $dt $t $speed $radius $orbit-y, | |
7 | + | finish circle update $id $circle-size $x-task $y-task $t-task. | |
8 | + | ||
9 | + | finish circle update $id $circle-size $x-task $y-task $t-task, | |
10 | + | @expr success $x-task $x, | |
11 | + | @expr success $y-task $y, | |
12 | + | @expr success $t-task $t: | |
13 | + | ||
14 | + | circle $id has timer of $t, | |
15 | + | circle $id has updated, | |
16 | + | @circle $x $y $circle-size. | |
17 | + | ||
18 | + | ||
19 | + | tick $dt?, | |
20 | + | $type $id can update: | |
21 | + | update $type $id $dt. | |
22 | + | tick $dt: prep. | |
23 | + | ||
24 | + | prep?, $type $id has updated: | |
25 | + | $type $id can update. | |
26 | + | prep: . |
capitalex gist felülvizsgálása . Revízióhoz ugrás
1 file changed, 301 insertions
zombies.mira(fájl létrehozva)
@@ -0,0 +1,301 @@ | |||
1 | + | player $player, | |
2 | + | $player at x #400 and y #300, | |
3 | + | can update for $player. | |
4 | + | ||
5 | + | update $id, player $id?: | |
6 | + | , compute player $id velocity x | |
7 | + | , @is-down key a, @is-down key d | |
8 | + | , compute player $id velocity y | |
9 | + | , @is-down key w, @is-down key s | |
10 | + | . | |
11 | + | ||
12 | + | compute player $id velocity x, @key-state down a: | |
13 | + | , player $id velocity x computed | |
14 | + | , player velocity x #-250 | |
15 | + | . | |
16 | + | ||
17 | + | compute player $id velocity x, @key-state down d: | |
18 | + | , player $id velocity x computed | |
19 | + | , player velocity x #250 | |
20 | + | . | |
21 | + | ||
22 | + | compute player $id velocity x: | |
23 | + | , player $id velocity x computed | |
24 | + | , player velocity x #0 | |
25 | + | . | |
26 | + | ||
27 | + | compute player $id velocity y, @key-state down w: | |
28 | + | , player $id velocity y computed | |
29 | + | , player velocity y #-250 | |
30 | + | . | |
31 | + | ||
32 | + | compute player $id velocity y, @key-state down s: | |
33 | + | , player $id velocity y computed | |
34 | + | , player velocity y #250 | |
35 | + | . | |
36 | + | ||
37 | + | compute player $id velocity y: | |
38 | + | , player $id velocity y computed | |
39 | + | , player velocity y #0 | |
40 | + | . | |
41 | + | ||
42 | + | player $id velocity y computed, | |
43 | + | player $id velocity x computed: | |
44 | + | , player $id velocity computed | |
45 | + | . | |
46 | + | ||
47 | + | player $id velocity computed?, @key-state up $key: . | |
48 | + | player $id velocity computed?, @key-state down $key: . | |
49 | + | ||
50 | + | tick $dt? | |
51 | + | , player $id velocity computed | |
52 | + | , $id at x $x and y $y | |
53 | + | , player velocity y $vy | |
54 | + | , player velocity x $vx: | |
55 | + | , commit player $id motion $new-x-token $new-y-token | |
56 | + | , @expr eval $new-x-token [%1 * %2 + %3] $vx $dt $x | |
57 | + | , @expr eval $new-y-token [%1 * %2 + %3] $vy $dt $y | |
58 | + | . | |
59 | + | ||
60 | + | commit player $id motion $new-x-token $new-y-token, | |
61 | + | @expr success $x $new-x-token, | |
62 | + | @expr success $y $new-y-token: | |
63 | + | , finished update for $id | |
64 | + | , $id at x $x and y $y | |
65 | + | , @circle $x $y #20 | |
66 | + | . | |
67 | + | ||
68 | + | ||
69 | + | ||
70 | + | compute enemy $id velocity | |
71 | + | , $id at x $my-x and y $my-y? | |
72 | + | , player $player? | |
73 | + | , $player at x $player-x and y $player-y?: | |
74 | + | , find angle to player for enemy $id using $delta-x-token $delta-y-token | |
75 | + | , @expr eval $delta-x-token [%1 - %2] $player-x $my-x | |
76 | + | , @expr eval $delta-y-token [%1 - %2] $player-y $my-y | |
77 | + | . | |
78 | + | ||
79 | + | find angle to player for enemy $id using $delta-x-token $delta-y-token | |
80 | + | , @expr success $delta-x $delta-x-token | |
81 | + | , @expr success $delta-y $delta-y-token: | |
82 | + | , compute enemy $id motion using $angle-token | |
83 | + | , @atan2 from $delta-x $delta-y into $angle-token | |
84 | + | . | |
85 | + | ||
86 | + | compute enemy $id motion using $angle-token | |
87 | + | , @atan2 angle $angle $angle-token: | |
88 | + | , compute new enemy $id location using $vx-token $vy-token | |
89 | + | , @expr eval $vx-token [cos(%1) * 200] $angle | |
90 | + | , @expr eval $vy-token [sin(%1) * 200] $angle | |
91 | + | . | |
92 | + | ||
93 | + | compute new enemy $id location using $vx-token $vy-token | |
94 | + | , tick $dt? | |
95 | + | , $id at x $x and y $y | |
96 | + | , @expr success $vx $vx-token | |
97 | + | , @expr success $vy $vy-token: | |
98 | + | , complete enemy $id update using $x-token $y-token | |
99 | + | , @expr eval $x-token [%1 + %2 * %3] $x $vx $dt | |
100 | + | , @expr eval $y-token [%1 + %2 * %3] $y $vy $dt | |
101 | + | . | |
102 | + | ||
103 | + | complete enemy $id update using $x-token $y-token, | |
104 | + | @expr success $x $x-token, | |
105 | + | @expr success $y $y-token: | |
106 | + | , finished update for $id | |
107 | + | , $id at x $x and y $y | |
108 | + | , @circle $x $y #10 | |
109 | + | . | |
110 | + | ||
111 | + | update $id, enemy $id?: | |
112 | + | , compute enemy $id velocity | |
113 | + | . | |
114 | + | ||
115 | + | ||
116 | + | update $self, bullet $self? | |
117 | + | , $self at x $x and y $y | |
118 | + | , $self velocity is x $vx and y $vy? | |
119 | + | , tick $dt?: | |
120 | + | , move bullet $self using $x-token $y-token | |
121 | + | , @expr eval $x-token [%1 + %2 * %3] $x $vx $dt | |
122 | + | , @expr eval $y-token [%1 + %2 * %3] $y $vy $dt | |
123 | + | . | |
124 | + | ||
125 | + | move bullet $self using $x-token $y-token, | |
126 | + | @expr success $x $x-token, | |
127 | + | @expr success $y $y-token: | |
128 | + | , $self at x $x and y $y | |
129 | + | , check if bullet $self should be destroyed | |
130 | + | , finish bullet $self update | |
131 | + | . | |
132 | + | ||
133 | + | check if bullet $self should be destroyed, $self at x $x and y $y?: | |
134 | + | , is bullet $self in bounds checking | |
135 | + | $left-bounds $right-bounds | |
136 | + | $top-bounds $bottom-bounds | |
137 | + | , @compare $x and #0 producing $left-bounds | |
138 | + | , @compare $x and #800 producing $right-bounds | |
139 | + | , @compare $y and #0 producing $top-bounds | |
140 | + | , @compare $y and #600 producing $bottom-bounds | |
141 | + | . | |
142 | + | ||
143 | + | is bullet $self in bounds checking | |
144 | + | $left-bounds $right-bounds | |
145 | + | $top-bounds $bottom-bounds | |
146 | + | , @compare greater-than $left-bounds | |
147 | + | , @compare less-than $right-bounds | |
148 | + | , @compare greater-than $top-bounds | |
149 | + | , @compare less-than $bottom-bounds: | |
150 | + | bullet $self is in bounds. | |
151 | + | ||
152 | + | is bullet $self in bounds checking | |
153 | + | $left-bounds $right-bounds | |
154 | + | $top-bounds $bottom-bounds | |
155 | + | , @compare $invalid-1 $left-bounds | |
156 | + | , @compare $invalid-2 $right-bounds | |
157 | + | , @compare $invalid-3 $top-bounds | |
158 | + | , @compare $invalid-4 $bottom-bounds: | |
159 | + | bullet $self is out of bounds. | |
160 | + | ||
161 | + | bullet $self is out of bounds?, @compare $ord $token:. | |
162 | + | ||
163 | + | finish bullet $self update, | |
164 | + | bullet $self is out of bounds, | |
165 | + | bullet $self, $self at x $x and y $y, $self velocity is x $vx and y $vy: . | |
166 | + | ||
167 | + | finish bullet $self update, | |
168 | + | bullet $self is in bounds, | |
169 | + | $self at x $x and y $y?: | |
170 | + | , finished update for $self | |
171 | + | , @circle $x $y #5 | |
172 | + | . | |
173 | + | ||
174 | + | ||
175 | + | ||
176 | + | spawn-timer $self | |
177 | + | , $self is at #0 seconds | |
178 | + | , $self times out every #1 seconds | |
179 | + | , can update for $self | |
180 | + | . | |
181 | + | ||
182 | + | update $self, spawn-timer $self?, $self is at $time seconds, tick $dt?: | |
183 | + | , update timer $self using $new-time-token | |
184 | + | , @expr eval $new-time-token [%1 + %2] $time $dt | |
185 | + | . | |
186 | + | ||
187 | + | update timer $self using $new-time-token | |
188 | + | , $self times out every $time-out seconds? | |
189 | + | , @expr success $time $new-time-token: | |
190 | + | , update timer $self to $time seconds using $bounds-check | |
191 | + | , @compare $time and $time-out producing $bounds-check | |
192 | + | . | |
193 | + | ||
194 | + | update timer $self to $time seconds using $bounds-check | |
195 | + | , @compare less-than $bounds-check: | |
196 | + | , $self is at $time seconds, | |
197 | + | , finished update for $self | |
198 | + | . | |
199 | + | ||
200 | + | update timer $self to $time seconds using $bounds-check, | |
201 | + | @compare $invalid $bounds-check: | |
202 | + | , spawn enemy | |
203 | + | , $self is at #0 seconds | |
204 | + | , finished update for $self | |
205 | + | . | |
206 | + | ||
207 | + | spawn enemy: | |
208 | + | , compute enemy $id location using $turns-token | |
209 | + | , @random generate $turns-token | |
210 | + | . | |
211 | + | ||
212 | + | compute enemy $id location using $turns-token, | |
213 | + | @random get $turns $turns-token: | |
214 | + | , commit new enemy $id at x $x-token and y $y-token | |
215 | + | , @expr eval $x-token [cos(6.28318530718 * %1) * 500 + 400] $turns | |
216 | + | , @expr eval $y-token [sin(6.28318530718 * %1) * 500 + 300] $turns | |
217 | + | . | |
218 | + | ||
219 | + | commit new enemy $id at x $x-token and y $y-token, | |
220 | + | @expr success $x $x-token, | |
221 | + | @expr success $y $y-token: | |
222 | + | , enemy $id | |
223 | + | , $id at x $x and y $y | |
224 | + | , can update for $id | |
225 | + | . | |
226 | + | ||
227 | + | ||
228 | + | ||
229 | + | ||
230 | + | bullet-spawner $self | |
231 | + | , can mouse-pressed for $self. | |
232 | + | ||
233 | + | mouse-pressed $self $mouse-x $mouse-y $button, bullet-spawner $self? | |
234 | + | , player $p?, $p at x $player-x and y $player-y?: | |
235 | + | , shoot bullet at angle using $angle-token | |
236 | + | , compute shoot angle using $shoot-x-token $shoot-y-token | |
237 | + | producing $angle-token | |
238 | + | , @expr eval $shoot-x-token [%1 - %2] $mouse-x $player-x | |
239 | + | , @expr eval $shoot-y-token [%1 - %2] $mouse-y $player-y | |
240 | + | . | |
241 | + | ||
242 | + | compute shoot angle using $shoot-x-token $shoot-y-token producing $angle-token | |
243 | + | , @expr success $shoot-x $shoot-x-token | |
244 | + | , @expr success $shoot-y $shoot-y-token: | |
245 | + | , @atan2 from $shoot-x $shoot-y into $angle-token | |
246 | + | . | |
247 | + | ||
248 | + | shoot bullet at angle using $angle-token | |
249 | + | , player $p?, $p at x $player-x and y $player-y? | |
250 | + | , @atan2 angle $angle $angle-token: | |
251 | + | , create new bullet $id using | |
252 | + | $spawn-x-token | |
253 | + | $spawn-y-token | |
254 | + | $bullet-vx-token | |
255 | + | $bullet-vy-token | |
256 | + | , @expr eval $spawn-x-token [cos(%1) + %2] $angle $player-x | |
257 | + | , @expr eval $spawn-y-token [sin(%1) + %2] $angle $player-y | |
258 | + | , @expr eval $bullet-vx-token [cos(%1) * 500] $angle | |
259 | + | , @expr eval $bullet-vy-token [sin(%1) * 500] $angle | |
260 | + | . | |
261 | + | ||
262 | + | , create new bullet $id using | |
263 | + | $spawn-x-token | |
264 | + | $spawn-y-token | |
265 | + | $bullet-vx-token | |
266 | + | $bullet-vy-token | |
267 | + | , bullet-spawner $self? | |
268 | + | , @expr success $bullet-x $spawn-x-token | |
269 | + | , @expr success $bullet-y $spawn-y-token | |
270 | + | , @expr success $bullet-vx $bullet-vx-token | |
271 | + | , @expr success $bullet-vy $bullet-vy-token: | |
272 | + | , bullet $id | |
273 | + | , $id at x $bullet-x and y $bullet-y | |
274 | + | , $id velocity is x $bullet-vx and y $bullet-vy | |
275 | + | , can update for $id | |
276 | + | , finished mouse-pressed for $self | |
277 | + | . | |
278 | + | ||
279 | + | ||
280 | + | ||
281 | + | tick $dt?, can update for $id: | |
282 | + | , update $id | |
283 | + | . | |
284 | + | ||
285 | + | tick $dt: prepare next tick. | |
286 | + | ||
287 | + | ||
288 | + | ||
289 | + | mouse-pressed $x $y $button, can mouse-pressed for $id: | |
290 | + | , mouse-pressed $id $x $y $button | |
291 | + | . | |
292 | + | ||
293 | + | mouse-pressed $x $y $button: . | |
294 | + | ||
295 | + | ||
296 | + | ||
297 | + | prepare next tick?, finished $event for $id: | |
298 | + | can $event for $id. | |
299 | + | ||
300 | + | prepare next tick: . | |
301 | + |