X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fgame_mm%2Fmm_game.c;h=d282dfe110eccbb1db631072a13035ee07ce64c0;hp=4f4af5f87c9aac8c71acb7a51ab4ffd0803cf6e6;hb=55961e9ba1fe67292a41fdcca0056b43bf960a93;hpb=e67a93043d558993882f89c5f2a933882f934a29 diff --git a/src/game_mm/mm_game.c b/src/game_mm/mm_game.c index 4f4af5f8..d282dfe1 100644 --- a/src/game_mm/mm_game.c +++ b/src/game_mm/mm_game.c @@ -55,20 +55,23 @@ #define IS_MUSIC_SOUND(s) ((s) == SND_TYGER || (s) == SND_VOYAGER) /* game button identifiers */ -#define GAME_CTRL_ID_LEFT 0 -#define GAME_CTRL_ID_MIDDLE 1 -#define GAME_CTRL_ID_RIGHT 2 +#define GAME_CTRL_ID_LEFT 0 +#define GAME_CTRL_ID_MIDDLE 1 +#define GAME_CTRL_ID_RIGHT 2 -#define NUM_GAME_BUTTONS 3 +#define NUM_GAME_BUTTONS 3 /* values for DrawLaser() */ -#define DL_LASER_DISABLED 0 -#define DL_LASER_ENABLED 1 +#define DL_LASER_DISABLED 0 +#define DL_LASER_ENABLED 1 /* values for 'click_delay_value' in ClickElement() */ #define CLICK_DELAY_SHORT 125 #define CLICK_DELAY_LONG 250 + #define AUTO_ROTATE_DELAY CLICK_DELAY_SHORT +#define INIT_GAME_ACTIONS_DELAY ONE_SECOND_DELAY +#define NUM_INIT_CYCLE_STEPS 16 /* forward declaration for internal use */ static int MovingOrBlocked2Element_MM(int, int); @@ -114,9 +117,9 @@ static void InitMovDir_MM(int x, int y) int element = Feld[x][y]; static int direction[3][4] = { - { MV_RIGHT, MV_UP, MV_LEFT, MV_DOWN }, - { MV_LEFT, MV_DOWN, MV_RIGHT, MV_UP }, - { MV_LEFT, MV_RIGHT, MV_UP, MV_DOWN } + { MV_RIGHT, MV_UP, MV_LEFT, MV_DOWN }, + { MV_LEFT, MV_DOWN, MV_RIGHT, MV_UP }, + { MV_LEFT, MV_RIGHT, MV_UP, MV_DOWN } }; switch(element) @@ -215,41 +218,28 @@ static void InitField(int x, int y, boolean init_game) } } -static void InitCycleElements() +static void InitCycleElements_RotateSingleStep() { - int i, j; + int i; if (game_mm.num_cycle == 0) /* no elements to cycle */ return; - for(i=0; i<16; i++) + for (i = 0; i < game_mm.num_cycle; i++) { - for(j=0; j= SXSIZE + 2 || ly >= SYSIZE + 2) { Error(ERR_WARN, "AddLaserEdge: out of bounds: %d, %d", lx, ly); + return; } @@ -464,8 +453,8 @@ boolean StepBehind() return ((x - last_x) * XS < 0 || (y - last_y) * YS < 0); } - else - return FALSE; + + return FALSE; } static int getMaskFromElement(int element) @@ -505,7 +494,7 @@ int ScanPixel() } #endif - for (i=0; i<4; i++) + for (i = 0; i < 4; i++) { int px = LX + (i % 2) * 2; int py = LY + (i / 2) * 2; @@ -570,6 +559,10 @@ void ScanLaser() int element; int end = 0, rf = laser.num_edges; + /* do not scan laser again after the game was lost for whatever reason */ + if (game_mm.game_over) + return; + laser.overloaded = FALSE; laser.stops_inside_element = FALSE; @@ -588,6 +581,7 @@ void ScanLaser() { end = 1; laser.overloaded = TRUE; + break; } @@ -677,6 +671,7 @@ void ScanLaser() if (HitBlock(element, hit_mask)) { rf = 1; + break; } } @@ -731,6 +726,7 @@ void ScanLaser() LX -= XS; LY -= YS; + AddLaserEdge(LX, LY); } @@ -758,12 +754,14 @@ void DrawLaserExt(int start_edge, int num_edges, int mode) if (start_edge < 0) { Error(ERR_WARN, "DrawLaserExt: start_edge < 0"); + return; } if (num_edges < 0) { Error(ERR_WARN, "DrawLaserExt: num_edges < 0"); + return; } @@ -792,18 +790,19 @@ void DrawLaserExt(int start_edge, int num_edges, int mode) /* determine the starting edge, from which graphics need to be restored */ if (start_edge > 0) { - for(i=0; i %d\n", laser.beamer_edge[i]); printf("DrawLaserExt: IS_BEAMER: [%d]: Hit[%d][%d] == %d [%d]\n", mode, elx, ely, Hit[elx][ely], start_edge); @@ -844,6 +843,7 @@ void DrawLaserExt(int start_edge, int num_edges, int mode) { /* element is outgoing beamer */ laser.num_damages = damage_start + 1; + if (IS_BEAMER(element)) laser.current_angle = get_element_angle(element); } @@ -866,6 +866,7 @@ void DrawLaserExt(int start_edge, int num_edges, int mode) laser.num_edges = start_edge + 1; if (start_edge == 0) laser.current_angle = laser.start_angle; + LX = laser.edge[start_edge].x - (SX + 2); LY = laser.edge[start_edge].y - (SY + 2); XS = 2 * Step[laser.current_angle].x; @@ -936,6 +937,7 @@ void DrawLaser(int start_edge, int mode) if (laser.num_edges - start_edge < 0) { Error(ERR_WARN, "DrawLaser: laser.num_edges - start_edge < 0"); + return; } @@ -949,7 +951,7 @@ void DrawLaser(int start_edge, int mode) int tmp_start_edge = start_edge; /* draw laser segments forward from the start to the last beamer */ - for (i=0; i=0; i--) + for (i = num_beamers-1; i >= 0; i--) { int tmp_num_edges = last_num_edges - laser.beamer_edge[i]; @@ -984,6 +987,7 @@ void DrawLaser(int start_edge, int mode) break; DrawLaserExt(laser.beamer_edge[i], tmp_num_edges, DL_LASER_DISABLED); + last_num_edges = laser.beamer_edge[i]; laser.num_beamers--; } @@ -999,7 +1003,9 @@ void DrawLaser(int start_edge, int mode) } } else + { DrawLaserExt(start_edge, laser.num_edges - start_edge, mode); + } } boolean HitElement(int element, int hit_mask) @@ -1069,7 +1075,8 @@ boolean HitElement(int element, int hit_mask) ((element - EL_POLAR_START) % 2 || (element - EL_POLAR_START) / 2 != laser.current_angle % 8)) { - PlaySoundStereo(SND_KINK, ST(ELX)); + PlayLevelSound_MM(ELX, ELY, element, MM_ACTION_HITTING); + laser.num_damages--; return TRUE; @@ -1078,7 +1085,8 @@ boolean HitElement(int element, int hit_mask) if (IS_POLAR_CROSS(element) && (element - EL_POLAR_CROSS_START) != laser.current_angle % 4) { - PlaySoundStereo(SND_KINK, ST(ELX)); + PlayLevelSound_MM(ELX, ELY, element, MM_ACTION_HITTING); + laser.num_damages--; return TRUE; @@ -1098,6 +1106,7 @@ boolean HitElement(int element, int hit_mask) LX = ELX * TILEX + 14; LY = ELY * TILEY + 14; + AddLaserEdge(LX, LY); } @@ -1114,7 +1123,9 @@ boolean HitElement(int element, int hit_mask) int step_size; laser.num_damages--; + AddDamagedField(ELX, ELY); + laser.damage[laser.num_damages - 1].is_mirror = TRUE; if (!Hit[ELX][ELY]) @@ -1152,7 +1163,7 @@ boolean HitElement(int element, int hit_mask) if ((!IS_POLAR(element) && !IS_POLAR_CROSS(element)) && current_angle != laser.current_angle) - PlaySoundStereo(SND_LASER, ST(ELX)); + PlayLevelSound_MM(ELX, ELY, element, MM_ACTION_HITTING); laser.overloaded = (get_opposite_angle(laser.current_angle) == @@ -1170,7 +1181,7 @@ boolean HitElement(int element, int hit_mask) if (element == EL_BOMB || element == EL_MINE) { - PlaySoundStereo(SND_KINK, ST(ELX)); + PlayLevelSound_MM(ELX, ELY, element, MM_ACTION_HITTING); if (element == EL_MINE) laser.overloaded = TRUE; @@ -1191,10 +1202,14 @@ boolean HitElement(int element, int hit_mask) if (element == EL_KETTLE || element == EL_CELL) { + if (game_mm.kettles_still_needed > 0) + game_mm.kettles_still_needed--; + RaiseScore_MM(10); if (game_mm.kettles_still_needed == 0) { + int exit_element = (element == EL_KETTLE ? EL_EXIT_OPEN : EL_RECEIVER); int x, y; static int xy[4][2] = { @@ -1204,11 +1219,11 @@ boolean HitElement(int element, int hit_mask) { 0, +1 } }; - PlaySoundStereo(SND_KLING, ST(ELX)); + PlayLevelSound_MM(ELX, ELY, exit_element, MM_ACTION_OPENING); - for(y=0; y 0) == (i % 2) && (YS > 0) == (i / 2)) mask = 15 - (8 >> i); @@ -1913,6 +1964,7 @@ boolean HitAbsorbingWalls(int element, int hit_mask) if (element2 != EL_EMPTY && !IS_WALL_AMOEBA(element2)) { laser.dest_element = EL_EMPTY; + return TRUE; } @@ -1946,8 +1998,9 @@ void OpenExit(int x, int y) MovDelay[x][y]--; phase = MovDelay[x][y] / delay; + if (!(MovDelay[x][y] % delay) && IN_SCR_FIELD(x, y)) - DrawGraphic_MM(x, y, EL_EXIT_OPEN - phase); + DrawGraphicAnimation_MM(x, y, IMG_MM_EXIT_OPENING, 3 - phase); if (!MovDelay[x][y]) { @@ -1967,6 +2020,7 @@ void OpenSurpriseBall(int x, int y) if (MovDelay[x][y]) /* wait some time before next frame */ { MovDelay[x][y]--; + if (!(MovDelay[x][y] % delay) && IN_SCR_FIELD(x, y)) { Bitmap *bitmap; @@ -1975,8 +2029,10 @@ void OpenSurpriseBall(int x, int y) int dx = RND(26), dy = RND(26); getGraphicSource(graphic, 0, &bitmap, &gx, &gy); + BlitBitmap(bitmap, drawto, gx + dx, gy + dy, 6, 6, SX + x * TILEX + dx, SY + y * TILEY + dy); + MarkTileDirty(x, y); } @@ -2020,7 +2076,7 @@ void MeltIce(int x, int y) if (Feld[x][y] == EL_WALL_ICE) Feld[x][y] = EL_EMPTY; - for (i = (laser.num_damages > 0 ? laser.num_damages - 1 : 0); i>=0; i--) + for (i = (laser.num_damages > 0 ? laser.num_damages - 1 : 0); i >= 0; i--) if (laser.damage[i].is_mirror) break; @@ -2066,7 +2122,9 @@ void GrowAmoeba(int x, int y) DrawLaser(0, DL_LASER_ENABLED); } else if (!(MovDelay[x][y] % delay) && IN_SCR_FIELD(x, y)) + { DrawWallsAnimation_MM(x, y, real_element, phase, wall_mask); + } } } @@ -2087,6 +2145,7 @@ static void Explode_MM(int x, int y, int phase, int mode) /* put moving element to center field (and let it explode there) */ center_element = MovingOrBlocked2Element_MM(x, y); RemoveMovingField_MM(x, y); + Feld[x][y] = center_element; } @@ -2094,6 +2153,7 @@ static void Explode_MM(int x, int y, int phase, int mode) Store[x][y] = center_element; else Store[x][y] = EL_EMPTY; + Store2[x][y] = mode; Feld[x][y] = EL_EXPLODING_OPAQUE; MovDir[x][y] = MovPos[x][y] = MovDelay[x][y] = 0; @@ -2133,6 +2193,7 @@ static void Explode_MM(int x, int y, int phase, int mode) Feld[x][y] = Store[x][y]; Store[x][y] = Store2[x][y] = 0; MovDir[x][y] = MovPos[x][y] = MovDelay[x][y] = 0; + InitField(x, y, FALSE); DrawField_MM(x, y); } @@ -2146,7 +2207,9 @@ static void Explode_MM(int x, int y, int phase, int mode) if (Store2[x][y] == EX_KETTLE) { if (graphic_phase < 3) + { graphic = IMG_MM_KETTLE_EXPLODING; + } else if (graphic_phase < 5) { graphic_phase += 3; @@ -2160,10 +2223,12 @@ static void Explode_MM(int x, int y, int phase, int mode) else if (Store2[x][y] == EX_SHORT) { if (graphic_phase < 4) + { graphic_phase += 4; + } else { - graphic = GFX_EMPTY; + graphic = IMG_EMPTY; graphic_phase = 0; } } @@ -2172,6 +2237,7 @@ static void Explode_MM(int x, int y, int phase, int mode) BlitBitmap(bitmap, drawto_field, src_x, src_y, TILEX, TILEY, FX + x * TILEX, FY + y * TILEY); + MarkTileDirty(x, y); } } @@ -2202,13 +2268,13 @@ static void Bang_MM(int x, int y) } if (IS_PACMAN(element)) - PlaySoundStereo(SND_QUIEK, ST(x)); + PlayLevelSound_MM(x, y, element, MM_ACTION_EXPLODING); else if (element == EL_BOMB || IS_MCDUFFIN(element)) - PlaySoundStereo(SND_ROAAAR, ST(x)); + PlayLevelSound_MM(x, y, element, MM_ACTION_EXPLODING); else if (element == EL_KEY) - PlaySoundStereo(SND_KLING, ST(x)); + PlayLevelSound_MM(x, y, element, MM_ACTION_EXPLODING); else - PlaySoundStereo((mode == EX_SHORT ? SND_WHOOSH : SND_KABUMM), ST(x)); + PlayLevelSound_MM(x, y, element, MM_ACTION_EXPLODING); Explode_MM(x, y, EX_PHASE_START, mode); } @@ -2247,7 +2313,7 @@ void TurnRound(int x, int y) int right_dir = turn[old_move_dir].right; int back_dir = turn[old_move_dir].back; int right_dx = move_xy[right_dir].x, right_dy = move_xy[right_dir].y; - int right_x = x+right_dx, right_y = y+right_dy; + int right_x = x + right_dx, right_y = y + right_dy; if (element == EL_PACMAN) { @@ -2295,6 +2361,7 @@ static void StartMoving_MM(int x, int y) { Store[newx][newy] = Feld[newx][newy]; Feld[newx][newy] = EL_EMPTY; + DrawField_MM(newx, newy); } else if (!IN_LEV_FIELD(newx, newy) || !IS_FREE(newx, newy) || @@ -2357,18 +2424,23 @@ static void ContinueMoving_MM(int x, int y) } } else /* still moving on */ + { DrawField_MM(x, y); + } laser.redraw = TRUE; } -void ClickElement(int mx, int my, int button) +void ClickElement(int x, int y, int button) { static unsigned int click_delay = 0; static int click_delay_value = CLICK_DELAY_SHORT; static boolean new_button = TRUE; int element; - int x = (mx - SX) / TILEX, y = (my - SY) / TILEY; + + /* do not rotate objects hit by the laser after the game was solved */ + if (game_mm.level_solved && Hit[x][y]) + return; if (button == MB_RELEASED) { @@ -2387,7 +2459,7 @@ void ClickElement(int mx, int my, int button) if (button == MB_MIDDLEBUTTON) /* middle button has no function */ return; - if (!IN_PIX_FIELD(mx - SX, my - SY)) + if (!IN_LEV_FIELD(x, y)) return; if (Feld[x][y] == EL_EMPTY) @@ -2409,6 +2481,7 @@ void ClickElement(int mx, int my, int button) if (!laser.fuse_off) { DrawLaser(0, DL_LASER_DISABLED); + /* BackToFront(); */ @@ -2421,9 +2494,11 @@ void ClickElement(int mx, int my, int button) Feld[x][y] = element; DrawField_MM(x, y); + /* BackToFront(); */ + if (!laser.fuse_off) ScanLaser(); } @@ -2492,7 +2567,9 @@ void RotateMirror(int x, int y, int button) hold_y = y; } else if (button == MB_RIGHTBUTTON && (hold_x != x || hold_y != y)) + { Feld[x][y] = get_rotated_element(Feld[x][y], ROTATE_RIGHT); + } } if (IS_GRID_STEEL_AUTO(Feld[x][y]) || IS_GRID_WOOD_AUTO(Feld[x][y])) @@ -2562,12 +2639,16 @@ void AutoRotateMirrors() if (!DelayReached(&rotate_delay, AUTO_ROTATE_DELAY)) return; - for (x=0; x 0x100) new = 0x001; } @@ -2680,7 +2762,7 @@ void ColorCycling(void) } } -static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode) +static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode) { static unsigned int action_delay = 0; static unsigned int pacman_delay = 0; @@ -2693,10 +2775,10 @@ static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode) WaitUntilDelayReached(&action_delay, GameFrameDelay); - for (y=0; y=0; i--) + for (i = 15; i >= 0; i--) { #if 0 SetRGB(pen_ray, 0x0000, 0x0000, i * color_scale); @@ -2766,12 +2848,13 @@ static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode) native_mm_level.laser_red * 0x11 * i, native_mm_level.laser_green * 0x11 * i, native_mm_level.laser_blue * 0x11 * i); + DrawLaser(0, DL_LASER_ENABLED); BackToFront(); Delay(50); } - StopSound(SND_WARNTON); + StopSound_MM(SND_MM_GAME_HEALTH_CHARGING); FadeMusic(); DrawLaser(0, DL_LASER_DISABLED); @@ -2832,6 +2915,8 @@ static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode) laser.overload_value = 0; } + game_mm.laser_overload_value = laser.overload_value; + if (laser.overload_value < MAX_LASER_OVERLOAD - 8) { int color_up = 0xFF * laser.overload_value / MAX_LASER_OVERLOAD; @@ -2841,24 +2926,22 @@ static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode) SetRGB(pen_ray, (laser.overload_value / 6) * color_scale, 0x0000, (15 - (laser.overload_value / 6)) * color_scale); #endif - pen_ray = GetPixelFromRGB(window, - (native_mm_level.laser_red ? 0xFF : color_up), - (native_mm_level.laser_green ? color_down : 0x00), - (native_mm_level.laser_blue ? color_down : 0x00)); + pen_ray = + GetPixelFromRGB(window, + (native_mm_level.laser_red ? 0xFF : color_up), + (native_mm_level.laser_green ? color_down : 0x00), + (native_mm_level.laser_blue ? color_down : 0x00)); + DrawLaser(0, DL_LASER_ENABLED); BackToFront(); } - if (laser.overloaded) - { - if (setup.sound_loops) - PlaySoundExt(SND_WARNTON, SOUND_MAX_VOLUME, SOUND_MAX_RIGHT, SND_CTRL_PLAY_LOOP); - else - PlaySoundStereo(SND_WARNTON, SOUND_MAX_RIGHT); - } - if (!laser.overloaded) - StopSound(SND_WARNTON); + StopSound_MM(SND_MM_GAME_HEALTH_CHARGING); + else if (setup.sound_loops) + PlaySoundLoop_MM(SND_MM_GAME_HEALTH_CHARGING); + else + PlaySound_MM(SND_MM_GAME_HEALTH_CHARGING); if (laser.overloaded) { @@ -2888,19 +2971,21 @@ static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode) { int i; - for(i=15; i>=0; i--) + for (i = 15; i >= 0; i--) { #if 0 SetRGB(pen_ray, i * color_scale, 0x0000, 0x0000); #endif pen_ray = GetPixelFromRGB(window, 0x11 * i, 0x00, 0x00); + DrawLaser(0, DL_LASER_ENABLED); BackToFront(); Delay(50); } DrawLaser(0, DL_LASER_DISABLED); + game_mm.game_over = TRUE; game_mm.game_over_cause = GAME_OVER_OVERLOADED; @@ -2969,6 +3054,7 @@ static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode) laser.fuse_off = TRUE; laser.fuse_x = ELX; laser.fuse_y = ELY; + DrawLaser(0, DL_LASER_DISABLED); DrawGraphic_MM(ELX, ELY, IMG_MM_FUSE); } @@ -3027,7 +3113,7 @@ static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode) graphic = el2gfx(element); - for(i=0; i<50; i++) + for (i = 0; i < 50; i++) { int x = RND(26); int y = RND(26); @@ -3094,9 +3180,7 @@ static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode) if (IS_WALL_ICE(element) && CT > 1000) { - PlaySoundStereo(SND_SLURP, ST(ELX)); - - + PlayLevelSound_MM(ELX, ELY, element, MM_ACTION_SHRINKING); { Feld[ELX][ELY] = Feld[ELX][ELY] - EL_WALL_ICE + EL_WALL_CHANGING; @@ -3108,10 +3192,7 @@ static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode) return; } - - - - for(i=0; i<5; i++) + for (i = 0; i < 5; i++) { int phase = i + 1; @@ -3135,7 +3216,7 @@ static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode) LY = laser.edge[laser.num_edges].y - (SY + 2); */ - for (i = (laser.num_damages > 0 ? laser.num_damages - 1 : 0); i>=0; i--) + for (i = (laser.num_damages > 0 ? laser.num_damages - 1 : 0); i >= 0; i--) if (laser.damage[i].is_mirror) break; @@ -3157,7 +3238,7 @@ static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode) if (element2 != EL_EMPTY && !IS_WALL_AMOEBA(element)) return; - for (i = laser.num_damages - 1; i>=0; i--) + for (i = laser.num_damages - 1; i >= 0; i--) if (laser.damage[i].is_mirror) break; @@ -3177,10 +3258,11 @@ static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode) x = laser.damage[k1].x; y = laser.damage[k1].y; + DrawField_MM(x, y); } - for(i=0; i<4; i++) + for (i = 0; i < 4; i++) { if (laser.wall_mask & (1 << i)) { @@ -3197,7 +3279,7 @@ static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode) k2 = i; - for(i=0; i<4; i++) + for (i = 0; i < 4; i++) { if (laser.wall_mask & (1 << i)) { @@ -3217,29 +3299,26 @@ static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode) { laser.num_edges = r; laser.num_damages = d; + DrawLaser(0, DL_LASER_DISABLED); } Feld[ELX][ELY] = element | laser.wall_mask; + dx = ELX; dy = ELY; de = Feld[ELX][ELY]; dm = laser.wall_mask; - - #if 1 { int x = ELX, y = ELY; int wall_mask = laser.wall_mask; - ScanLaser(); DrawLaser(0, DL_LASER_ENABLED); - PlaySoundStereo(SND_AMOEBE, ST(dx)); - - + PlayLevelSound_MM(dx, dy, element, MM_ACTION_GROWING); Feld[x][y] = Feld[x][y] - EL_WALL_AMOEBA + EL_WALL_CHANGING; Store[x][y] = EL_WALL_AMOEBA; @@ -3249,17 +3328,16 @@ static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode) } #endif - - DrawWallsAnimation_MM(dx, dy, de, 4, dm); ScanLaser(); DrawLaser(0, DL_LASER_ENABLED); - PlaySoundStereo(SND_AMOEBE, ST(dx)); + PlayLevelSound_MM(dx, dy, element, MM_ACTION_GROWING); - for(i=4; i>=0; i--) + for (i = 4; i >= 0; i--) { DrawWallsAnimation_MM(dx, dy, de, i, dm); + BackToFront(); Delay(20); } @@ -3282,12 +3360,12 @@ static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode) if (XS < YS) k += 2; - for(i=0; i<4; i++) + for (i = 0; i < 4; i++) { if (i) k++; if (k > 3) - k=0; + k = 0; x = ELX + Step[k * 4].x; y = ELY + Step[k * 4].y; @@ -3304,15 +3382,16 @@ static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode) if (i > 3) { laser.overloaded = (element == EL_BLOCK_STONE); + return; } - PlaySoundStereo(SND_BONG, ST(ELX)); + PlayLevelSound_MM(ELX, ELY, element, MM_ACTION_PUSHING); Feld[ELX][ELY] = 0; Feld[x][y] = element; - DrawGraphic_MM(ELX, ELY, -1); + DrawGraphic_MM(ELX, ELY, IMG_EMPTY); DrawField_MM(x, y); if (element == EL_BLOCK_STONE && Box[ELX][ELY]) @@ -3328,7 +3407,7 @@ static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode) if (element == EL_FUEL_FULL && CT > 200) { - for(i=game_mm.energy_left; i<=MAX_LASER_ENERGY; i+=2) + for (i = game_mm.energy_left; i <= MAX_LASER_ENERGY; i+=2) { #if 0 BlitBitmap(pix[PIX_DOOR], drawto, @@ -3356,10 +3435,9 @@ static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode) return; } -void GameActions_MM(byte action[MAX_PLAYERS], boolean warp_mode) +void GameActions_MM(struct MouseActionInfo action, boolean warp_mode) { - if (!button_status) - ClickElement(0, 0, MB_NOT_PRESSED); + ClickElement(action.lx, action.ly, action.button); GameActions_MM_Ext(action, warp_mode); } @@ -3368,14 +3446,15 @@ void MovePacMen() { static int p = -1; int mx, my, ox, oy, nx, ny; - int g, element; + int element; int l; if (++p >= game_mm.num_pacman) p = 0; + game_mm.pacman[p].dir--; - for(l=1; l<5; l++) + for (l = 1; l < 5; l++) { game_mm.pacman[p].dir++; @@ -3398,6 +3477,7 @@ void MovePacMen() nx = ox + mx; ny = oy + my; element = Feld[nx][ny]; + if (nx < 0 || nx > 15 || ny < 0 || ny > 11) continue; @@ -3415,32 +3495,29 @@ void MovePacMen() game_mm.pacman[p].x = nx; game_mm.pacman[p].y = ny; - g = Feld[nx][ny] - EL_PACMAN_RIGHT; + DrawGraphic_MM(ox, oy, IMG_EMPTY); if (element != EL_EMPTY) { + int graphic = el2gfx(Feld[nx][ny]); + Bitmap *bitmap; + int src_x, src_y; int i; + getGraphicSource(graphic, 0, &bitmap, &src_x, &src_y); + CT = Counter(); ox = SX + ox * TILEX; oy = SY + oy * TILEY; - for(i=1; i<33; i+=2) - { -#if 1 - // !!! temporary fix to compile -- change to game graphics !!! - BlitBitmap(drawto, window, - SX + g * TILEX, SY + 4 * TILEY, TILEX, TILEY, - ox + i * mx, oy + i * my); -#else - BlitBitmap(pix[PIX_BACK], window, - SX + g * TILEX, SY + 4 * TILEY, TILEX, TILEY, + for (i = 1; i < 33; i += 2) + BlitBitmap(bitmap, window, + src_x, src_y, TILEX, TILEY, ox + i * mx, oy + i * my); -#endif - } Ct = Ct + Counter() - CT; } + DrawField_MM(nx, ny); BackToFront(); @@ -3451,14 +3528,13 @@ void MovePacMen() if (ObjHit(nx, ny, HIT_POS_BETWEEN)) { AddDamagedField(nx, ny); + laser.damage[laser.num_damages - 1].edge = 0; } } if (element == EL_BOMB) - { DeletePacMan(nx, ny); - } if (IS_WALL_AMOEBA(element) && (LX + 2 * XS) / TILEX == nx && @@ -3467,6 +3543,7 @@ void MovePacMen() laser.num_edges--; ScanLaser(); } + break; } } @@ -3486,9 +3563,10 @@ void GameWon_MM() if (game_mm.energy_left) { if (setup.sound_loops) - PlaySoundExt(SND_SIRR, SOUND_MAX_VOLUME, SOUND_MAX_RIGHT, SND_CTRL_PLAY_LOOP); + PlaySoundExt(SND_SIRR, SOUND_MAX_VOLUME, SOUND_MAX_RIGHT, + SND_CTRL_PLAY_LOOP); - while(game_mm.energy_left > 0) + while (game_mm.energy_left > 0) { if (!setup.sound_loops) PlaySoundStereo(SND_SIRR, SOUND_MAX_RIGHT); @@ -3522,9 +3600,10 @@ void GameWon_MM() else if (native_mm_level.time == 0) /* level without time limit */ { if (setup.sound_loops) - PlaySoundExt(SND_SIRR, SOUND_MAX_VOLUME, SOUND_MAX_RIGHT, SND_CTRL_PLAY_LOOP); + PlaySoundExt(SND_SIRR, SOUND_MAX_VOLUME, SOUND_MAX_RIGHT, + SND_CTRL_PLAY_LOOP); - while(TimePlayed < 999) + while (TimePlayed < 999) { if (!setup.sound_loops) PlaySoundStereo(SND_SIRR, SOUND_MAX_RIGHT); @@ -3569,15 +3648,19 @@ void GameWon_MM() if ((hi_pos = NewHiScore_MM()) >= 0) { game_status = HALLOFFAME; + // DrawHallOfFame(hi_pos); + if (raise_level) level_nr++; } else { game_status = MAINMENU; + if (raise_level) level_nr++; + // DrawMainMenu(); } @@ -3595,7 +3678,7 @@ int NewHiScore_MM() game_mm.score < highscore[MAX_SCORE_ENTRIES - 1].Score) return -1; - for (k=0; k highscore[k].Score) { @@ -3606,14 +3689,14 @@ int NewHiScore_MM() int m = MAX_SCORE_ENTRIES - 1; #ifdef ONE_PER_NAME - for (l=k; lk; l--) + for (l = m; l>k; l--) { strcpy(highscore[l].Name, highscore[l - 1].Name); highscore[l].Score = highscore[l - 1].Score; @@ -3627,6 +3710,7 @@ int NewHiScore_MM() highscore[k].Name[MAX_PLAYER_NAME_LEN] = '\0'; highscore[k].Score = game_mm.score; position = k; + break; } @@ -3651,6 +3735,7 @@ static void InitMovingField_MM(int x, int y, int direction) MovDir[x][y] = direction; MovDir[newx][newy] = direction; + if (Feld[newx][newy] == EL_EMPTY) Feld[newx][newy] = EL_BLOCKED; } @@ -3693,10 +3778,11 @@ static int MovingOrBlocked2Element_MM(int x, int y) int oldx, oldy; Blocked2Moving_MM(x, y, &oldx, &oldy); + return Feld[oldx][oldy]; } - else - return element; + + return element; } #if 0 @@ -3779,6 +3865,7 @@ void PlaySoundLevel(int x, int y, int sound_nr) static void RaiseScore_MM(int value) { game_mm.score += value; + #if 0 DrawText(DX_SCORE, DY_SCORE, int2str(game_mm.score, 4), FONT_TEXT_2); @@ -3792,9 +3879,11 @@ void RaiseScoreElement_MM(int element) case EL_PACMAN: RaiseScore_MM(native_mm_level.score[SC_PACMAN]); break; + case EL_KEY: RaiseScore_MM(native_mm_level.score[SC_KEY]); break; + default: break; }