3 This program "Emerald Mine for X11"
4 is copyright © 2009 David Tritscher. All rights reserved.
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
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.
18 3. Altered source versions must be plainly marked as such, and must
19 not be misrepresented as being the original software.
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.
34 /* 2007-03-31 06:22:47
36 * emerald mine game engine defines
39 // ----------------------------------------------------------------------------
40 // EM game engine source code was altered for integration in Rocks'n'Diamonds
41 // ----------------------------------------------------------------------------
47 // ----------------------------------------------------------------------------
48 // constant definitions
49 // ----------------------------------------------------------------------------
51 /* maximum cave size */
52 #define CAVE_WIDTH MAX_PLAYFIELD_WIDTH
53 #define CAVE_HEIGHT MAX_PLAYFIELD_HEIGHT
55 /* additional padding for Zborder elements and linked cave buffer columns */
56 #define CAVE_BUFFER_XOFFSET 4
57 #define CAVE_BUFFER_YOFFSET 2
58 #define CAVE_BUFFER_WIDTH (CAVE_WIDTH + 2 * CAVE_BUFFER_XOFFSET)
59 #define CAVE_BUFFER_HEIGHT (CAVE_HEIGHT + 2 * CAVE_BUFFER_YOFFSET)
62 // ----------------------------------------------------------------------------
63 // definition of elements used in the Emerald Mine Club engine;
64 // the element names (mostly) have the following properties:
65 // - elements that start with 'X' are not animated (more or less)
66 // - elements that start with 'Y' are animated elements
67 // - elements that start with 'Z' are internal elements (without graphics)
68 // - elements that end with 'B' or '_blank' change to the "Xblank" element
69 // ----------------------------------------------------------------------------
73 Zborder, /* special code to indicate border */
74 Zplayer, /* special code to indicate player */
76 Zbug, /* internal bug explosion */
77 Ztank, /* internal tank/alien/bomb explosion */
78 Zeater, /* internal eater explosion */
79 Zdynamite, /* internal dynamite explosion */
80 Zboom, /* explosion */
82 Xchain, /* chain explosion; transition to Zboom */
83 Xboom_bug, /* bug explosion; transition to Zbug */
84 Xboom_tank, /* tank/alien/bomb explosion; transition to Ztank */
85 Xboom_android, /* android explosion; transition to Xboom_2 */
86 Xboom_1, /* tile explosion; transition to Xboom_2 */
87 Xboom_2, /* transition to boom[] */
106 Xfake_acid_1, /* newly added to EM engine */
115 Xfake_acid_1_player, /* newly added to EM engine */
422 Xfake_amoeba, /* dripper */
445 Xsand_stonesand_quickout_1, /* newly added to EM engine */
446 Xsand_stonesand_quickout_2,
448 Xslide_ns, /* growing wall */
542 Ykey_1_blank, /* newly added to EM engine */
558 /* other definitions */
584 SOUND_blank, /* player walks on blank */
585 SOUND_roll, /* player pushes stone/bomb/nut/spring */
586 SOUND_stone, /* stone hits ground */
587 SOUND_nut, /* nut hits ground */
588 SOUND_crack, /* stone hits nut */
589 SOUND_bug, /* bug moves */
590 SOUND_tank, /* tank moves */
591 SOUND_android_clone, /* android places something */
592 SOUND_android_move, /* android moves */
593 SOUND_spring, /* spring hits ground/wall/bumper, stone hits spring */
594 SOUND_slurp, /* spring kills alien */
595 SOUND_eater, /* eater sits */
596 SOUND_eater_eat, /* eater eats diamond */
597 SOUND_alien, /* alien moves */
598 SOUND_collect, /* player collects object */
599 SOUND_diamond, /* diamond/emerald hits ground */
600 SOUND_squash, /* stone squashes diamond */
601 SOUND_wonderfall, /* object falls thru wonderwall */
602 SOUND_drip, /* drip hits ground */
603 SOUND_push, /* player pushes spring/balloon/android */
604 SOUND_dirt, /* player digs into dirt */
605 SOUND_acid, /* acid splashes */
606 SOUND_ball, /* ball places something */
607 SOUND_slide, /* slide wall grows */
608 SOUND_wonder, /* wonderwall is active */
609 SOUND_door, /* player goes thru door (gate) */
610 SOUND_exit_open, /* exit opens */
611 SOUND_exit_leave, /* player goes into exit */
612 SOUND_dynamite, /* player places dynamite */
613 SOUND_tick, /* dynamite ticks */
614 SOUND_press, /* player presses wheel/wind/switch */
615 SOUND_wheel, /* wheel moves */
616 SOUND_boom, /* explosion */
617 SOUND_time, /* time runs out */
618 SOUND_die, /* player dies */
624 // ----------------------------------------------------------------------------
625 // data structure definitions
626 // ----------------------------------------------------------------------------
628 /* structure used by logic() for gameplay */
632 int num; /* player number */
640 boolean exists; /* flag if player exists in cave */
641 boolean alive; /* flag if player is alive */
643 int dynamite; /* number of pieces of collected dynamite */
644 int dynamite_cnt; /* how long the player has held down fire */
645 int keys; /* keys the player has collected */
660 int width; /* cave width */
661 int height; /* cave height */
663 int left; /* cave left edge */
664 int top; /* cave top edge */
665 int right; /* cave right edge */
666 int bottom; /* cave bottom edge */
668 int time; /* time remaining */
669 int gems_needed; /* emeralds needed */
670 int score; /* score */
672 int eater_score; /* score for killing eater */
673 int alien_score; /* score for killing alien */
674 int bug_score; /* score for killing bug */
675 int tank_score; /* score for killing tank */
676 int slurp_score; /* score for slurping alien with spring */
677 int nut_score; /* score for cracking nut to emerald */
678 int emerald_score; /* score for collecting emerald */
679 int diamond_score; /* score for collecting diamond */
680 int dynamite_score; /* score for collecting dynamite */
681 int key_score; /* score for colleting key */
682 int lenses_score; /* score for collecting lenses */
683 int magnify_score; /* score for collecting magnifier */
684 int exit_score; /* score for entering exit */
686 int android_move_time; /* reset time for android movement */
687 int android_clone_time; /* reset time for android cloning */
688 int ball_time; /* reset time for ball activity */
689 int amoeba_time; /* amoeba growth speed */
690 int wonderwall_time; /* reset time for wonderwall activity */
691 int wheel_time; /* reset time for wheel activity */
692 int wheel_x; /* wheel x position */
693 int wheel_y; /* wheel y position */
694 int lenses_time; /* reset time for lenses activity */
695 int magnify_time; /* reset time for magnifier activity */
696 int wind_time; /* reset time for wind activity */
697 int wind_direction; /* wind direction */
699 boolean ball_random; /* flag if ball is random */
700 boolean ball_active; /* flag if ball is already active */
701 boolean wonderwall_active; /* flag if wonderwall is already active */
703 int wheel_cnt; /* counter for wheel activity */
704 int lenses_cnt; /* counter for lenses activity */
705 int magnify_cnt; /* counter for magnifier activity */
706 int wind_cnt; /* counter for wind activity */
707 int android_move_cnt; /* counter for android movement */
708 int android_clone_cnt; /* counter for android cloning */
709 int ball_cnt; /* counter for ball activity */
710 int ball_pos; /* counter for ball array position */
711 int eater_pos; /* counter for eater array position */
712 int shine_cnt; /* counter for emerald/diamond shining */
714 int num_eater_arrays; /* number of eater data arrays used */
715 int num_ball_arrays; /* number of ball data arrays used */
717 int home_initial; /* number of players (initial) */
718 int home; /* number of players not yet at home */
719 /* 0 == all players at home */
721 boolean testmode; /* test mode */
722 boolean infinite; /* flag for infinitely wide cave */
723 boolean infinite_true; /* flag for truely infinitely wide cave */
724 boolean killed_out_of_time; /* kill player due to time out */
726 int exit_x, exit_y; /* kludge for playing player exit sound */
728 short eater_array[8][9]; /* eater data */
729 short ball_array[8][8]; /* ball data */
730 short android_array[GAME_TILE_MAX]; /* android clone data */
732 short cavebuf[CAVE_BUFFER_WIDTH][CAVE_BUFFER_HEIGHT];
733 short nextbuf[CAVE_BUFFER_WIDTH][CAVE_BUFFER_HEIGHT];
734 short drawbuf[CAVE_BUFFER_WIDTH][CAVE_BUFFER_HEIGHT];
735 short boombuf[CAVE_BUFFER_WIDTH][CAVE_BUFFER_HEIGHT];
737 short *cavecol[CAVE_BUFFER_WIDTH];
738 short *nextcol[CAVE_BUFFER_WIDTH];
739 short *drawcol[CAVE_BUFFER_WIDTH];
740 short *boomcol[CAVE_BUFFER_WIDTH];