-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcloud.c
824 lines (632 loc) · 17.8 KB
/
cloud.c
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
/*
Overgod
Copyright (C) 2005 Linley Henzell
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public Licence as published by
the Free Software Foundation; either version 2 of the Licence, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public Licence for more details.
You should have received a copy of the GNU General Public Licence
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
The GPL version 2 is included in this distribution in a file called
LICENCE.TXT. Use any text editor or the TYPE command to read it.
You should be able to reach me by sending an email to
l_henzell@yahoo.com.au.
File: cloud.c
History:
11/9/2005 - Version 1.0 finalised
This file contains:
- functions relating to clouds and transient special effects
*/
#include "allegro.h"
#include <math.h>
#include "config.h"
#include "globvars.h"
#include "stuff.h"
#include "palette.h"
#include "sound.h"
#include "light.h"
#include "actor.h"
#include "display.h"
void manage_cloud(int cl);
int move_cloud(int mc, char limited);
void destroy_cloud(int c);
void drag_cloud(int i, float dragged);
void simple_cloud(int colour, int x, int y, int xs, int ys, int size);
void simple_cloud_trans(int colour, int x, int y, int xs, int ys, int size);
void place_explosion_with_smoke(int x, int y, int xs, int ys, int size, int colours [5]);
void place_explosion(int x, int y, int xs, int ys, int size, int colours [5]);
void place_burstlet_burst(int x, int y, int xs, int ys, int burstlets, int min_timeout, int random_timeout, int burst, int random_burst, int pretravel, int colours [5]);
void place_bang(int x, int y, int xs, int ys, int size, int btype);
int create_cloud_minimum(int type, int x, int y, int x2, int y2,
int x_speed, int y_speed, int timer, int tickrate,
int delta_tickrate, int angle,
int status, unsigned char seed, int minimum, int colours [5]);
void init_clouds(void)
{
int c;
for (c = 0; c < NO_CLOUDS; c++)
{
cloud[c].type = CLOUD_NONE;
}
}
// should delta_tickrate be unsigned?
int create_cloud(int type, int x, int y, int x2, int y2,
int x_speed, int y_speed, int timer, int tickrate,
int delta_tickrate, int angle,
int status, unsigned char seed, int colours [5])
{
int c = 0;
for (c = 1; c < NO_CLOUDS; c++)
{
if (c == NO_CLOUDS - 1) return -1;
if (cloud[c].type == CLOUD_NONE) break;
}
cloud[c].type = type;
cloud[c].x = x;// + (x_speed - actor[owner].x_speed);
cloud[c].y = y;// + (y_speed - actor[owner].y_speed);
cloud[c].x2 = x2;
cloud[c].y2 = y2;
cloud[c].x_speed = x_speed;
cloud[c].y_speed = y_speed;
cloud[c].seed = seed;
cloud[c].timeout = timer;
cloud[c].tickrate= tickrate;
cloud[c].delta_tickrate= delta_tickrate;
cloud[c].status = status;
cloud[c].angle = angle;
cloud[c].colour [0] = colours [0];
cloud[c].colour [1] = colours [1];
cloud[c].colour [2] = colours [2];
cloud[c].colour [3] = colours [3];
cloud[c].colour [4] = colours [4];
return c;
}
// just like create_cloud, but sets a minimum for the index.
// use it for clouds that need to overwrite other clouds on the display (eg dead trianglers)
int create_cloud_minimum(int type, int x, int y, int x2, int y2,
int x_speed, int y_speed, int timer, int tickrate,
int delta_tickrate, int angle,
int status, unsigned char seed, int minimum, int colours [5])
{
int c = 0;
for (c = minimum; c < NO_CLOUDS; c++)
{
if (c == NO_CLOUDS - 1) return -1;
if (cloud[c].type == CLOUD_NONE) break;
}
cloud[c].type = type;
cloud[c].x = x;// + (x_speed - actor[owner].x_speed);
cloud[c].y = y;// + (y_speed - actor[owner].y_speed);
cloud[c].x2 = x2;
cloud[c].y2 = y2;
cloud[c].x_speed = x_speed;
cloud[c].y_speed = y_speed;
cloud[c].seed = seed;
cloud[c].timeout = timer;
cloud[c].tickrate= tickrate;
cloud[c].delta_tickrate= delta_tickrate;
cloud[c].status = status;
cloud[c].angle = angle;
cloud[c].colour [0] = colours [0];
cloud[c].colour [1] = colours [1];
cloud[c].colour [2] = colours [2];
cloud[c].colour [3] = colours [3];
cloud[c].colour [4] = colours [4];
return c;
}
void run_clouds(void)
{
int c;
for (c = 1; c < NO_CLOUDS; c++)
{
if (cloud[c].type != CLOUD_NONE) manage_cloud(c);
}
}
void manage_cloud(int c)
{
int passing_colours [5];
// int x_gain = 0;
// int y_gain = 0;
// char angle_change;
// if (cloud[c].timeout > 0)
// {
cloud[c].timeout -= cloud[c].tickrate;
cloud[c].tickrate += cloud[c].delta_tickrate;
// }
if (cloud[c].timeout <= 0 || cloud[c].timeout >= 10000) // 10000 is sanity check - unfortunately necessary
{
destroy_cloud(c);
return;
}
switch(cloud[c].type)
{
case CLOUD_PULSER1_V:
case CLOUD_PULSER1_H:
case CLOUD_PULSER2_V:
case CLOUD_PULSER2_H:
if (cloud[c].timeout <= 2)
{
shake_all_screens(3 + grand(5));
place_explosion(
cloud[c].x + (11 * GRAIN), cloud[c].y + (11 * GRAIN),
0, 0, 300, cloud[c].colour);
place_burstlet_burst(cloud[c].x, cloud[c].y,
0, 0, 4 + grand(3), 2, 5, 1200, 500,
4, cloud[c].colour);
play_wav_pos(NWAV_MINEBANG, 200 + grand(200), 200, cloud[c].x, cloud[c].y);
destroy_cloud(c);
return;
}
break;
case CLOUD_SQUAREY:
cloud[c].angle -= cloud[c].status;
cloud[c].x = cloud[c].x2 + xpart(cloud[c].angle, 30);
cloud[c].y = cloud[c].y2 + ypart(cloud[c].angle, 30);
if (cloud[c].timeout <= 2)
{
shake_all_screens(3 + grand(5));
place_explosion(
cloud[c].x + xpart(cloud[c].angle, 30000), cloud[c].y + ypart(cloud[c].angle, 30000),
0, 0, 300, cloud[c].colour);
place_burstlet_burst(cloud[c].x + xpart(cloud[c].angle, 30000), cloud[c].y + ypart(cloud[c].angle, 30000),
0, 0, 4 + grand(3), 2, 5, 1200, 500,
4, cloud[c].colour);
//void place_burstlet_burst(int x, int y, int xs, int ys, int burstlets, int min_timeout, int random_timeout, int burst, int random_burst, int pretravel, int colours [5])
play_wav_pos(NWAV_MINEBANG, 200 + grand(200), 200, cloud[c].x, cloud[c].y);
destroy_cloud(c);
return;
}
break;
/* case CLOUD_TRI1:
case CLOUD_TRI2:
case CLOUD_TRI3:
drag_cloud(c, .05);
if (cloud[c].timeout % 2 == 0)
{
int cangle = grand(ANGLE_FULL);
int cx = cloud[c].x + xpart(cangle, grand(cloud[c].status));
int cy = cloud[c].y + ypart(cangle, grand(cloud[c].status));
passing_colours [0] = cloud[c].colour [1];
create_cloud_minimum(CLOUD_MED_TRANS_CIRCLE,
cx, cy, 0, 0, cloud[c].x_speed, cloud[c].y_speed,
200 + grand(350),0,2, 0, 0, 0, c, passing_colours);
passing_colours [0] = cloud[c].colour [2];
create_cloud_minimum(CLOUD_MED_TRANS_CIRCLE,
cx, cy, 0, 0, cloud[c].x_speed, cloud[c].y_speed,
300 + grand(450),0,6, 0, 0, 0, c, passing_colours);
}
if (cloud[c].timeout <= 2)
{
shake_all_screens(7 + grand(8));
place_explosion(
cloud[c].x, cloud[c].y,
0, 0, 1900, cloud[c].colour);
place_burstlet_burst(cloud[c].x, cloud[c].y,
0, 0, 4 + grand(3), 2, 6, 2000, 2500,
4, cloud[c].colour);
play_wav_pos(NWAV_BANG, 700, 200, cloud[c].x, cloud[c].y);
destroy_cloud(c);
return;
}
break;*/
case CLOUD_LIGHT:
add_light(LIGHT_NORMAL, cloud[c].timeout / 40, cloud[c].x, cloud[c].y);
break;
case CLOUD_FLAME_CIRCLE:
drag_cloud(c, .2);
break;
case CLOUD_BIG_BLAST_CIRCLE:
drag_cloud(c, .1);
break;
case CLOUD_BLAST_CIRCLE:
drag_cloud(c, .2);
break;
case CLOUD_SEEKER_CIRCLE:
drag_cloud(c, .2);
break;
case CLOUD_JET_CIRCLE1:
case CLOUD_JET_CIRCLE2:
case CLOUD_DRIVE_CIRCLE:
drag_cloud(c, .02);
break;
case CLOUD_BURSTLET:
// place_explosion(cloud[c].x, cloud[c].y, 0, 0, , cloud[c].colours);
passing_colours [0] = cloud[c].colour [1]; // was [0]
create_cloud(CLOUD_MED_TRANS_CIRCLE,
cloud[c].x, cloud[c].y, 0, 0, 0, 0,
100 + grand(450),0,2, 0, 0, 0, passing_colours);
// 50 + grand(300),0,3, 0, 0, 0, passing_colours);
// passing_colours [0] = cloud[c].colour [1];
// create_cloud(CLOUD_MED_TRANS_CIRCLE,
// cloud[c].x, cloud[c].y, 0, 0, 0, 0, size,-40,15, 0, 0, 0, passing_colours);
passing_colours [0] = cloud[c].colour [2];
create_cloud(CLOUD_MED_TRANS_CIRCLE,
cloud[c].x, cloud[c].y, 0, 0, 0, 0,
50 + grand(300),0,6, 0, 0, 0, passing_colours);
break;
case CLOUD_SPAWNER:
// the tickrate of a spawner must be a factor of the seed
if (cloud[c].timeout % cloud[c].seed == 0)
{
int cangle = grand(ANGLE_FULL);
int cx = cloud[c].x + xpart(cangle, grand(cloud[c].status * 100));
int cy = cloud[c].y + ypart(cangle, grand(cloud[c].status * 100));
shake_all_screens(grand(cloud[c].status) / 200);
place_explosion(
cx, cy,
0, 0, grand(cloud[c].status) + 250, cloud[c].colour);
// if (cloud[c].timeout % 48 == 0)
// play_sound_pos(WAV_MINEBANG, 200 + grand(200), 200, cx, cy);
if (cloud[c].timeout % 48 == 0)
play_wav_pos(NWAV_BANG, 400 + grand(200), 200, cx, cy);
}
break;
}
if (move_cloud(c, 1) == 0)
return;
drag_cloud(c, game.drag);
}
void destroy_cloud(int c)
{
cloud[c].type = CLOUD_NONE;
}
int move_cloud(int c, char limited)
{
if (cloud[c].x_speed == 0 && cloud[c].y_speed == 0) return 1;
cloud[c].x2 += cloud[c].x_speed;
cloud[c].y2 += cloud[c].y_speed;
cloud[c].x += cloud[c].x_speed;
cloud[c].y += cloud[c].y_speed;
return 1;
}
void drag_cloud(int i, float dragged)
{
cloud[i].x_speed *= 1 - dragged;
cloud[i].y_speed *= 1 - dragged;
}
void simple_cloud(int colour, int x, int y, int xs, int ys, int size)
{
int passing_colours [5];
passing_colours [0] = colour;
create_cloud(CLOUD_MED_CIRCLE,
x,
y,
0, 0,
xs,
ys,
size,-30,10, 0, 0, 0, passing_colours);
}
void simple_cloud_trans(int colour, int x, int y, int xs, int ys, int size)
{
int passing_colours [5];
passing_colours [0] = colour;
create_cloud(CLOUD_MED_TRANS_CIRCLE,
x,
y,
0, 0,
xs,
ys,
size,-30,10, 0, 0, 0, passing_colours);
}
void simple_light(int x, int y, int xs, int ys, int size)
{
int passing_colours [5];
create_cloud(CLOUD_LIGHT,
x,
y,
0, 0,
xs,
ys,
size,-30,10, 0, 0, 0, passing_colours);
}
void simple_shockwave(int colour, int x, int y, int xs, int ys, int size, int speed)
{
int passing_colours [5];
switch(colour)
{
default:
case TRANS_WHITE2:
passing_colours [3] = TRANS_WHITE2;
passing_colours [2] = TRANS_LGREY;
passing_colours [1] = TRANS_LGREY;
passing_colours [0] = TRANS_DGREY;
break;
case TRANS_YELLOW:
passing_colours [3] = TRANS_YELLOW;
passing_colours [2] = TRANS_ORANGE;
passing_colours [1] = TRANS_LRED;
passing_colours [0] = TRANS_DRED;
break;
case TRANS_PURPLE:
passing_colours [3] = TRANS_PURPLE;
passing_colours [2] = TRANS_LBLUE;
passing_colours [1] = TRANS_LBLUE;
passing_colours [0] = TRANS_DBLUE;
break;
case TRANS_LGREEN:
passing_colours [3] = TRANS_YELLOW;
passing_colours [2] = TRANS_LGREEN;
passing_colours [1] = TRANS_DGREEN;
passing_colours [0] = TRANS_DGREEN;
break;
}
create_cloud(CLOUD_SHOCKWAVE,
x,
y,
0, 0,
xs,
ys,
size,speed,0, 0, size + 20 + grand(50), 0, passing_colours);
}
void place_bang(int x, int y, int xs, int ys, int size, int btype)
{
int passing_colours [5];
create_cloud(CLOUD_BANG,
x,
y,
0, 0,
xs,
ys,
size,-20,3, 0, btype, 0, passing_colours);
}
void place_explosion(int x, int y, int xs, int ys, int size, int colours [5])
{
int passing_colours [5];
passing_colours [0] = colours [0];
create_cloud(CLOUD_MED_TRANS_CIRCLE,
x,
y,
0, 0,
xs,
ys,
size,-100,7, 0, 0, 0, passing_colours);
passing_colours [0] = colours [1];
create_cloud(CLOUD_MED_TRANS_CIRCLE,
x,
y,
0, 0,
xs,
ys,
size,-120,10, 0, 0, 0, passing_colours);
passing_colours [0] = colours [2];
create_cloud(CLOUD_MED_TRANS_CIRCLE,
x,
y,
0, 0,
xs,
ys,
size,-140,15, 0, 0, 0, passing_colours);
create_cloud(CLOUD_LIGHT,
x,
y,
0, 0,
xs,
ys,
size,-100,7, 0, 0, 0, passing_colours);
}
void place_explosion_no_light(int x, int y, int xs, int ys, int size, int colours [5])
{
int passing_colours [5];
passing_colours [0] = colours [0];
create_cloud(CLOUD_MED_TRANS_CIRCLE,
x,
y,
0, 0,
xs,
ys,
size,-100,7, 0, 0, 0, passing_colours);
passing_colours [0] = colours [1];
create_cloud(CLOUD_MED_TRANS_CIRCLE,
x,
y,
0, 0,
xs,
ys,
size,-120,10, 0, 0, 0, passing_colours);
passing_colours [0] = colours [2];
create_cloud(CLOUD_MED_TRANS_CIRCLE,
x,
y,
0, 0,
xs,
ys,
size,-140,15, 0, 0, 0, passing_colours);
}
void place_small_explosion(int x, int y, int xs, int ys, int size, int colours [5])
{
int passing_colours [5];
passing_colours [0] = colours [0];
create_cloud(CLOUD_MED_TRANS_CIRCLE,
x,
y,
0, 0,
xs,
ys,
size,-15,3, 0, 0, 0, passing_colours);
passing_colours [0] = colours [1];
create_cloud(CLOUD_MED_TRANS_CIRCLE,
x,
y,
0, 0,
xs,
ys,
size,-20,5, 0, 0, 0, passing_colours);
passing_colours [0] = colours [2];
create_cloud(CLOUD_MED_TRANS_CIRCLE,
x,
y,
0, 0,
xs,
ys,
size,-23,8, 0, 0, 0, passing_colours);
create_cloud(CLOUD_LIGHT,
x,
y,
0, 0,
xs,
ys,
size,-40,7, 0, 0, 0, passing_colours);
}
void place_explosion_with_smoke(int x, int y, int xs, int ys, int size, int colours [5])
{
int passing_colours [5];
passing_colours [0] = TRANS_LGREY;
/* create_cloud(CLOUD_MED_TRANS_CIRCLE,
x,
y,
0, 0,
xs,
ys,
size,-30,1, 0, 0, 0, passing_colours);*/
create_cloud(CLOUD_LIGHT,
x,
y,
0, 0,
xs,
ys,
size,-100,7, 0, 0, 0, passing_colours);
passing_colours [0] = colours [0];
create_cloud(CLOUD_MED_TRANS_CIRCLE,
x,
y,
0, 0,
xs,
ys,
size,-100,7, 0, 0, 0, passing_colours);
passing_colours [0] = colours [1];
create_cloud(CLOUD_MED_TRANS_CIRCLE,
x,
y,
0, 0,
xs,
ys,
size,-105,10, 0, 0, 0, passing_colours);
passing_colours [0] = colours [2];
create_cloud(CLOUD_MED_TRANS_CIRCLE,
x,
y,
0, 0,
xs,
ys,
size,-110,15, 0, 0, 0, passing_colours);
}
void place_rocket_trail(int x, int y, int xs, int ys, int size, int colours [5])
{
int passing_colours [5];
passing_colours [0] = colours [0];
create_cloud(CLOUD_MED_TRANS_CIRCLE,
x,
y,
0, 0,
xs,
ys,
size,-10,2, 0, 0, 0, passing_colours);
passing_colours [0] = colours [1];
create_cloud(CLOUD_MED_TRANS_CIRCLE,
x,
y,
0, 0,
xs,
ys,
size,-15,4, 0, 0, 0, passing_colours);
passing_colours [0] = colours [2];
create_cloud(CLOUD_MED_TRANS_CIRCLE,
x,
y,
0, 0,
xs,
ys,
size,-20,15, 0, 0, 0, passing_colours);
}
void place_speck_burst(int x, int y, int xs, int ys, int specks, int min_timeout, int random_timeout, int scatter, int colours [5])
{
int i;
for (i = 0; i < specks; i ++)
{
create_cloud(CLOUD_SPECK,
x,
y,
0, 0,
xs + grand(scatter * 2 + 1) - scatter,
ys + grand(scatter * 2 + 1) - scatter,
min_timeout + grand(random_timeout), 1,0,0, 0, 0, colours);
}
}
void place_line_burst(int x, int y, int xs, int ys, int specks, int min_timeout, int random_timeout, int burst, int random_burst, int colours [5])
{
int i, angle, xsp, ysp, burst_speed;
for (i = 0; i < specks; i ++)
{
angle = grand(ANGLE_FULL);
burst_speed = burst + grand(burst);
xsp = xs + xpart(angle, burst_speed);
ysp = ys + ypart(angle, burst_speed);
x += xsp;
y += ysp;
create_cloud(CLOUD_SHRINKING_LINE,
x,
y,
0, 0,
xsp,
ysp,
(min_timeout + grand(random_timeout)) * 10, 10 + grand(6),0,angle, 0, 0, colours);
}
}
void place_burstlet_burst(int x, int y, int xs, int ys, int burstlets, int min_timeout, int random_timeout, int burst, int random_burst, int pretravel, int colours [5])
{
int i, xs2, ys2, x2, y2;
for (i = 0; i < burstlets; i ++)
{
xs2 = burst + grand(random_burst);
ys2 = burst + grand(random_burst);
if (grand(2) == 0)
xs2 *= -1;
if (grand(2) == 0)
ys2 *= -1;
xs2 += xs;
ys2 += ys;
x2 = x + xs2 * pretravel; // or it will just be masked by the main
y2 = y + ys2 * pretravel; // explosion
create_cloud(CLOUD_BURSTLET,
x2, y2, 0,0, xs2, ys2,
min_timeout + random_timeout,1,0, 0, 0, 0, colours);
}
}
// called at start of each level and once per tick
void init_effects(void)
{
int i;
for (i = 0; i < MAX_EFFECTS; i ++)
{
effect[i].type = EFFECT_NONE;
}
}
int create_effect(int type, int x, int y, int x1, int y1, int x2, int y2, int att1, int att2, int att3, int att4, int att5)
{
int i;
for (i = 0; i < MAX_EFFECTS + 1; i ++)
{
if (i >= MAX_EFFECTS)
return 0;
if (effect[i].type == EFFECT_NONE)
break;
}
effect[i].type = type;
effect[i].x = x;
effect[i].y = y;
effect[i].x1 = x1;
effect[i].y1 = y1;
effect[i].x2 = x2;
effect[i].y2 = y2;
effect[i].things [0] = att1;
effect[i].things [1] = att2;
effect[i].things [2] = att3;
effect[i].things [3] = att4;
effect[i].things [4] = att5;
return 1;
}