X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_mm%2Fmm_game.c;h=9d32be5e813033793684fdcf3a1940cb3f43ed93;hb=28d0092120f3b0038bf15b4c19f494219851599f;hp=7b8a139b114fe8647bf23c6e37becc1af4c5b9d5;hpb=be40beef1065b50786c34b2da9fa51f2c8927a0c;p=rocksndiamonds.git diff --git a/src/game_mm/mm_game.c b/src/game_mm/mm_game.c index 7b8a139b..9d32be5e 100644 --- a/src/game_mm/mm_game.c +++ b/src/game_mm/mm_game.c @@ -714,6 +714,53 @@ void InitGameActions_MM(void) SetTileCursorActive(TRUE); } +static void FadeOutLaser(boolean overloaded) +{ + int i; + + for (i = 15; i >= 0; i--) + { + if (overloaded) + pen_ray = GetPixelFromRGB(window, 0x11 * i, 0x00, 0x00); + else + pen_ray = GetPixelFromRGB(window, + 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_WithScreenUpdates(50); + } + + DrawLaser(0, DL_LASER_DISABLED); + + if (!overloaded) + StopSound_MM(SND_MM_GAME_HEALTH_CHARGING); +} + +static void GameOver_MM(int game_over_cause) +{ + // do not handle game over if request dialog is already active + if (game.request_active) + return; + + game_mm.game_over = TRUE; + game_mm.game_over_cause = game_over_cause; + + if (setup.ask_on_game_over) + game.restart_game_message = (game_over_cause == GAME_OVER_BOMB ? + "Bomb killed Mc Duffin! Play it again?" : + game_over_cause == GAME_OVER_NO_ENERGY ? + "Out of magic energy! Play it again?" : + game_over_cause == GAME_OVER_OVERLOADED ? + "Magic spell hit Mc Duffin! Play it again?" : + NULL); + + SetTileCursorActive(FALSE); +} + void AddLaserEdge(int lx, int ly) { int clx = dSX + lx; @@ -2486,10 +2533,7 @@ static void Explode_MM(int x, int y, int phase, int mode) Bang_MM(laser.start_edge.x, laser.start_edge.y); Store[x][y] = EL_EMPTY; - game_mm.game_over = TRUE; - game_mm.game_over_cause = GAME_OVER_BOMB; - - SetTileCursorActive(FALSE); + GameOver_MM(GAME_OVER_DELAYED); laser.overloaded = FALSE; } @@ -2497,7 +2541,7 @@ static void Explode_MM(int x, int y, int phase, int mode) { Store[x][y] = EL_EMPTY; - game.restart_game_message = "Bomb killed Mc Duffin! Play it again?"; + GameOver_MM(GAME_OVER_BOMB); } Tile[x][y] = Store[x][y]; @@ -2950,7 +2994,9 @@ void RotateMirror(int x, int y, int button) LX, LY, laser.beamer_edge, laser.beamer[1].num); #endif +#if 0 laser.num_edges--; +#endif } ScanLaser(); @@ -3146,6 +3192,10 @@ static void GameActions_MM_Ext(void) } } + // skip all following game actions if game is over + if (game_mm.game_over) + return; + if (FrameReached(&energy_delay)) { if (game_mm.energy_left > 0) @@ -3156,35 +3206,9 @@ static void GameActions_MM_Ext(void) } else if (game.time_limit && !game_mm.game_over) { - int i; + FadeOutLaser(FALSE); - for (i = 15; i >= 0; i--) - { -#if 0 - SetRGB(pen_ray, 0x0000, 0x0000, i * color_scale); -#endif - pen_ray = GetPixelFromRGB(window, - 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_WithScreenUpdates(50); - } - - StopSound_MM(SND_MM_GAME_HEALTH_CHARGING); -#if 0 - FadeMusic(); -#endif - - DrawLaser(0, DL_LASER_DISABLED); - game_mm.game_over = TRUE; - game_mm.game_over_cause = GAME_OVER_NO_ENERGY; - - SetTileCursorActive(FALSE); - - game.restart_game_message = "Out of magic energy! Play it again?"; + GameOver_MM(GAME_OVER_NO_ENERGY); return; } @@ -3282,31 +3306,11 @@ static void GameActions_MM_Ext(void) if (laser.overload_value == MAX_LASER_OVERLOAD) { - int i; - UpdateAndDisplayGameControlValues(); - 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_WithScreenUpdates(50); - } - - DrawLaser(0, DL_LASER_DISABLED); - - game_mm.game_over = TRUE; - game_mm.game_over_cause = GAME_OVER_OVERLOADED; - - SetTileCursorActive(FALSE); + FadeOutLaser(TRUE); - game.restart_game_message = "Magic spell hit Mc Duffin! Play it again?"; + GameOver_MM(GAME_OVER_OVERLOADED); return; }