From 3a606b24c2e6459e8522f060d37f8f4b9434c4b8 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 22 Feb 2023 18:51:19 +0100 Subject: [PATCH] fixed using wall tiles as gray ball content elements in MM engine --- src/game_mm/mm_game.c | 52 ++++++++++++++++++++++++++++++++++++++---- src/game_mm/mm_main.h | 1 + src/game_mm/mm_tools.c | 15 ++++++++++++ src/game_mm/mm_tools.h | 2 ++ 4 files changed, 66 insertions(+), 4 deletions(-) diff --git a/src/game_mm/mm_game.c b/src/game_mm/mm_game.c index 2805fb77..4ad6ea61 100644 --- a/src/game_mm/mm_game.c +++ b/src/game_mm/mm_game.c @@ -2463,7 +2463,20 @@ static void OpenSurpriseBall(int x, int y) int delay = 2; if (!MovDelay[x][y]) // next animation frame + { + if (IS_WALL(Store[x][y])) + { + DrawWalls_MM(x, y, Store[x][y]); + + // copy wall tile to spare bitmap for "melting" animation + BlitBitmap(drawto, bitmap_db_field, cSX + x * TILEX, cSY + y * TILEY, + TILEX, TILEY, x * TILEX, y * TILEY); + + DrawElement_MM(x, y, EL_BALL_GRAY); + } + MovDelay[x][y] = 50 * delay; + } if (MovDelay[x][y]) // wait some time before next frame { @@ -2472,11 +2485,22 @@ static void OpenSurpriseBall(int x, int y) if (!(MovDelay[x][y] % delay) && IN_SCR_FIELD(x, y)) { Bitmap *bitmap; - int graphic = el2gfx(Store[x][y]); int gx, gy; int dx = RND(26), dy = RND(26); - getGraphicSource(graphic, 0, &bitmap, &gx, &gy); + if (IS_WALL(Store[x][y])) + { + // copy wall tile from spare bitmap for "melting" animation + bitmap = bitmap_db_field; + gx = x * TILEX; + gy = y * TILEY; + } + else + { + int graphic = el2gfx(Store[x][y]); + + getGraphicSource(graphic, 0, &bitmap, &gx, &gy); + } BlitBitmap(bitmap, drawto, gx + dx, gy + dy, 6, 6, cSX + x * TILEX + dx, cSY + y * TILEY + dy); @@ -2488,6 +2512,8 @@ static void OpenSurpriseBall(int x, int y) if (!MovDelay[x][y]) { + int i; + Tile[x][y] = Store[x][y]; Store[x][y] = Store2[x][y] = 0; MovDir[x][y] = MovPos[x][y] = MovDelay[x][y] = 0; @@ -2495,6 +2521,15 @@ static void OpenSurpriseBall(int x, int y) InitField(x, y, FALSE); DrawField_MM(x, y); + for (i = (laser.num_damages > 0 ? laser.num_damages - 1 : 0); i >= 0; i--) + if (laser.damage[i].is_mirror) + break; + + if (i > 0) + DrawLaser(laser.damage[i].edge - 1, DL_LASER_DISABLED); + else + DrawLaser(0, DL_LASER_DISABLED); + ScanLaser(); } } @@ -3499,10 +3534,19 @@ static void GameActions_MM_Ext(void) game_mm.ball_choice_pos++; int new_element = native_mm_level.ball_content[element_pos]; + int new_element_unmapped = unmap_element(new_element); - // randomly rotate newly created game element, if needed - if (native_mm_level.rotate_ball_content) + if (IS_WALL(new_element_unmapped)) + { + // always use completely filled wall element + new_element = new_element_unmapped | 0x000f; + } + else if (native_mm_level.rotate_ball_content && + get_num_elements(new_element) > 1) + { + // randomly rotate newly created game element new_element = get_rotated_element(new_element, RND(16)); + } Store[ELX][ELY] = new_element; Store2[ELX][ELY] = TRUE; diff --git a/src/game_mm/mm_main.h b/src/game_mm/mm_main.h index dafaa5d6..f8b775fc 100644 --- a/src/game_mm/mm_main.h +++ b/src/game_mm/mm_main.h @@ -189,6 +189,7 @@ extern DrawBuffer *drawto_field; +extern DrawBuffer *bitmap_db_field; extern int game_status; extern boolean level_editor_test_game; diff --git a/src/game_mm/mm_tools.c b/src/game_mm/mm_tools.c index d8dbe8be..4e9254a7 100644 --- a/src/game_mm/mm_tools.c +++ b/src/game_mm/mm_tools.c @@ -1293,6 +1293,21 @@ static int map_element(int element) } } +int unmap_element(int element) +{ + switch (element) + { + case EL_STEEL_WALL: return EL_WALL_STEEL; + case EL_WOODEN_WALL: return EL_WALL_WOOD; + case EL_ICE_WALL: return EL_WALL_ICE; + case EL_AMOEBA_WALL: return EL_WALL_AMOEBA; + case EL_DF_STEEL_WALL: return EL_DF_WALL_STEEL; + case EL_DF_WOODEN_WALL: return EL_DF_WALL_WOOD; + + default: return element; + } +} + int el2gfx(int element) { return el2img_mm(map_element(element)); diff --git a/src/game_mm/mm_tools.h b/src/game_mm/mm_tools.h index 58b2beb0..8857d7ba 100644 --- a/src/game_mm/mm_tools.h +++ b/src/game_mm/mm_tools.h @@ -106,6 +106,8 @@ int get_element_phase(int); int get_num_elements(int); int get_rotated_element(int, int); +int unmap_element(int); + int el2gfx(int); int el_act2gfx(int, int); -- 2.34.1