added "pause" element to game elements in EM engine
[rocksndiamonds.git] / src / game_em / emerald.h
1 /*
2
3 This program "Emerald Mine for X11"
4 is copyright © 2009 David Tritscher.  All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9
10 1. Redistributions of source code must retain the above copyright
11    notice, this list of conditions and the following disclaimer.
12
13 2. The origin of this software must not be misrepresented; you must
14    not claim that you wrote the original software.  If you use this
15    software in a product, an acknowledgment in the product
16    documentation would be appreciated but is not required.
17
18 3. Altered source versions must be plainly marked as such, and must
19    not be misrepresented as being the original software.
20
21 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
22 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
25 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 */
34 /* 2007-03-31 06:22:47
35  *
36  * emerald mine game engine defines
37  */
38
39 // ----------------------------------------------------------------------------
40 // EM game engine source code was altered for integration in Rocks'n'Diamonds
41 // ----------------------------------------------------------------------------
42
43 #ifndef EMERALD_H
44 #define EMERALD_H
45
46
47 // ----------------------------------------------------------------------------
48 // constant definitions
49 // ----------------------------------------------------------------------------
50
51 /* define these to use additional elements */
52 #define EM_ENGINE_USE_ADDITIONAL_ELEMENTS
53
54 /* one border for Zborder elements, one border for steelwall, if needed */
55 #define EM_MAX_CAVE_WIDTH               (MAX_PLAYFIELD_WIDTH  + 2 + 2)
56 #define EM_MAX_CAVE_HEIGHT              (MAX_PLAYFIELD_HEIGHT + 2 + 2)
57
58 /*
59   -----------------------------------------------------------------------------
60   definition of elements used in the Emerald Mine Club engine;
61   the element names have the following properties:
62   - elements that start with 'X' can be stored in a level file
63   - elements that start with 'Y' indicate moving elements
64   - elements that end with 'B' are the "backside" of moving elements
65   -----------------------------------------------------------------------------
66 */
67
68 enum
69 {
70   Xblank = 0,
71
72   Xacid_splash_e,
73   Xacid_splash_w,
74
75   Xplant,
76   Yplant,
77
78   Xacid_1,
79   Xacid_2,
80   Xacid_3,
81   Xacid_4,
82   Xacid_5,
83   Xacid_6,
84   Xacid_7,
85   Xacid_8,
86
87 #ifdef EM_ENGINE_USE_ADDITIONAL_ELEMENTS
88   Xfake_acid_1,
89   Xfake_acid_2,
90   Xfake_acid_3,
91   Xfake_acid_4,
92   Xfake_acid_5,
93   Xfake_acid_6,
94   Xfake_acid_7,
95   Xfake_acid_8,
96 #endif
97
98   Xgrass,
99   Ygrass_nB,
100   Ygrass_eB,
101   Ygrass_sB,
102   Ygrass_wB,
103
104   Xdirt,
105   Ydirt_nB,
106   Ydirt_eB,
107   Ydirt_sB,
108   Ydirt_wB,
109
110   Xandroid,
111   Xandroid_1_n,
112   Xandroid_2_n,
113   Xandroid_1_e,
114   Xandroid_2_e,
115   Xandroid_1_w,
116   Xandroid_2_w,
117   Xandroid_1_s,
118   Xandroid_2_s,
119   Yandroid_n,
120   Yandroid_nB,
121   Yandroid_ne,
122   Yandroid_neB,
123   Yandroid_e,
124   Yandroid_eB,
125   Yandroid_se,
126   Yandroid_seB,
127   Yandroid_s,
128   Yandroid_sB,
129   Yandroid_sw,
130   Yandroid_swB,
131   Yandroid_w,
132   Yandroid_wB,
133   Yandroid_nw,
134   Yandroid_nwB,
135
136   Xeater_n,
137   Xeater_e,
138   Xeater_w,
139   Xeater_s,
140   Yeater_n,
141   Yeater_nB,
142   Yeater_e,
143   Yeater_eB,
144   Yeater_s,
145   Yeater_sB,
146   Yeater_w,
147   Yeater_wB,
148   Yeater_stone,
149   Yeater_spring,
150
151   Xalien,
152   Xalien_pause,
153   Yalien_n,
154   Yalien_nB,
155   Yalien_e,
156   Yalien_eB,
157   Yalien_s,
158   Yalien_sB,
159   Yalien_w,
160   Yalien_wB,
161   Yalien_stone,
162   Yalien_spring,
163
164   Xbug_1_n,
165   Xbug_1_e,
166   Xbug_1_s,
167   Xbug_1_w,
168   Xbug_2_n,
169   Xbug_2_e,
170   Xbug_2_s,
171   Xbug_2_w,
172   Ybug_n,
173   Ybug_nB,
174   Ybug_e,
175   Ybug_eB,
176   Ybug_s,
177   Ybug_sB,
178   Ybug_w,
179   Ybug_wB,
180   Ybug_w_n,
181   Ybug_n_e,
182   Ybug_e_s,
183   Ybug_s_w,
184   Ybug_e_n,
185   Ybug_s_e,
186   Ybug_w_s,
187   Ybug_n_w,
188   Ybug_stone,
189   Ybug_spring,
190
191   Xtank_1_n,
192   Xtank_1_e,
193   Xtank_1_s,
194   Xtank_1_w,
195   Xtank_2_n,
196   Xtank_2_e,
197   Xtank_2_s,
198   Xtank_2_w,
199   Ytank_n,
200   Ytank_nB,
201   Ytank_e,
202   Ytank_eB,
203   Ytank_s,
204   Ytank_sB,
205   Ytank_w,
206   Ytank_wB,
207   Ytank_w_n,
208   Ytank_n_e,
209   Ytank_e_s,
210   Ytank_s_w,
211   Ytank_e_n,
212   Ytank_s_e,
213   Ytank_w_s,
214   Ytank_n_w,
215   Ytank_stone,
216   Ytank_spring,
217
218   Xemerald,
219   Xemerald_pause,
220   Xemerald_fall,
221   Xemerald_shine,
222   Yemerald_s,
223   Yemerald_sB,
224   Yemerald_e,
225   Yemerald_eB,
226   Yemerald_w,
227   Yemerald_wB,
228   Yemerald_blank,
229
230   Xdiamond,
231   Xdiamond_pause,
232   Xdiamond_fall,
233   Xdiamond_shine,
234   Ydiamond_s,
235   Ydiamond_sB,
236   Ydiamond_e,
237   Ydiamond_eB,
238   Ydiamond_w,
239   Ydiamond_wB,
240   Ydiamond_blank,
241   Ydiamond_stone,
242
243   Xstone,
244   Xstone_pause,
245   Xstone_fall,
246   Ystone_s,
247   Ystone_sB,
248   Ystone_e,
249   Ystone_eB,
250   Ystone_w,
251   Ystone_wB,
252
253   Xbomb,
254   Xbomb_pause,
255   Xbomb_fall,
256   Ybomb_s,
257   Ybomb_sB,
258   Ybomb_e,
259   Ybomb_eB,
260   Ybomb_w,
261   Ybomb_wB,
262   Ybomb_blank,
263
264   Xnut,
265   Xnut_pause,
266   Xnut_fall,
267   Ynut_s,
268   Ynut_sB,
269   Ynut_e,
270   Ynut_eB,
271   Ynut_w,
272   Ynut_wB,
273   Ynut_stone,
274
275   Xspring,
276   Xspring_pause,
277   Xspring_e,
278   Xspring_w,
279   Xspring_fall,
280   Yspring_s,
281   Yspring_sB,
282   Yspring_e,
283   Yspring_eB,
284   Yspring_w,
285   Yspring_wB,
286   Yspring_alien_e,
287   Yspring_alien_eB,
288   Yspring_alien_w,
289   Yspring_alien_wB,
290
291   Xpush_emerald_e,
292   Xpush_emerald_w,
293   Xpush_diamond_e,
294   Xpush_diamond_w,
295   Xpush_stone_e,
296   Xpush_stone_w,
297   Xpush_bomb_e,
298   Xpush_bomb_w,
299   Xpush_nut_e,
300   Xpush_nut_w,
301   Xpush_spring_e,
302   Xpush_spring_w,
303
304   Xdynamite,
305   Ydynamite_blank,
306   Xdynamite_1,
307   Xdynamite_2,
308   Xdynamite_3,
309   Xdynamite_4,
310
311   Xkey_1,
312   Xkey_2,
313   Xkey_3,
314   Xkey_4,
315   Xkey_5,
316   Xkey_6,
317   Xkey_7,
318   Xkey_8,
319
320   Xdoor_1,
321   Xdoor_2,
322   Xdoor_3,
323   Xdoor_4,
324   Xdoor_5,
325   Xdoor_6,
326   Xdoor_7,
327   Xdoor_8,
328
329   Xfake_door_1,
330   Xfake_door_2,
331   Xfake_door_3,
332   Xfake_door_4,
333   Xfake_door_5,
334   Xfake_door_6,
335   Xfake_door_7,
336   Xfake_door_8,
337
338   Xballoon,
339   Yballoon_n,
340   Yballoon_nB,
341   Yballoon_e,
342   Yballoon_eB,
343   Yballoon_s,
344   Yballoon_sB,
345   Yballoon_w,
346   Yballoon_wB,
347
348   Xball_1,
349   Yball_1,
350   Xball_2,
351   Yball_2,
352   Yball_blank,
353
354   Xamoeba_1,
355   Xamoeba_2,
356   Xamoeba_3,
357   Xamoeba_4,
358   Xamoeba_5,
359   Xamoeba_6,
360   Xamoeba_7,
361   Xamoeba_8,
362
363   Xdrip,
364   Xdrip_fall,
365   Xdrip_stretch,
366   Xdrip_stretchB,
367   Ydrip_1_s,
368   Ydrip_1_sB,
369   Ydrip_2_s,
370   Ydrip_2_sB,
371
372   Xwonderwall,
373   XwonderwallB,
374
375   Xwheel,
376   XwheelB,
377
378   Xswitch,
379   XswitchB,
380
381   Xbumper,
382   XbumperB,
383
384   Xacid_nw,
385   Xacid_ne,
386   Xacid_sw,
387   Xacid_s,
388   Xacid_se,
389
390   Xfake_blank,
391   Xfake_blankB,
392
393   Xfake_grass,
394   Xfake_grassB,
395
396   Xfake_amoeba,         /* dripper */
397   Xfake_amoebaB,
398
399   Xlenses,
400
401   Xmagnify,
402
403   Xsand,
404   Xsand_stone,
405   Xsand_stonein_1,
406   Xsand_stonein_2,
407   Xsand_stonein_3,
408   Xsand_stonein_4,
409   Xsand_sandstone_1,
410   Xsand_sandstone_2,
411   Xsand_sandstone_3,
412   Xsand_sandstone_4,
413   Xsand_stonesand_1,
414   Xsand_stonesand_2,
415   Xsand_stonesand_3,
416   Xsand_stonesand_4,
417   Xsand_stoneout_1,
418   Xsand_stoneout_2,
419 #ifdef EM_ENGINE_USE_ADDITIONAL_ELEMENTS
420   Xsand_stonesand_quickout_1,
421   Xsand_stonesand_quickout_2,
422 #endif
423
424   Xslidewall_ns,        /* growing wall */
425   Yslidewall_ns_blank,
426   Xslidewall_ew,
427   Yslidewall_ew_blank,
428
429   Xwind_n,
430   Xwind_e,
431   Xwind_s,
432   Xwind_w,
433   Xwind_any,
434   Xwind_stop,
435
436   Xexit,
437   Xexit_1,
438   Xexit_2,
439   Xexit_3,
440
441   Xpause,
442
443   Xwall_1,
444   Xwall_2,
445   Xwall_3,
446   Xwall_4,
447
448   Xroundwall_1,
449   Xroundwall_2,
450   Xroundwall_3,
451   Xroundwall_4,
452
453   Xsteel_1,
454   Xsteel_2,
455   Xsteel_3,
456   Xsteel_4,
457
458   Xdecor_1,
459   Xdecor_2,
460   Xdecor_3,
461   Xdecor_4,
462   Xdecor_5,
463   Xdecor_6,
464   Xdecor_7,
465   Xdecor_8,
466   Xdecor_9,
467   Xdecor_10,
468   Xdecor_11,
469   Xdecor_12,
470
471   Xalpha_0,
472   Xalpha_1,
473   Xalpha_2,
474   Xalpha_3,
475   Xalpha_4,
476   Xalpha_5,
477   Xalpha_6,
478   Xalpha_7,
479   Xalpha_8,
480   Xalpha_9,
481   Xalpha_excla,
482   Xalpha_quote,
483   Xalpha_comma,
484   Xalpha_minus,
485   Xalpha_perio,
486   Xalpha_colon,
487   Xalpha_quest,
488   Xalpha_a,
489   Xalpha_b,
490   Xalpha_c,
491   Xalpha_d,
492   Xalpha_e,
493   Xalpha_f,
494   Xalpha_g,
495   Xalpha_h,
496   Xalpha_i,
497   Xalpha_j,
498   Xalpha_k,
499   Xalpha_l,
500   Xalpha_m,
501   Xalpha_n,
502   Xalpha_o,
503   Xalpha_p,
504   Xalpha_q,
505   Xalpha_r,
506   Xalpha_s,
507   Xalpha_t,
508   Xalpha_u,
509   Xalpha_v,
510   Xalpha_w,
511   Xalpha_x,
512   Xalpha_y,
513   Xalpha_z,
514   Xalpha_arrow_e,
515   Xalpha_arrow_w,
516   Xalpha_copyr,
517
518 #ifdef EM_ENGINE_USE_ADDITIONAL_ELEMENTS
519   Ykey_1_blank,
520   Ykey_2_blank,
521   Ykey_3_blank,
522   Ykey_4_blank,
523   Ykey_5_blank,
524   Ykey_6_blank,
525   Ykey_7_blank,
526   Ykey_8_blank,
527   Ylenses_blank,
528   Ymagnify_blank,
529   Ygrass_blank,
530   Ydirt_blank,
531 #endif
532
533   Xboom_bug,            /* passed from explode to synchro (linked explosion);
534                            transition to explode_normal */
535   Xboom_bomb,           /* passed from explode to synchro (linked explosion);
536                            transition to explode_normal */
537   Xboom_android,        /* passed from explode to synchro;
538                            transition to boom_2 */
539   Xboom_1,              /* passed from explode to synchro;
540                            transition to boom_2 */
541   Xboom_2,              /* transition to boom[] */
542
543   Znormal,              /* passed from synchro to explode, only in next[];
544                            no picture */
545   Zdynamite,            /* passed from synchro to explode, only in next[];
546                            no picture */
547   Zplayer,              /* special code to indicate player;
548                            no picture */
549   Zborder,              /* special code to indicate border;
550                            no picture */
551
552   TILE_MAX
553 };
554
555 /* other definitions */
556
557 enum
558 {
559   PLY_still = 0,
560
561   PLY_walk_n,
562   PLY_walk_e,
563   PLY_walk_s,
564   PLY_walk_w,
565
566   PLY_push_n,
567   PLY_push_e,
568   PLY_push_s,
569   PLY_push_w,
570
571   PLY_shoot_n,
572   PLY_shoot_e,
573   PLY_shoot_s,
574   PLY_shoot_w,
575
576   PLY_MAX
577 };
578
579 enum
580 {
581   SOUND_blank = 0,      /* player walks on blank */
582   SOUND_roll,           /* player pushes stone/bomb/nut/spring */
583   SOUND_stone,          /* stone hits ground */
584   SOUND_nut,            /* nut hits ground */
585   SOUND_crack,          /* stone hits nut */
586   SOUND_bug,            /* bug moves */
587   SOUND_tank,           /* tank moves */
588   SOUND_android_clone,  /* android places something */
589   SOUND_android_move,   /* android moves */
590   SOUND_spring,         /* spring hits ground/wall/bumper, stone hits spring */
591   SOUND_slurp,          /* spring kills alien */
592   SOUND_eater,          /* eater sits */
593   SOUND_eater_eat,      /* eater eats diamond */
594   SOUND_alien,          /* alien moves */
595   SOUND_collect,        /* player collects object */
596   SOUND_diamond,        /* diamond/emerald hits ground */
597   SOUND_squash,         /* stone squashes diamond */
598   SOUND_wonderfall,     /* object falls thru wonderwall */
599   SOUND_drip,           /* drip hits ground */
600   SOUND_push,           /* player pushes spring/balloon/android */
601   SOUND_dirt,           /* player digs into dirt */
602   SOUND_acid,           /* acid splashes */
603   SOUND_ball,           /* ball places something */
604   SOUND_slidewall,      /* slide wall grows */
605   SOUND_wonder,         /* wonderwall is active */
606   SOUND_door,           /* player goes thru door (gate) */
607   SOUND_exit_open,      /* exit opens */
608   SOUND_exit_leave,     /* player goes into exit */
609   SOUND_dynamite,       /* player places dynamite */
610   SOUND_tick,           /* dynamite ticks */
611   SOUND_press,          /* player presses wheel/wind/switch */
612   SOUND_wheel,          /* wheel moves */
613   SOUND_boom,           /* explosion */
614   SOUND_time,           /* time runs out */
615   SOUND_die,            /* player dies */
616
617   SOUND_MAX
618 };
619
620
621 // ----------------------------------------------------------------------------
622 // data structure definitions
623 // ----------------------------------------------------------------------------
624
625 struct LEVEL
626 {
627   int home_initial;             /* number of players (initial) */
628   int home;                     /* number of players not yet at home */
629                                 /* 0 == all players at home */
630
631   int width;                    /* playfield width */
632   int height;                   /* playfield height */
633
634   int time_seconds;             /* available time (seconds) */
635   int time_initial;             /* available time (initial) */
636   int time;                     /* time remaining (runtime) */
637
638   boolean killed_out_of_time;   /* kill player due to time out */
639
640   int required_initial;         /* emeralds needed (initial) */
641   int required;                 /* emeralds needed (runtime) */
642
643   int score;                    /* score */
644
645   /* all below entries must be filled every time a level is read */
646
647   int alien_score;              /* score for killing alien */
648   int amoeba_time;              /* amoeba speed */
649   int android_move_cnt_initial; /* android move counter (initial) */
650   int android_move_cnt;         /* android move counter */
651   int android_move_time;        /* android move reset time */
652   int android_clone_cnt_initial;/* android clone counter (initial) */
653   int android_clone_cnt;        /* android clone counter */
654   int android_clone_time;       /* android clone reset time */
655   int ball_cnt;                 /* ball counter */
656   int ball_pos;                 /* ball array pos counter */
657   int ball_random;              /* ball is random flag */
658   int ball_state_initial;       /* ball active flag (initial) */
659   int ball_state;               /* ball active flag */
660   int ball_time;                /* ball reset time */
661   int bug_score;                /* score for killing bug */
662   int diamond_score;            /* score for collecting diamond */
663   int dynamite_score;           /* score for collecting dynamite */
664   int eater_pos;                /* eater array pos */
665   int eater_score;              /* score for killing eater */
666   int emerald_score;            /* score for collecting emerald */
667   int exit_score;               /* score for entering exit */
668   int key_score;                /* score for colleting key */
669   int lenses_cnt_initial;       /* lenses counter (initial) */
670   int lenses_cnt;               /* lenses counter */
671   int lenses_score;             /* score for collecting lenses */
672   int lenses_time;              /* lenses reset time */
673   int magnify_cnt_initial;      /* magnify counter (initial) */
674   int magnify_cnt;              /* magnify counter */
675   int magnify_score;            /* score for collecting magnifier */
676   int magnify_time;             /* magnify reset time */
677   int nut_score;                /* score for cracking nut */
678   int shine_cnt;                /* shine counter for emerald/diamond */
679   int slurp_score;              /* score for slurping alien */
680   int tank_score;               /* score for killing tank */
681   int wheel_cnt_initial;        /* wheel counter (initial) */
682   int wheel_cnt;                /* wheel counter */
683   int wheel_x_initial;          /* wheel x pos (initial) */
684   int wheel_x;                  /* wheel x pos */
685   int wheel_y_initial;          /* wheel y pos (initial) */
686   int wheel_y;                  /* wheel y pos */
687   int wheel_time;               /* wheel reset time */
688   int wind_cnt_initial;         /* wind counter (initial) */
689   int wind_cnt;                 /* wind time counter */
690   int wind_direction_initial;   /* wind direction (initial) */
691   int wind_direction;           /* wind direction */
692   int wind_time;                /* wind reset time */
693   int wonderwall_state_initial; /* wonderwall active flag (initial) */
694   int wonderwall_state;         /* wonderwall active flag */
695   int wonderwall_time_initial;  /* wonderwall time (initial) */
696   int wonderwall_time;          /* wonderwall time */
697   short eater_array[8][9];      /* eater data */
698   short ball_array[8][8];       /* ball data */
699   short android_array[TILE_MAX];/* android clone table */
700   int num_ball_arrays;          /* number of ball data arrays used */
701
702   int exit_x, exit_y;           /* kludge for playing player exit sound */
703 };
704
705 struct PLAYER
706 {
707   int num;
708   int exists;
709   int alive_initial;
710   int alive;
711
712   int dynamite;
713   int dynamite_cnt;
714   int keys;
715   int anim;
716
717   int x_initial;
718   int y_initial;
719   int x;
720   int y;
721   int oldx;
722   int oldy;
723
724   int last_move_dir;
725
726   int joy_n:1;
727   int joy_e:1;
728   int joy_s:1;
729   int joy_w:1;
730   int joy_snap:1;
731   int joy_drop:1;
732   int joy_stick:1;
733   int joy_spin:1;
734 };
735
736 #endif  // EMERALD_H