X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_em%2Fsynchro_2.c;h=c4b9a678b3e1e9dbf5ebb3302986d70c76736abf;hb=61c3da024802ecc0268bab42d7499fc0346e4fd3;hp=119d86a5832c1fd7d229d0e5b96057388937fce5;hpb=68f0ce90185b6ea19cad62bc6328326bda538951;p=rocksndiamonds.git diff --git a/src/game_em/synchro_2.c b/src/game_em/synchro_2.c index 119d86a5..c4b9a678 100644 --- a/src/game_em/synchro_2.c +++ b/src/game_em/synchro_2.c @@ -8,25 +8,48 @@ * compilers suck. */ -#include "display.h" -#include "tile.h" -#include "level.h" -#include "sample.h" +#include "main_em.h" #define RANDOM (random = random << 31 | random >> 1) +static void set_nearest_player_xy(int x, int y, int *dx, int *dy) +{ + int distance, distance_shortest = EM_MAX_CAVE_WIDTH + EM_MAX_CAVE_HEIGHT; + int i; + + /* default values if no players are alive anymore */ + *dx = 0; + *dy = 0; + + for (i = 0; i < MAX_PLAYERS; i++) + { + if (!ply[i].alive) + continue; + + distance = ABS(ply[i].x - x) + ABS(ply[i].y - y); + + if (distance < distance_shortest) + { + *dx = ply[i].x; + *dy = ply[i].y; + + distance_shortest = distance; + } + } +} + void synchro_2(void) { - register unsigned int x = 0; - register unsigned int y = 1; - register unsigned long random = RandomEM; - register unsigned short *cave_cache = Cave[y]; /* might be a win */ - unsigned long score = 0; - - unsigned int temp = 0; /* initialized to make compilers happy */ - unsigned int dx; /* only needed to find closest player */ - unsigned int dy; + int x = 0; + int y = 1; + unsigned int random = RandomEM; + short *cave_cache = Cave[y]; /* might be a win */ + int score = 0; + + int temp = 0; /* initialized to make compilers happy */ + int dx; /* only needed to find closest player */ + int dy; int element; loop: @@ -588,7 +611,7 @@ void synchro_2(void) Boom[y+2][x-1] = Xemerald; Boom[y+2][x] = Xemerald; Boom[y+2][x+1] = Xemerald; -#if 0 +#if PLAY_ELEMENT_SOUND play_element_sound(x, y, SAMPLE_boom, element); #endif score += lev.bug_score; @@ -614,7 +637,7 @@ void synchro_2(void) Boom[y+2][x-1] = Xblank; Boom[y+2][x] = Xblank; Boom[y+2][x+1] = Xblank; -#if 0 +#if PLAY_ELEMENT_SOUND play_element_sound(x, y, SAMPLE_boom, element); #endif score += lev.tank_score; @@ -674,7 +697,7 @@ void synchro_2(void) Boom[y+2][x-1] = lev.eater_array[lev.eater_pos][6]; Boom[y+2][x] = lev.eater_array[lev.eater_pos][7]; Boom[y+2][x+1] = lev.eater_array[lev.eater_pos][8]; -#if 0 +#if PLAY_ELEMENT_SOUND play_element_sound(x, y, SAMPLE_boom, element); #endif lev.eater_pos = (lev.eater_pos + 1) & 7; @@ -695,7 +718,7 @@ void synchro_2(void) Boom[y+2][x-1] = Xblank; Boom[y+2][x] = Xblank; Boom[y+2][x+1] = Xblank; -#if 0 +#if PLAY_ELEMENT_SOUND play_element_sound(x, y, SAMPLE_boom, element); #endif score += lev.alien_score; @@ -776,7 +799,7 @@ void synchro_2(void) Boom[y+2][x-1] = Xblank; Boom[y+2][x] = Xblank; Boom[y+2][x+1] = Xblank; -#if 0 +#if PLAY_ELEMENT_SOUND play_element_sound(x, y, SAMPLE_boom, element); #endif goto loop; @@ -1879,6 +1902,12 @@ void synchro_2(void) Cave[y+1][x+1] == Zplayer) goto android_still; +#if 1 + + set_nearest_player_xy(x, y, &dx, &dy); + +#else + if (ply1.alive && ply2.alive) { if ((ply1.x > x ? ply1.x - x : x - ply1.x) + @@ -1911,6 +1940,8 @@ void synchro_2(void) dy = 0; } +#endif + Next[y][x] = Xblank; /* assume we will move */ temp = ((x < dx) + 1 - (x > dx)) + ((y < dy) + 1 - (y > dy)) * 3; @@ -2807,7 +2838,7 @@ void synchro_2(void) Boom[y+2][x-1] = Xblank; Boom[y+2][x] = Xblank; Boom[y+2][x+1] = Xblank; -#if 0 +#if PLAY_ELEMENT_SOUND play_element_sound(x, y, SAMPLE_boom, element); #endif goto loop; @@ -2832,7 +2863,7 @@ void synchro_2(void) Boom[y+2][x-1] = Xemerald; Boom[y+2][x] = Xemerald; Boom[y+2][x+1] = Xemerald; -#if 0 +#if PLAY_ELEMENT_SOUND play_element_sound(x, y, SAMPLE_boom, element); #endif score += lev.bug_score; @@ -2858,7 +2889,7 @@ void synchro_2(void) Boom[y+2][x-1] = Xblank; Boom[y+2][x] = Xblank; Boom[y+2][x+1] = Xblank; -#if 0 +#if PLAY_ELEMENT_SOUND play_element_sound(x, y, SAMPLE_boom, element); #endif score += lev.tank_score; @@ -2880,7 +2911,7 @@ void synchro_2(void) Boom[y+2][x-1] = lev.eater_array[lev.eater_pos][6]; Boom[y+2][x] = lev.eater_array[lev.eater_pos][7]; Boom[y+2][x+1] = lev.eater_array[lev.eater_pos][8]; -#if 0 +#if PLAY_ELEMENT_SOUND play_element_sound(x, y, SAMPLE_boom, element); #endif lev.eater_pos = (lev.eater_pos + 1) & 7; @@ -2901,7 +2932,7 @@ void synchro_2(void) Boom[y+2][x-1] = Xblank; Boom[y+2][x] = Xblank; Boom[y+2][x+1] = Xblank; -#if 0 +#if PLAY_ELEMENT_SOUND play_element_sound(x, y, SAMPLE_boom, element); #endif score += lev.alien_score; @@ -3205,6 +3236,21 @@ void synchro_2(void) /* --------------------------------------------------------------------- */ case Xalien: + +#if 1 + + if (lev.wheel_cnt) + { + dx = lev.wheel_x; + dy = lev.wheel_y; + } + else + { + set_nearest_player_xy(x, y, &dx, &dy); + } + +#else + if (lev.wheel_cnt) { dx = lev.wheel_x; @@ -3242,6 +3288,8 @@ void synchro_2(void) dy = 0; } +#endif + if (RANDOM & 1) { if (y > dy) @@ -4141,7 +4189,7 @@ void synchro_2(void) Boom[y+1][x-1] = Xblank; Boom[y+1][x] = Xblank; Boom[y+1][x+1] = Xblank; -#if 0 +#if PLAY_ELEMENT_SOUND play_element_sound(x, y, SAMPLE_boom, element); #endif goto loop; @@ -4668,6 +4716,16 @@ void synchro_2(void) case Xacid_6: case Xacid_7: case Xacid_8: +#if 1 + Cave[y][x] = Xsand_stonesand_quickout_1; + if (Cave[y][x+1] == Xblank) + Cave[y][x+1] = Yacid_splash_eB; + if (Cave[y][x-1] == Xblank) + Cave[y][x-1] = Yacid_splash_wB; + Next[y][x] = Xsand_stonesand_quickout_2; + play_element_sound(x, y, SAMPLE_acid, Xacid_1); + goto loop; +#else Cave[y][x] = Xsand_stonesand_3; if (Cave[y][x+1] == Xblank) Cave[y][x+1] = Yacid_splash_eB; @@ -4676,15 +4734,24 @@ void synchro_2(void) Next[y][x] = Xsand_stonesand_4; play_element_sound(x, y, SAMPLE_acid, Xacid_1); goto loop; +#endif case Xblank: case Yacid_splash_eB: case Yacid_splash_wB: +#if 1 + Cave[y][x] = Xsand_stonesand_quickout_1; + Cave[y+1][x] = Xsand_stoneout_1; + Next[y][x] = Xsand_stonesand_quickout_2; + Next[y+1][x] = Xsand_stoneout_2; + goto loop; +#else Cave[y][x] = Xsand_stonesand_3; Cave[y+1][x] = Xsand_stoneout_1; Next[y][x] = Xsand_stonesand_4; Next[y+1][x] = Xsand_stoneout_2; goto loop; +#endif case Xsand: Cave[y][x] = Xsand_stonesand_1; @@ -4729,6 +4796,16 @@ void synchro_2(void) Next[y][x] = Xsand; goto loop; +#if 1 + case Xsand_stonesand_quickout_1: + Next[y][x] = Xsand_stonesand_quickout_2; + goto loop; + + case Xsand_stonesand_quickout_2: + Next[y][x] = Xsand; + goto loop; +#endif + case Xsand_stoneout_1: Next[y][x] = Xsand_stoneout_2; goto loop; @@ -4830,7 +4907,7 @@ void synchro_2(void) Boom[y+1][x-1] = Xemerald; Boom[y+1][x] = Xemerald; Boom[y+1][x+1] = Xemerald; -#if 0 +#if PLAY_ELEMENT_SOUND play_element_sound(x, y, SAMPLE_boom, element); #endif goto loop; @@ -4849,19 +4926,22 @@ void synchro_2(void) Boom[y+1][x-1] = Xblank; Boom[y+1][x] = Xblank; Boom[y+1][x+1] = Xblank; -#if 0 +#if PLAY_ELEMENT_SOUND play_element_sound(x, y, SAMPLE_boom, element); #endif goto loop; case Xboom_android: -#if 0 +#if PLAY_ELEMENT_SOUND play_element_sound(x, y, SAMPLE_boom, Xandroid); #endif case Xboom_1: Next[y][x] = Xboom_2; -#if 1 - play_sound(x, y, SAMPLE_boom); +#if !PLAY_ELEMENT_SOUND + if (x != lev.exit_x && y != lev.exit_y) + play_sound(x, y, SAMPLE_boom); + else + lev.exit_x = lev.exit_y = -1; #endif goto loop; @@ -4888,8 +4968,8 @@ void synchro_2(void) done: - if (ply1.alive || ply2.alive) - lev.score += score; /* only get a score if someone is alive */ + if (ply[0].alive || ply[1].alive || ply[2].alive || ply[3].alive) + lev.score += score; /* only add a score if someone is alive */ RandomEM = random;