X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_mm%2Fmm_game.c;h=8f61572d9c26a69da2b14f0704949c1ad049ca15;hb=46f998cb9e98f77911bbfa8a24f80d062af8acaa;hp=c3d573db93c59ff2430e378f4c7595246b49e1fe;hpb=e045b84cb4938c7fd5413664675245f5d4fd0791;p=rocksndiamonds.git diff --git a/src/game_mm/mm_game.c b/src/game_mm/mm_game.c index c3d573db..8f61572d 100644 --- a/src/game_mm/mm_game.c +++ b/src/game_mm/mm_game.c @@ -411,6 +411,20 @@ static void CheckExitMM(void) PlayLevelSound_MM(exit_x, exit_y, exit_element, MM_ACTION_OPENING); } +static void SetLaserColor(int brightness) +{ + int color_min = 0x00; + int color_max = brightness; // (0x00 <= brightness <= 0xFF) + int color_up = color_max * laser.overload_value / MAX_LASER_OVERLOAD; + int color_down = color_max - color_up; + + pen_ray = + GetPixelFromRGB(window, + (native_mm_level.laser_red ? color_max : color_up), + (native_mm_level.laser_green ? color_down : color_min), + (native_mm_level.laser_blue ? color_down : color_min)); +} + static void InitMovDir_MM(int x, int y) { int element = Tile[x][y]; @@ -573,10 +587,7 @@ static void InitLaser(void) AddLaserEdge(LX, LY); // set laser starting edge - pen_ray = GetPixelFromRGB(window, - native_mm_level.laser_red * 0xFF, - native_mm_level.laser_green * 0xFF, - native_mm_level.laser_blue * 0xFF); + SetLaserColor(0xFF); } void InitGameEngine_MM(void) @@ -714,19 +725,13 @@ void InitGameActions_MM(void) SetTileCursorActive(TRUE); } -static void FadeOutLaser(boolean overloaded) +static void FadeOutLaser(void) { 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); + SetLaserColor(0x11 * i); DrawLaser(0, DL_LASER_ENABLED); @@ -736,8 +741,28 @@ static void FadeOutLaser(boolean overloaded) DrawLaser(0, DL_LASER_DISABLED); - if (!overloaded) - StopSound_MM(SND_MM_GAME_HEALTH_CHARGING); + 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) @@ -2512,10 +2537,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; } @@ -2523,7 +2545,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]; @@ -3174,6 +3196,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) @@ -3184,14 +3210,9 @@ static void GameActions_MM_Ext(void) } else if (game.time_limit && !game_mm.game_over) { - FadeOutLaser(FALSE); - - game_mm.game_over = TRUE; - game_mm.game_over_cause = GAME_OVER_NO_ENERGY; - - SetTileCursorActive(FALSE); + FadeOutLaser(); - game.restart_game_message = "Out of magic energy! Play it again?"; + GameOver_MM(GAME_OVER_NO_ENERGY); return; } @@ -3240,18 +3261,7 @@ static void GameActions_MM_Ext(void) if (laser.overload_value < MAX_LASER_OVERLOAD - 8) { - int color_up = 0xFF * laser.overload_value / MAX_LASER_OVERLOAD; - int color_down = 0xFF - color_up; - -#if 0 - 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)); + SetLaserColor(0xFF); DrawLaser(0, DL_LASER_ENABLED); } @@ -3291,14 +3301,9 @@ static void GameActions_MM_Ext(void) { UpdateAndDisplayGameControlValues(); - FadeOutLaser(TRUE); - - game_mm.game_over = TRUE; - game_mm.game_over_cause = GAME_OVER_OVERLOADED; - - SetTileCursorActive(FALSE); + FadeOutLaser(); - game.restart_game_message = "Magic spell hit Mc Duffin! Play it again?"; + GameOver_MM(GAME_OVER_OVERLOADED); return; }