X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_bd%2Fbd_graphics.c;h=96e9b20c2fb277d542de9386d9082ee736ee440a;hb=a3edb6437b8864290bab53bfc3bd1da9595879c1;hp=aab4330160292ff3727b75f758cd0a99efda7313;hpb=edaa850fd2d2cae7ec31961fae3d56487e710c71;p=rocksndiamonds.git diff --git a/src/game_bd/bd_graphics.c b/src/game_bd/bd_graphics.c index aab43301..96e9b20c 100644 --- a/src/game_bd/bd_graphics.c +++ b/src/game_bd/bd_graphics.c @@ -108,7 +108,7 @@ void set_play_area(int w, int h) play_area_h = h; } -void gd_init_keystate(void) +void gd_init_play_area(void) { set_play_area(SXSIZE, SYSIZE); } @@ -466,8 +466,14 @@ static Bitmap *get_tile_bitmap_c64(GdCave *cave, SDL_Surface *surface) set_surface_palette_color(surface, 7, 0); set_surface_palette_color(surface, 8, 0); + // set background color to be transparent for masked tile bitmap + int bg_color = gd_color_get_rgb(cave->color0); + int bg_r = gd_color_get_r(bg_color); + int bg_g = gd_color_get_g(bg_color); + int bg_b = gd_color_get_b(bg_color); + // create bitmap from C64 surface - tile_bitmap_c64 = SDLGetBitmapFromSurface(surface); + tile_bitmap_c64 = SDLGetBitmapFromSurface_WithMaskedColor(surface, bg_r, bg_g, bg_b); return tile_bitmap_c64; } @@ -538,11 +544,13 @@ static inline boolean el_diggable(const int element) return (gd_elements[element & O_MASK].properties & P_DIGGABLE) != 0; } +#if 0 // returns true if the element is collectible static inline boolean el_collectible(const int element) { return (gd_elements[element & O_MASK].properties & P_COLLECTIBLE) != 0; } +#endif // returns true if the element is pushable static inline boolean el_pushable(const int element) @@ -562,6 +570,12 @@ static inline boolean el_falling(const int element) return (gd_elements[element & O_MASK].properties & P_FALLING) != 0; } +// returns true if the element is growing +static inline boolean el_growing(const int element) +{ + return (gd_elements[element & O_MASK].properties & P_GROWING) != 0; +} + // returns true if the element is exploding static inline boolean el_explosion(const int element) { @@ -586,9 +600,32 @@ static void gd_drawcave_tile(Bitmap *dest, GdGame *game, int x, int y, boolean d boolean is_moving = (is_movable_or_diggable && dir != GD_MV_STILL); boolean use_smooth_movements = use_bd_smooth_movements(); - // do not use smooth movement animation for exploding game elements (like player) - if (el_explosion(tile) && dir != GD_MV_STILL) + // do not use smooth movement animation for growing or exploding game elements + if ((el_growing(tile) || el_explosion(tile)) && dir != GD_MV_STILL) + { + int dx = (dir == GD_MV_LEFT ? +1 : dir == GD_MV_RIGHT ? -1 : 0); + int dy = (dir == GD_MV_UP ? +1 : dir == GD_MV_DOWN ? -1 : 0); + int old_x = cave->getx(cave, x + dx, y + dy); + int old_y = cave->gety(cave, x + dx, y + dy); + int last_tile_from = game->last_element_buffer[old_y][old_x] & ~SKIPPED; + boolean old_is_player = el_player(last_tile_from); + + // check special case of player running into enemy from top or left side + if (old_is_player) + { + game->element_buffer[y][x] = (dir == GD_MV_LEFT ? O_PLAYER_LEFT : + dir == GD_MV_RIGHT ? O_PLAYER_RIGHT : + dir == GD_MV_UP ? O_PLAYER_UP : + dir == GD_MV_DOWN ? O_PLAYER_DOWN : O_PLAYER); + + // draw player running into explosion (else player would disappear immediately) + gd_drawcave_tile(dest, game, x, y, draw_masked); + + game->element_buffer[y][x] = tile; + } + use_smooth_movements = FALSE; + } // do not use smooth movement animation for player entering exit (engine stopped) if (cave->player_state == GD_PL_EXITED)