From e7ae2ca4129230d48f74a07162e6902214584bcf Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 23 Sep 2024 20:12:19 +0200 Subject: [PATCH] fixed code for drawing diagonal player movement in BD engine When drawing diagonal player movement, do not use smooth movement for the player, and do not draw the source tile (but only draw the target tile, as the player "jump-moves" to the next tile in this case). So far, the source tile was not drawn at all due to not correctly detecting diagonal movement, causing smooth movement being disabled for this tile, so the player was not drawn at the source tile anyway (which causes another bug yet to be fixed: not drawing tiles entering the tile left by the player at the same time using smooth movement). This change fixes (not) drawing the source tile for diagonal player movement. --- src/game_bd/bd_graphics.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/game_bd/bd_graphics.c b/src/game_bd/bd_graphics.c index f6548a12..4c7c5cd6 100644 --- a/src/game_bd/bd_graphics.c +++ b/src/game_bd/bd_graphics.c @@ -670,9 +670,12 @@ static void gd_drawcave_tile(Bitmap *dest, GdGame *game, int x, int y, boolean d int tile_to = tile; // target element if element is moving int draw_to = draw; // target element if element is moving int frame = game->animcycle; + int dx_from = gd_dx[dir_from]; + int dy_from = gd_dy[dir_from]; boolean is_moving_from = (dir_from != GD_MV_STILL); boolean is_moving_to = (dir_to != GD_MV_STILL); boolean is_moving = (is_moving_from || is_moving_to); + boolean is_diagonal_movement = (dx_from != 0 && dy_from != 0); boolean use_smooth_movements = use_bd_smooth_movements(); // if element is moving away from this tile, determine element that is moving @@ -803,18 +806,16 @@ static void gd_drawcave_tile(Bitmap *dest, GdGame *game, int x, int y, boolean d // ---------- 2nd step: draw element that is moving away from this tile ---------- - if (is_moving_from) + if (is_moving_from && !is_diagonal_movement) { struct GraphicInfo_BD *g = &graphic_info_bd_object[draw_from][frame]; Bitmap *tile_bitmap = gd_get_tile_bitmap(g->bitmap); - int dx = (dir_from == GD_MV_LEFT ? -1 : dir_from == GD_MV_RIGHT ? +1 : 0); - int dy = (dir_from == GD_MV_UP ? -1 : dir_from == GD_MV_DOWN ? +1 : 0); - int xsize = (dx != 0 ? shift : cell_size); - int ysize = (dy != 0 ? shift : cell_size); - int gx = g->src_x + (dx < 0 ? cell_size - shift : 0); - int gy = g->src_y + (dy < 0 ? cell_size - shift : 0); - int tx = sx + (dx < 0 ? 0 : dx > 0 ? cell_size - shift : 0); - int ty = sy + (dy < 0 ? 0 : dy > 0 ? cell_size - shift : 0); + int xsize = (dx_from != 0 ? shift : cell_size); + int ysize = (dy_from != 0 ? shift : cell_size); + int gx = g->src_x + (dx_from < 0 ? cell_size - shift : 0); + int gy = g->src_y + (dy_from < 0 ? cell_size - shift : 0); + int tx = sx + (dx_from < 0 ? 0 : dx_from > 0 ? cell_size - shift : 0); + int ty = sy + (dy_from < 0 ? 0 : dy_from > 0 ? cell_size - shift : 0); if (!el_diggable(tile)) blit_bitmap = BlitBitmapMasked; -- 2.34.1