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