/* forward declaration for internal use */
static void UnmapToolButtons();
static void HandleToolButtons(struct GadgetInfo *);
+static int el_act_dir2crm(int, int, int);
static struct GadgetInfo *tool_gadget[NUM_TOOL_BUTTONS];
static int request_gadget_id = -1;
return;
DrawGraphicAnimation(sx, sy, graphic);
+
+ if (CAN_BE_CRUMBLED(Feld[x][y]))
+ DrawLevelFieldCrumbledSand(x, y);
}
void DrawLevelElementAnimationIfNeeded(int x, int y, int element)
return;
DrawGraphicAnimation(sx, sy, graphic);
+
+ if (CAN_BE_CRUMBLED(element))
+ DrawLevelFieldCrumbledSand(x, y);
}
void DrawAllPlayers()
void DrawPlayer(struct PlayerInfo *player)
{
+#if 0
int jx = player->jx, jy = player->jy;
int last_jx = player->last_jx, last_jy = player->last_jy;
int next_jx = jx + (jx - last_jx), next_jy = jy + (jy - last_jy);
boolean player_is_moving = (last_jx != jx || last_jy != jy ? TRUE : FALSE);
int move_dir = player->MovDir;
int action = ACTION_DEFAULT;
+#else
+ int jx = player->jx, jy = player->jy;
+ int move_dir = player->MovDir;
+ int dx = (move_dir == MV_LEFT ? -1 : move_dir == MV_RIGHT ? +1 : 0);
+ int dy = (move_dir == MV_UP ? -1 : move_dir == MV_DOWN ? +1 : 0);
+ int last_jx = (player->is_moving ? jx - dx : jx);
+ int last_jy = (player->is_moving ? jy - dy : jy);
+ int next_jx = jx + dx;
+ int next_jy = jy + dy;
+ int sx = SCREENX(jx), sy = SCREENY(jy);
+ int sxx = 0, syy = 0;
+ int element = Feld[jx][jy], last_element = Feld[last_jx][last_jy];
+ int graphic;
+ int frame = 0;
+ boolean player_is_moving = (player->MovPos ? TRUE : FALSE);
+ int action = ACTION_DEFAULT;
+#endif
if (!player->active || !IN_SCR_FIELD(SCREENX(last_jx), SCREENY(last_jy)))
return;
player->is_moving ? ACTION_MOVING :
player->snapped ? ACTION_SNAPPING : ACTION_DEFAULT);
+#if 0
+ printf("::: '%s'\n", element_action_info[action].suffix);
+#endif
+
InitPlayerGfxAnimation(player, action, move_dir);
/* ----------------------------------------------------------------------- */
/* draw things in the field the player is leaving, if needed */
/* ----------------------------------------------------------------------- */
+#if 1
+ if (player->is_moving)
+#else
if (player_is_moving)
+#endif
{
if (Back[last_jx][last_jy] && IS_DRAWABLE(last_element))
{
if (player->Pushing && IN_SCR_FIELD(SCREENX(next_jx), SCREENY(next_jy)))
{
+#if 1
#if 1
DrawLevelElement(next_jx, next_jy, EL_EMPTY);
#else
}
else
DrawLevelField(next_jx, next_jy);
+#endif
#endif
}
}
{
if (player_is_moving && GfxElement[jx][jy] != EL_UNDEFINED)
{
+#if 1
+ if (CAN_BE_CRUMBLED(GfxElement[jx][jy]))
+ DrawLevelFieldCrumbledSandDigging(jx, jy, move_dir, player->StepFrame);
+#else
if (GfxElement[jx][jy] == EL_SAND)
DrawLevelFieldCrumbledSandDigging(jx, jy, move_dir, player->StepFrame);
+#endif
else
{
int old_element = GfxElement[jx][jy];
/* draw things the player is pushing, if needed */
/* ----------------------------------------------------------------------- */
+#if 0
+ printf("::: %d, %d [%d, %d] [%d]\n",
+ player->Pushing, player_is_moving, player->GfxAction,
+ player->is_moving, player_is_moving);
+#endif
+
+#if 1
+ if (player->Pushing && player->is_moving)
+#else
if (player->Pushing && player_is_moving)
+#endif
{
int px = SCREENX(next_jx), py = SCREENY(next_jy);
#endif
else
{
+#if 1
+ int element = MovingOrBlocked2Element(next_jx, next_jy);
+#else
#if 1
int element = Feld[jx][jy];
#else
int element = Feld[next_jx][next_jy];
#endif
+#endif
+#if 1
int graphic = el2img(element);
int frame = 0;
+#if 0
if ((sxx || syy) && IS_PUSHABLE(element))
+#endif
{
- graphic = el_act_dir2img(element, ACTION_MOVING, move_dir);
+ graphic = el_act_dir2img(element, ACTION_PUSHING, move_dir);
frame = getGraphicAnimationFrame(graphic, player->Frame);
}
+#if 0
+ printf("::: pushing %d: %d ...\n", sxx, frame);
+#endif
+
DrawGraphicShifted(px, py, sxx, syy, graphic, frame,
NO_CUTTING, NO_MASKING);
+#endif
}
}
if (!IN_LEV_FIELD(x, y))
return;
- element = (GfxElement[x][y] != EL_UNDEFINED ? GfxElement[x][y] : Feld[x][y]);
+ element = (GfxElement[x][y] != EL_UNDEFINED && Feld[x][y] != EL_EXPLOSION ?
+ GfxElement[x][y] : Feld[x][y]);
/* crumble field itself */
if (CAN_BE_CRUMBLED(element) && !IS_MOVING(x, y))
if (CAN_BE_CRUMBLED(element) && !IS_MOVING(xx, yy))
continue;
+#if 0
+ if (Feld[x][y] == EL_CUSTOM_START + 123)
+ printf("::: crumble [%d] THE CHAOS ENGINE (%d, %d): %d, %d\n",
+ i, Feld[x][y], element,
+ CAN_BE_CRUMBLED(element), IS_MOVING(x, y));
+#endif
+
if (i == 1 || i == 2)
{
width = snip;
void DrawLevelFieldCrumbledSandDigging(int x, int y, int direction,
int step_frame)
{
+#if 1
+ int graphic1 = el_act_dir2img(GfxElement[x][y], ACTION_DIGGING, direction);
+ int graphic2 = el_act_dir2crm(GfxElement[x][y], ACTION_DIGGING, direction);
+#else
int graphic1 = el_act_dir2img(EL_SAND, ACTION_DIGGING, direction);
int graphic2 = el_act_dir2img(EL_SAND_CRUMBLED, ACTION_DIGGING, direction);
+#endif
int frame1 = getGraphicAnimationFrame(graphic1, step_frame);
int frame2 = getGraphicAnimationFrame(graphic2, step_frame);
int sx = SCREENX(x), sy = SCREENY(y);
{ EL_STEELWALL, EL_INVISIBLE_STEELWALL }
};
int steel_type = (BorderElement == EL_STEELWALL ? 0 : 1);
- int steel_position = (x == -1 && y == -1 ? 0 :
- x == lev_fieldx && y == -1 ? 1 :
- x == -1 && y == lev_fieldy ? 2 :
- x == lev_fieldx && y == lev_fieldy ? 3 :
- x == -1 || x == lev_fieldx ? 4 :
- y == -1 || y == lev_fieldy ? 5 : 6);
+ int steel_position = (x == -1 && y == -1 ? 0 :
+ x == lev_fieldx && y == -1 ? 1 :
+ x == -1 && y == lev_fieldy ? 2 :
+ x == lev_fieldx && y == lev_fieldy ? 3 :
+ x == -1 || x == lev_fieldx ? 4 :
+ y == -1 || y == lev_fieldy ? 5 : 6);
return border[steel_position][steel_type];
}
DrawMiniGraphic(sx, sy, el2edimg(getBorderElement(x, y)));
}
+void DrawEnvelopeBorder(int sx, int sy, int ex, int ey)
+{
+ int border[8][2] =
+ {
+ { EL_STEELWALL_TOPLEFT, EL_INVISIBLE_STEELWALL_TOPLEFT },
+ { EL_STEELWALL_TOPRIGHT, EL_INVISIBLE_STEELWALL_TOPRIGHT },
+ { EL_STEELWALL_BOTTOMLEFT, EL_INVISIBLE_STEELWALL_BOTTOMLEFT },
+ { EL_STEELWALL_BOTTOMRIGHT, EL_INVISIBLE_STEELWALL_BOTTOMRIGHT },
+ { EL_STEELWALL_VERTICAL, EL_INVISIBLE_STEELWALL_VERTICAL },
+ { EL_STEELWALL_HORIZONTAL, EL_INVISIBLE_STEELWALL_HORIZONTAL },
+ { EL_STEELWALL, EL_INVISIBLE_STEELWALL },
+ { EL_EMPTY, EL_EMPTY }
+ };
+ int steel_type = (BorderElement == EL_STEELWALL ? 0 : 1);
+ int steel_position = (ex == -1 && ey == -1 ? 0 :
+ ex == +1 && ey == -1 ? 1 :
+ ex == -1 && ey == +1 ? 2 :
+ ex == +1 && ey == +1 ? 3 :
+ ex == -1 || ex == +1 ? 4 :
+ ey == -1 || ey == +1 ? 5 : 7);
+ int element = border[steel_position][steel_type];
+
+ DrawMiniGraphic(sx, sy, el2edimg(element));
+}
+
void getMicroGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y)
{
Bitmap *src_bitmap = graphic_info[graphic].bitmap;
if (strlen(label_text) > 0)
{
- int text_width = strlen(label_text) * getFontWidth(font_nr);
- int lxpos = SX + (SXSIZE - text_width) / 2;
+ int lxpos = SX + (SXSIZE - getTextWidth(label_text, font_nr)) / 2;
int lypos = MICROLABEL_YPOS;
DrawText(lxpos, lypos, label_text, font_nr);
if (leveldir_current->name)
{
- int len = strlen(leveldir_current->name);
- int lxpos = SX + (SXSIZE - len * getFontWidth(FONT_TEXT_1)) / 2;
+ int text_width = getTextWidth(leveldir_current->name, FONT_TEXT_1);
+ int lxpos = SX + (SXSIZE - text_width) / 2;
int lypos = SY + 352;
DrawText(lxpos, lypos, leveldir_current->name, FONT_TEXT_1);
unsigned int old_door_state;
int last_game_status = game_status; /* save current game status */
+#if 1
+ SetMouseCursor(CURSOR_DEFAULT);
+#endif
+
#if defined(PLATFORM_UNIX)
/* pause network game while waiting for request to answer */
if (options.network &&
SetDrawBackgroundMask(REDRAW_FIELD | REDRAW_DOOR_1);
+#if 0
+ SetMouseCursor(CURSOR_DEFAULT);
+#endif
+
while(result < 0)
{
if (PendingEvent())
return element_info[element].direction_graphic[action][direction];
}
+static int el_act_dir2crm(int element, int action, int direction)
+{
+ element = GFX_ELEMENT(element);
+ direction = MV_DIR_BIT(direction);
+
+ return element_info[element].direction_crumbled[action][direction];
+}
+
int el_act2img(int element, int action)
{
element = GFX_ELEMENT(element);