From: Holger Schemel Date: Fri, 26 Mar 2010 20:55:45 +0000 (+0100) Subject: rnd-20100326-2-src X-Git-Tag: 3.3.0.0^2~16 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=dc856cea3f61d1fecaf875fa519ac72c1c129713;p=rocksndiamonds.git rnd-20100326-2-src * added image config suffix ".class" to be able to define classes of crumbled elements which are then separated against each others when drawing crumbled borders (class names can freely be defined) * added image config suffix ".style" to use two new features for crumbled graphics: - "accurate_borders": try to draw correctly crumbled corners - "inner_corners": also draw inner corners -- this is a big kludge: number of frames for crumbled graphic must be "2", with the first frame as usual (crumbled graphic), while the second frame contains the inner corners for the crumbled graphic (These two features are mainly intended for bevelled walls, not for diggable elements like sand; "inner_corners" only reliably works for static walls, not for dynamically changing walls using CEs.) --- diff --git a/ChangeLog b/ChangeLog index bbe4d3ea..6766943e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2010-03-26 + * added image config suffix ".class" to be able to define classes of + crumbled elements which are then separated against each others when + drawing crumbled borders (class names can freely be defined) + * added image config suffix ".style" to use two new features for + crumbled graphics: + - "accurate_borders": try to draw correctly crumbled corners + - "inner_corners": also draw inner corners -- this is a big kludge: + number of frames for crumbled graphic must be "2", with the first + frame as usual (crumbled graphic), while the second frame contains + the inner corners for the crumbled graphic + (These two features are mainly intended for bevelled walls, not for + diggable elements like sand; "inner_corners" only reliably works for + static walls, not for dynamically changing walls using CEs.) + 2010-03-16 * continued code cleanup of native Supaplex game engine diff --git a/src/conftime.h b/src/conftime.h index 676fd677..a00f5051 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2010-03-25 22:15" +#define COMPILE_DATE_STRING "2010-03-26 21:45" diff --git a/src/game.c b/src/game.c index 4874b346..d486b15f 100644 --- a/src/game.c +++ b/src/game.c @@ -72,19 +72,19 @@ #if USE_DELAYED_GFX_REDRAW #define TEST_DrawLevelField(x, y) \ GfxRedraw[x][y] |= GFX_REDRAW_TILE -#define TEST_DrawLevelFieldCrumbledSand(x, y) \ +#define TEST_DrawLevelFieldCrumbled(x, y) \ GfxRedraw[x][y] |= GFX_REDRAW_TILE_CRUMBLED -#define TEST_DrawLevelFieldCrumbledSandNeighbours(x, y) \ +#define TEST_DrawLevelFieldCrumbledNeighbours(x, y) \ GfxRedraw[x][y] |= GFX_REDRAW_TILE_CRUMBLED_NEIGHBOURS #define TEST_DrawTwinkleOnField(x, y) \ GfxRedraw[x][y] |= GFX_REDRAW_TILE_TWINKLED #else #define TEST_DrawLevelField(x, y) \ DrawLevelField(x, y) -#define TEST_DrawLevelFieldCrumbledSand(x, y) \ - DrawLevelFieldCrumbledSand(x, y) -#define TEST_DrawLevelFieldCrumbledSandNeighbours(x, y) \ - DrawLevelFieldCrumbledSandNeighbours(x, y) +#define TEST_DrawLevelFieldCrumbled(x, y) \ + DrawLevelFieldCrumbled(x, y) +#define TEST_DrawLevelFieldCrumbledNeighbours(x, y) \ + DrawLevelFieldCrumbledNeighbours(x, y) #define TEST_DrawTwinkleOnField(x, y) \ DrawTwinkleOnField(x, y) #endif @@ -6150,7 +6150,7 @@ void Explode(int ex, int ey, int phase, int mode) TestIfElementTouchesCustomElement(x, y); if (GFX_CRUMBLED(element)) - TEST_DrawLevelFieldCrumbledSandNeighbours(x, y); + TEST_DrawLevelFieldCrumbledNeighbours(x, y); if (IS_PLAYER(x, y) && !PLAYERINFO(x, y)->present) StorePlayer[x][y] = 0; @@ -6164,7 +6164,7 @@ void Explode(int ex, int ey, int phase, int mode) int frame = getGraphicAnimationFrame(graphic, GfxFrame[x][y]); if (phase == delay) - TEST_DrawLevelFieldCrumbledSand(x, y); + TEST_DrawLevelFieldCrumbled(x, y); if (IS_WALKABLE_OVER(Back[x][y]) && Back[x][y] != EL_EMPTY) { @@ -6622,7 +6622,7 @@ static void RedrawAllLightSwitchesAndInvisibleElements() /* uncrumble neighbour fields, if needed */ if (element == EL_INVISIBLE_SAND) - TEST_DrawLevelFieldCrumbledSandNeighbours(x, y); + TEST_DrawLevelFieldCrumbledNeighbours(x, y); } else if (element == EL_INVISIBLE_STEELWALL_ACTIVE || element == EL_INVISIBLE_WALL_ACTIVE || @@ -6635,7 +6635,7 @@ static void RedrawAllLightSwitchesAndInvisibleElements() /* re-crumble neighbour fields, if needed */ if (element == EL_INVISIBLE_SAND) - TEST_DrawLevelFieldCrumbledSandNeighbours(x, y); + TEST_DrawLevelFieldCrumbledNeighbours(x, y); } } } @@ -6671,7 +6671,7 @@ static void RedrawAllInvisibleElementsForLenses() /* uncrumble neighbour fields, if needed */ if (element == EL_INVISIBLE_SAND) - TEST_DrawLevelFieldCrumbledSandNeighbours(x, y); + TEST_DrawLevelFieldCrumbledNeighbours(x, y); } else if (element == EL_INVISIBLE_STEELWALL_ACTIVE || element == EL_INVISIBLE_WALL_ACTIVE || @@ -6684,7 +6684,7 @@ static void RedrawAllInvisibleElementsForLenses() /* re-crumble neighbour fields, if needed */ if (element == EL_INVISIBLE_SAND) - TEST_DrawLevelFieldCrumbledSandNeighbours(x, y); + TEST_DrawLevelFieldCrumbledNeighbours(x, y); } } } @@ -8501,7 +8501,7 @@ void StartMoving(int x, int y) if (IN_SCR_FIELD(sx, sy)) { - TEST_DrawLevelFieldCrumbledSand(xx, yy); + TEST_DrawLevelFieldCrumbled(xx, yy); DrawGraphic(sx, sy, flame_graphic, frame); } } @@ -9004,7 +9004,7 @@ void ContinueMoving(int x, int y) { Feld[x][y] = EL_SAND; - TEST_DrawLevelFieldCrumbledSandNeighbours(x, y); + TEST_DrawLevelFieldCrumbledNeighbours(x, y); } else if (element == EL_QUICKSAND_FILLING) { @@ -9171,7 +9171,7 @@ void ContinueMoving(int x, int y) InitField(x, y, FALSE); if (GFX_CRUMBLED(Feld[x][y])) - TEST_DrawLevelFieldCrumbledSandNeighbours(x, y); + TEST_DrawLevelFieldCrumbledNeighbours(x, y); if (ELEM_IS_PLAYER(move_leave_element)) RelocatePlayer(x, y, move_leave_element); @@ -10365,7 +10365,7 @@ static void ChangeActiveTrap(int x, int y) /* if new animation frame was drawn, correct crumbled sand border */ if (IS_NEW_FRAME(GfxFrame[x][y], graphic)) - TEST_DrawLevelFieldCrumbledSand(x, y); + TEST_DrawLevelFieldCrumbled(x, y); } static int getSpecialActionElement(int element, int number, int base_element) @@ -11101,7 +11101,7 @@ static void CreateFieldExt(int x, int y, int element, boolean is_change) TEST_DrawLevelField(x, y); if (GFX_CRUMBLED(new_element)) - TEST_DrawLevelFieldCrumbledSandNeighbours(x, y); + TEST_DrawLevelFieldCrumbledNeighbours(x, y); } #if 1 @@ -13170,10 +13170,10 @@ void GameActions_RND() DrawLevelField(x, y); if (GfxRedraw[x][y] & GFX_REDRAW_TILE_CRUMBLED) - DrawLevelFieldCrumbledSand(x, y); + DrawLevelFieldCrumbled(x, y); if (GfxRedraw[x][y] & GFX_REDRAW_TILE_CRUMBLED_NEIGHBOURS) - DrawLevelFieldCrumbledSandNeighbours(x, y); + DrawLevelFieldCrumbledNeighbours(x, y); if (GfxRedraw[x][y] & GFX_REDRAW_TILE_TWINKLED) DrawTwinkleOnField(x, y); diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 35b9c5ab..1535b69c 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1980,8 +1980,8 @@ int get_parameter_value(char *value_raw, char *suffix, int type) if (string_has_parameter(value, "accurate_borders")) result |= STYLE_ACCURATE_BORDERS; - if (string_has_parameter(value, "with_inner_corners")) - result |= STYLE_WITH_INNER_CORNERS; + if (string_has_parameter(value, "inner_corners")) + result |= STYLE_INNER_CORNERS; } else if (strEqual(suffix, ".fade_mode")) { diff --git a/src/libgame/system.h b/src/libgame/system.h index ea4dbd17..75668281 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -209,8 +209,8 @@ /* values for special drawing styles (currently only for crumbled graphics) */ #define STYLE_NONE 0 -#define STYLE_ACCURATE_BORDERS (1 << 0) -#define STYLE_WITH_INNER_CORNERS (1 << 1) +#define STYLE_ACCURATE_BORDERS (1 << 0) +#define STYLE_INNER_CORNERS (1 << 1) #define STYLE_DEFAULT STYLE_NONE diff --git a/src/tools.c b/src/tools.c index 5bf1328e..970dfb6d 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1442,8 +1442,8 @@ void DrawLevelFieldThruMask(int x, int y) (e) == EL_QUICKSAND_EMPTYING || \ (e) == EL_QUICKSAND_FAST_EMPTYING)) -static void DrawLevelFieldCrumbledSandExtBlitInner(int x, int y, int dx, int dy, - int graphic) +static void DrawLevelFieldCrumbledInnerCorners(int x, int y, int dx, int dy, + int graphic) { Bitmap *src_bitmap; int src_x, src_y; @@ -1486,8 +1486,8 @@ static void DrawLevelFieldCrumbledSandExtBlitInner(int x, int y, int dx, int dy, width, height, FX + sx * TILEX + cx, FY + sy * TILEY + cy); } -static void DrawLevelFieldCrumbledSandExtBlit(int x, int y, - int graphic, int frame, int dir) +static void DrawLevelFieldCrumbledBorders(int x, int y, int graphic, int frame, + int dir) { Bitmap *src_bitmap; int src_x, src_y; @@ -1500,7 +1500,7 @@ static void DrawLevelFieldCrumbledSandExtBlit(int x, int y, /* draw simple, sloppy, non-corner-accurate crumbled border */ -#if 0 +#if 1 width = (dir == 1 || dir == 2 ? crumbled_border_size : TILEX); height = (dir == 0 || dir == 3 ? crumbled_border_size : TILEY); cx = (dir == 2 ? TILEX - crumbled_border_size : 0); @@ -1532,7 +1532,7 @@ static void DrawLevelFieldCrumbledSandExtBlit(int x, int y, /* correct corners of crumbled border, if needed */ -#if 0 +#if 1 for (i = -1; i <= 1; i+=2) { int xx = x + (dir == 0 || dir == 3 ? i : 0); @@ -1540,8 +1540,6 @@ static void DrawLevelFieldCrumbledSandExtBlit(int x, int y, int element = (IN_LEV_FIELD(xx, yy) ? TILE_GFX_ELEMENT(xx, yy) : BorderElement); - /* ... */ - /* check if neighbour field is of same crumble type */ if (IS_CRUMBLED_TILE(xx, yy, element) && graphic_info[graphic].class == @@ -1549,13 +1547,28 @@ static void DrawLevelFieldCrumbledSandExtBlit(int x, int y, { /* no crumbled corner, but continued crumbled border */ + int c1 = (dir == 2 || dir == 3 ? TILESIZE - crumbled_border_size : 0); + int c2 = (i == 1 ? TILESIZE - crumbled_border_size : 0); + int b1 = (i == 1 ? crumbled_border_size : + TILESIZE - 2 * crumbled_border_size); + width = crumbled_border_size; height = crumbled_border_size; - cx = (dir == 2 ? TILEX - crumbled_border_size : 0); - cy = (i == 1 ? TILEX - crumbled_border_size : 0); - bx = cx; - by = (i == 1 ? crumbled_border_size : - TILEY - 2 * crumbled_border_size); + + if (dir == 1 || dir == 2) + { + cx = c1; + cy = c2; + bx = cx; + by = b1; + } + else + { + cx = c2; + cy = c1; + bx = b1; + by = cy; + } BlitBitmap(src_bitmap, drawto_field, src_x + bx, src_y + by, width, height, FX + sx * TILEX + cx, FY + sy * TILEY + cy); @@ -1581,7 +1594,7 @@ static void DrawLevelFieldCrumbledSandExtBlit(int x, int y, width = crumbled_border_size; height = crumbled_border_size; cx = (dir == 2 ? TILEX - crumbled_border_size : 0); - cy = (i == 1 ? TILEX - crumbled_border_size : 0); + cy = (i == 1 ? TILEY - crumbled_border_size : 0); bx = cx; by = (i == 1 ? crumbled_border_size : TILEY - 2 * crumbled_border_size); @@ -1612,7 +1625,7 @@ static void DrawLevelFieldCrumbledSandExtBlit(int x, int y, cx = (i == 1 ? TILEX - crumbled_border_size : 0); cy = (dir == 3 ? TILEY - crumbled_border_size : 0); bx = (i == 1 ? crumbled_border_size : - TILEY - 2 * crumbled_border_size); + TILEX - 2 * crumbled_border_size); by = cy; BlitBitmap(src_bitmap, drawto_field, src_x + bx, src_y + by, @@ -1623,7 +1636,7 @@ static void DrawLevelFieldCrumbledSandExtBlit(int x, int y, #endif } -static void DrawLevelFieldCrumbledSandExt(int x, int y, int graphic, int frame) +static void DrawLevelFieldCrumbledExt(int x, int y, int graphic, int frame) { int sx = SCREENX(x), sy = SCREENY(y); int element; @@ -1666,10 +1679,10 @@ static void DrawLevelFieldCrumbledSandExt(int x, int y, int graphic, int frame) continue; #endif - DrawLevelFieldCrumbledSandExtBlit(x, y, graphic, frame, i); + DrawLevelFieldCrumbledBorders(x, y, graphic, frame, i); } - if ((graphic_info[graphic].style & STYLE_WITH_INNER_CORNERS) && + if ((graphic_info[graphic].style & STYLE_INNER_CORNERS) && graphic_info[graphic].anim_frames == 2) { for (i = 0; i < 4; i++) @@ -1677,7 +1690,7 @@ static void DrawLevelFieldCrumbledSandExt(int x, int y, int graphic, int frame) int dx = (i & 1 ? +1 : -1); int dy = (i & 2 ? +1 : -1); - DrawLevelFieldCrumbledSandExtBlitInner(x, y, dx, dy, graphic); + DrawLevelFieldCrumbledInnerCorners(x, y, dx, dy, graphic); } } @@ -1706,14 +1719,14 @@ static void DrawLevelFieldCrumbledSandExt(int x, int y, int graphic, int frame) graphic = el_act2crm(element, ACTION_DEFAULT); - DrawLevelFieldCrumbledSandExtBlit(xx, yy, graphic, 0, 3 - i); + DrawLevelFieldCrumbledBorders(xx, yy, graphic, 0, 3 - i); MarkTileDirty(sxx, syy); } } } -void DrawLevelFieldCrumbledSand(int x, int y) +void DrawLevelFieldCrumbled(int x, int y) { int graphic; @@ -1732,7 +1745,7 @@ void DrawLevelFieldCrumbledSand(int x, int y) GfxElement[x][y] != EL_UNDEFINED && GFX_CRUMBLED(GfxElement[x][y])) { - DrawLevelFieldCrumbledSandDigging(x, y, GfxDir[x][y], GfxFrame[x][y]); + DrawLevelFieldCrumbledDigging(x, y, GfxDir[x][y], GfxFrame[x][y]); return; } @@ -1744,11 +1757,11 @@ void DrawLevelFieldCrumbledSand(int x, int y) graphic = el_act2crm(Feld[x][y], ACTION_DEFAULT); #endif - DrawLevelFieldCrumbledSandExt(x, y, graphic, 0); + DrawLevelFieldCrumbledExt(x, y, graphic, 0); } -void DrawLevelFieldCrumbledSandDigging(int x, int y, int direction, - int step_frame) +void DrawLevelFieldCrumbledDigging(int x, int y, int direction, + int step_frame) { int graphic1 = el_act_dir2img(GfxElement[x][y], ACTION_DIGGING, direction); int graphic2 = el_act_dir2crm(GfxElement[x][y], ACTION_DIGGING, direction); @@ -1757,10 +1770,10 @@ void DrawLevelFieldCrumbledSandDigging(int x, int y, int direction, int sx = SCREENX(x), sy = SCREENY(y); DrawGraphic(sx, sy, graphic1, frame1); - DrawLevelFieldCrumbledSandExt(x, y, graphic2, frame2); + DrawLevelFieldCrumbledExt(x, y, graphic2, frame2); } -void DrawLevelFieldCrumbledSandNeighbours(int x, int y) +void DrawLevelFieldCrumbledNeighbours(int x, int y) { int sx = SCREENX(x), sy = SCREENY(y); static int xy[4][2] = @@ -1772,55 +1785,6 @@ void DrawLevelFieldCrumbledSandNeighbours(int x, int y) }; int i; -#if 0 - int element = TILE_GFX_ELEMENT(x, y); - int graphic = el_act2crm(element, ACTION_DEFAULT); - - if (graphic_info[graphic].style & STYLE_WITH_INNER_CORNERS) - { - int dx, dy; - - for (dy = -1; dy < 2; dy++) - { - for (dx = -1; dx < 2; dx++) - { - if (dx != 0 || dy != 0) - { - int xx = x + dx; - int yy = y + dy; - int sxx = sx + dx; - int syy = sy + dy; - - if (!IN_LEV_FIELD(xx, yy) || - !IN_SCR_FIELD(sxx, syy) || - !GFX_CRUMBLED(Feld[xx][yy]) || - IS_MOVING(xx, yy)) - continue; - - DrawLevelField(xx, yy); - } - } - } - } - else - { - for (i = 0; i < 4; i++) - { - int xx = x + xy[i][0]; - int yy = y + xy[i][1]; - int sxx = sx + xy[i][0]; - int syy = sy + xy[i][1]; - - if (!IN_LEV_FIELD(xx, yy) || - !IN_SCR_FIELD(sxx, syy) || - !GFX_CRUMBLED(Feld[xx][yy]) || - IS_MOVING(xx, yy)) - continue; - - DrawLevelField(xx, yy); - } - } -#else for (i = 0; i < 4; i++) { int xx = x + xy[i][0]; @@ -1836,7 +1800,6 @@ void DrawLevelFieldCrumbledSandNeighbours(int x, int y) DrawLevelField(xx, yy); } -#endif } static int getBorderElement(int x, int y) @@ -1865,7 +1828,7 @@ static int getBorderElement(int x, int y) void DrawScreenElement(int x, int y, int element) { DrawScreenElementExt(x, y, 0, 0, element, NO_CUTTING, NO_MASKING); - DrawLevelFieldCrumbledSand(LEVELX(x), LEVELY(y)); + DrawLevelFieldCrumbled(LEVELX(x), LEVELY(y)); } void DrawLevelElement(int x, int y, int element) @@ -2599,10 +2562,10 @@ inline void DrawLevelGraphicAnimationIfNeeded(int x, int y, int graphic) #if 1 if (GFX_CRUMBLED(TILE_GFX_ELEMENT(x, y))) - DrawLevelFieldCrumbledSand(x, y); + DrawLevelFieldCrumbled(x, y); #else if (GFX_CRUMBLED(Feld[x][y])) - DrawLevelFieldCrumbledSand(x, y); + DrawLevelFieldCrumbled(x, y); #endif } @@ -2622,7 +2585,7 @@ void DrawLevelElementAnimationIfNeeded(int x, int y, int element) DrawGraphicAnimation(sx, sy, graphic); if (GFX_CRUMBLED(element)) - DrawLevelFieldCrumbledSand(x, y); + DrawLevelFieldCrumbled(x, y); } static int getPlayerGraphic(struct PlayerInfo *player, int move_dir) @@ -2794,7 +2757,7 @@ void DrawPlayer(struct PlayerInfo *player) int frame = getGraphicAnimationFrame(old_graphic, player->StepFrame); if (GFX_CRUMBLED(old_element)) - DrawLevelFieldCrumbledSandDigging(jx, jy, move_dir, player->StepFrame); + DrawLevelFieldCrumbledDigging(jx, jy, move_dir, player->StepFrame); else DrawGraphic(sx, sy, old_graphic, frame); diff --git a/src/tools.h b/src/tools.h index e16b4eae..dccbe10b 100644 --- a/src/tools.h +++ b/src/tools.h @@ -135,9 +135,9 @@ void DrawLevelElementShifted(int, int, int, int, int, int); void DrawScreenElementThruMask(int, int, int); void DrawLevelElementThruMask(int, int, int); void DrawLevelFieldThruMask(int, int); -void DrawLevelFieldCrumbledSand(int, int); -void DrawLevelFieldCrumbledSandDigging(int, int, int, int); -void DrawLevelFieldCrumbledSandNeighbours(int, int); +void DrawLevelFieldCrumbled(int, int); +void DrawLevelFieldCrumbledDigging(int, int, int, int); +void DrawLevelFieldCrumbledNeighbours(int, int); void DrawScreenElement(int, int, int); void DrawLevelElement(int, int, int); void DrawScreenField(int, int);