From: Holger Schemel Date: Thu, 17 Dec 2009 23:41:05 +0000 (+0100) Subject: rnd-20091218-1-src X-Git-Tag: 3.3.0.0^2~52 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=c14ddc8b933f45b1fb02e0fe5a7637655b88f90a;p=rocksndiamonds.git rnd-20091218-1-src * fixed EMC style pushing animations in the R'n'D graphics engine (when using ".2nd_movement_tile" for animations having start and end tile) * for this to work (look) properly for two-tile pushing animations with non-black (i.e. opaque) background, the pushing graphics drawing order was changed to first draw the pushed element, then the player (maybe this should be controlled by an ".anim_mode" flag yet to be added) * added searching for template level (file "template.level") not only inside the level set directory, but also in above level directories; this makes is possible to use the same single template level file (placed in a level group directory) for many level sub-directories --- diff --git a/ChangeLog b/ChangeLog index 467d8ca2..7e4cc1e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2009-12-17 + * fixed EMC style pushing animations in the R'n'D graphics engine (when + using ".2nd_movement_tile" for animations having start and end tile) + * for this to work (look) properly for two-tile pushing animations with + non-black (i.e. opaque) background, the pushing graphics drawing order + was changed to first draw the pushed element, then the player (maybe + this should be controlled by an ".anim_mode" flag yet to be added) + +2009-12-16 + * added searching for template level (file "template.level") not only + inside the level set directory, but also in above level directories; + this makes is possible to use the same single template level file + (placed in a level group directory) for many level sub-directories + 2009-12-10 * fixed bug with steel exit being destructible during opening phase * added token "special_flags" to "levelinfo.conf" (currently with the diff --git a/src/conftime.h b/src/conftime.h index 90e1e427..7e97ba26 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2009-12-16 10:52" +#define COMPILE_DATE_STRING "2009-12-18 00:11" diff --git a/src/tools.c b/src/tools.c index 0650532c..1e58363c 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1243,13 +1243,27 @@ inline static void DrawGraphicShiftedDouble(int x, int y, int dx, int dy, int x2 = x + SIGN(dx); int y2 = y + SIGN(dy); int anim_frames = graphic_info[graphic].anim_frames; + /* !!! THIS ONLY REALLY WORKS WITH anim_frames == 7 (MOVEMENT FRAMES) !!! */ + /* !!! (ELSE sync_frame DOES NOT START WITH 0 AND MOVEMENT LOOK WRONG !!! */ + /* !!! (AND anim_frames == 15 FOR SLOW MOVEMENT AND SO ON) !!! */ +#if 1 + /* (we also need anim_delay here for movement animations with less frames) */ + int anim_delay = graphic_info[graphic].anim_delay; + int anim_pos = (dx ? ABS(dx) : ABS(dy)); + int sync_frame = anim_pos * anim_frames * anim_delay / TILESIZE; +#else int sync_frame = (dx ? ABS(dx) : ABS(dy)) * anim_frames / TILESIZE; +#endif boolean draw_start_tile = (cut_mode != CUT_ABOVE); /* only for falling! */ boolean draw_end_tile = (cut_mode != CUT_BELOW); /* only for falling! */ /* re-calculate animation frame for two-tile movement animation */ frame = getGraphicAnimationFrame(graphic, sync_frame); +#if 0 + printf("::: %d [%d, %d]\n", frame, sync_frame, dy); +#endif + /* check if movement start graphic inside screen area and should be drawn */ if (draw_start_tile && IN_SCR_FIELD(x1, y1)) { @@ -2461,6 +2475,8 @@ void DrawPlayerField(int x, int y) DrawPlayer(PLAYERINFO(x, y)); } +#define TEST_DRAW_PLAYER_OVER_PUSHED_ELEMENT 1 + void DrawPlayer(struct PlayerInfo *player) { int jx = player->jx; @@ -2600,6 +2616,7 @@ void DrawPlayer(struct PlayerInfo *player) } } +#if !TEST_DRAW_PLAYER_OVER_PUSHED_ELEMENT /* ----------------------------------------------------------------------- */ /* draw player himself */ /* ----------------------------------------------------------------------- */ @@ -2637,6 +2654,17 @@ void DrawPlayer(struct PlayerInfo *player) DrawGraphicShiftedThruMask(sx, sy, sxx, syy, graphic, frame, NO_CUTTING); } +#endif + +#if TEST_DRAW_PLAYER_OVER_PUSHED_ELEMENT + if (player->GfxPos) + { + if (move_dir == MV_LEFT || move_dir == MV_RIGHT) + sxx = player->GfxPos; + else + syy = player->GfxPos; + } +#endif /* ----------------------------------------------------------------------- */ /* draw things the player is pushing, if needed */ @@ -2679,8 +2707,63 @@ void DrawPlayer(struct PlayerInfo *player) if (Back[next_jx][next_jy]) DrawLevelElement(next_jx, next_jy, Back[next_jx][next_jy]); +#if 0 + printf("::: %d, %d, %d [%d] [%d, %d, %d] [%d] [%d, %d]\n", + jx, px, player->GfxPos, player->is_pushing, dx, sxx, pxx, + IS_MOVING(jx, jy), graphic, frame); +#endif + +#if 1 + /* do not draw (EM style) pushing animation when pushing is finished */ + if (graphic_info[graphic].double_movement && !IS_MOVING(jx, jy)) + DrawLevelElement(next_jx, next_jy, Feld[next_jx][next_jy]); + else + DrawGraphicShiftedThruMask(px, py, pxx, pyy, graphic, frame, NO_CUTTING); +#else /* masked drawing is needed for EMC style (double) movement graphics */ + /* !!! (ONLY WHEN DRAWING PUSHED ELEMENT OVER THE PLAYER) !!! */ DrawGraphicShiftedThruMask(px, py, pxx, pyy, graphic, frame, NO_CUTTING); +#endif + } +#endif + +#if TEST_DRAW_PLAYER_OVER_PUSHED_ELEMENT + /* ----------------------------------------------------------------------- */ + /* draw player himself */ + /* ----------------------------------------------------------------------- */ + + graphic = getPlayerGraphic(player, move_dir); + + /* in the case of changed player action or direction, prevent the current + animation frame from being restarted for identical animations */ + if (player->Frame == 0 && equalGraphics(graphic, last_player_graphic)) + player->Frame = last_player_frame; + + frame = getGraphicAnimationFrame(graphic, player->Frame); + + if (player->GfxPos) + { + if (move_dir == MV_LEFT || move_dir == MV_RIGHT) + sxx = player->GfxPos; + else + syy = player->GfxPos; + } + + if (!setup.soft_scrolling && ScreenMovPos) + sxx = syy = 0; + + if (player_is_opaque) + DrawGraphicShifted(sx, sy, sxx, syy, graphic, frame,NO_CUTTING,NO_MASKING); + else + DrawGraphicShiftedThruMask(sx, sy, sxx, syy, graphic, frame, NO_CUTTING); + + if (SHIELD_ON(player)) + { + int graphic = (player->shield_deadly_time_left ? IMG_SHIELD_DEADLY_ACTIVE : + IMG_SHIELD_NORMAL_ACTIVE); + int frame = getGraphicAnimationFrame(graphic, -1); + + DrawGraphicShiftedThruMask(sx, sy, sxx, syy, graphic, frame, NO_CUTTING); } #endif