+ if (!IS_PLAYER(x,y))
+ return;
+
+ DrawPlayer(PLAYERINFO(x,y));
+}
+
+void DrawPlayer(struct PlayerInfo *player)
+{
+ 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);
+ int sx = SCREENX(jx), sy = SCREENY(jy);
+ int sxx = 0, syy = 0;
+ int element = Feld[jx][jy];
+ int graphic, phase;
+
+ if (!player->active || player->gone ||
+ !IN_SCR_FIELD(SCREENX(last_jx), SCREENY(last_jy)))
+ return;
+
+#if DEBUG
+ if (!IN_LEV_FIELD(jx,jy))
+ {
+ printf("DrawPlayerField(): x = %d, y = %d\n",jx,jy);
+ printf("DrawPlayerField(): sx = %d, sy = %d\n",sx,sy);
+ printf("DrawPlayerField(): This should never happen!\n");
+ return;
+ }
+#endif
+
+ if (element == EL_EXPLODING)
+ return;
+
+ /* draw things in the field the player is leaving, if needed */
+
+ if (last_jx != jx || last_jy != jy)
+ {
+ if (Store[last_jx][last_jy])
+ {
+ DrawLevelElement(last_jx, last_jy, Store[last_jx][last_jy]);
+ DrawLevelFieldThruMask(last_jx, last_jy);
+ }
+ else if (Feld[last_jx][last_jy] == EL_DYNAMIT)
+ DrawDynamite(last_jx, last_jy);
+ else
+ DrawLevelField(last_jx, last_jy);
+
+ if (player->Pushing && IN_SCR_FIELD(SCREENX(next_jx), SCREENY(next_jy)))
+ {
+ if (player->GfxPos)
+ {
+ if (Feld[next_jx][next_jy] == EL_SOKOBAN_FELD_VOLL)
+ DrawLevelElement(next_jx, next_jy, EL_SOKOBAN_FELD_LEER);
+ else
+ DrawLevelElement(next_jx, next_jy, EL_LEERRAUM);
+ }
+ else
+ DrawLevelField(next_jx, next_jy);
+ }
+ }
+
+ if (!IN_SCR_FIELD(sx, sy))
+ return;
+
+ if (setup.direct_draw)
+ SetDrawtoField(DRAW_BUFFERED);
+
+ /* draw things behind the player, if needed */
+
+ if (Store[jx][jy])
+ DrawLevelElement(jx, jy, Store[jx][jy]);
+ else if (element != EL_DYNAMIT && element != EL_DYNABOMB)
+ DrawLevelField(jx, jy);
+
+ /* draw player himself */
+
+ if (game_emulation == EMU_SUPAPLEX)
+ {
+#if 0
+ if (player->MovDir == MV_LEFT)
+ graphic =
+ (player->Pushing ? GFX_MURPHY_PUSH_LEFT : GFX_MURPHY_LEFT);
+ else if (player->MovDir == MV_RIGHT)
+ graphic =
+ (player->Pushing ? GFX_MURPHY_PUSH_RIGHT : GFX_MURPHY_RIGHT);
+ else if (player->MovDir == MV_UP)
+ graphic = GFX_MURPHY_UP;
+ else if (player->MovDir == MV_DOWN)
+ graphic = GFX_MURPHY_DOWN;
+ else /* MV_NO_MOVING */
+ graphic = GFX_SP_MURPHY;
+
+
+ /*
+ if (player->snapped)
+ graphic = GFX_SPIELER1_PUSH_LEFT;
+ else
+ graphic = GFX_SPIELER1_PUSH_RIGHT;
+ */
+#endif
+
+ static last_dir = MV_LEFT;
+
+ if (player->Pushing)
+ {
+ if (player->MovDir == MV_LEFT)
+ graphic = GFX_MURPHY_PUSH_LEFT;
+ else if (player->MovDir == MV_RIGHT)
+ graphic = GFX_MURPHY_PUSH_RIGHT;
+ else if (last_dir == MV_LEFT)
+ graphic = GFX_MURPHY_ANY_LEFT;
+ else if (last_dir == MV_RIGHT)
+ graphic = GFX_MURPHY_ANY_RIGHT;
+ else
+ graphic = GFX_SP_MURPHY;
+ }
+ else if (player->snapped)
+ {
+ if (player->MovDir == MV_LEFT)
+ graphic = GFX_MURPHY_SNAP_LEFT;
+ else if (player->MovDir == MV_RIGHT)
+ graphic = GFX_MURPHY_SNAP_RIGHT;
+ else if (player->MovDir == MV_UP)
+ graphic = GFX_MURPHY_SNAP_UP;
+ else if (player->MovDir == MV_DOWN)
+ graphic = GFX_MURPHY_SNAP_DOWN;
+ else
+ graphic = GFX_SP_MURPHY;
+ }
+ else
+ {
+ if (player->MovDir == MV_LEFT)
+ graphic = GFX_MURPHY_ANY_LEFT;
+ else if (player->MovDir == MV_RIGHT)
+ graphic = GFX_MURPHY_ANY_RIGHT;
+ else if (last_dir == MV_LEFT)
+ graphic = GFX_MURPHY_ANY_LEFT;
+ else if (last_dir == MV_RIGHT)
+ graphic = GFX_MURPHY_ANY_RIGHT;
+ else
+ graphic = GFX_SP_MURPHY;
+ }
+
+ if (player->MovDir == MV_LEFT || player->MovDir == MV_RIGHT)
+ last_dir = player->MovDir;
+
+ if (!player->Pushing && !player->snapped && player->MovDir != MV_NO_MOVING)
+ graphic -= player->Frame % 2;
+ }
+ else
+ {
+ if (player->MovDir == MV_LEFT)
+ graphic =
+ (player->Pushing ? GFX_SPIELER1_PUSH_LEFT : GFX_SPIELER1_LEFT);
+ else if (player->MovDir == MV_RIGHT)
+ graphic =
+ (player->Pushing ? GFX_SPIELER1_PUSH_RIGHT : GFX_SPIELER1_RIGHT);
+ else if (player->MovDir == MV_UP)
+ graphic = GFX_SPIELER1_UP;
+ else /* MV_DOWN || MV_NO_MOVING */
+ graphic = GFX_SPIELER1_DOWN;
+
+ graphic += player->index_nr * 3 * HEROES_PER_LINE;
+ graphic += player->Frame;
+ }
+
+ if (player->GfxPos)
+ {
+ if (player->MovDir == MV_LEFT || player->MovDir == MV_RIGHT)
+ sxx = player->GfxPos;
+ else
+ syy = player->GfxPos;
+ }
+
+ if (!setup.soft_scrolling && ScreenMovPos)
+ sxx = syy = 0;
+
+ DrawGraphicShiftedThruMask(sx, sy, sxx, syy, graphic, NO_CUTTING);
+
+ if (player->Pushing && player->GfxPos)
+ {
+ int px = SCREENX(next_jx), py = SCREENY(next_jy);
+
+ if (Feld[jx][jy] == EL_SOKOBAN_FELD_LEER ||
+ Feld[next_jx][next_jy] == EL_SOKOBAN_FELD_VOLL)
+ DrawGraphicShiftedThruMask(px, py, sxx, syy, GFX_SOKOBAN_OBJEKT,
+ NO_CUTTING);
+ else
+ {
+ int element = Feld[next_jx][next_jy];
+ int graphic = el2gfx(element);
+
+ if (element == EL_FELSBROCKEN && sxx)
+ {
+ int phase = (player->GfxPos / (TILEX/4));
+
+ if (player->MovDir == MV_LEFT)
+ graphic += phase;
+ else
+ graphic += (phase+4)%4;
+ }
+
+ DrawGraphicShifted(px, py, sxx, syy, graphic, NO_CUTTING, NO_MASKING);
+ }
+ }
+
+ /* draw things in front of player (EL_DYNAMIT || EL_DYNABOMB) */
+
+ if (element == EL_DYNAMIT || element == EL_DYNABOMB)
+ {
+ graphic = el2gfx(element);
+
+ if (element == EL_DYNAMIT)
+ {
+ if ((phase = (96 - MovDelay[jx][jy]) / 12) > 6)
+ phase = 6;
+ }
+ else
+ {
+ if ((phase = ((96 - MovDelay[jx][jy]) / 6) % 8) > 3)
+ phase = 7 - phase;
+ }
+
+ if (game_emulation == EMU_SUPAPLEX)
+ DrawGraphic(sx, sy, GFX_SP_DISK_RED);
+ else
+ DrawGraphicThruMask(sx, sy, graphic + phase);
+ }
+
+ if ((last_jx != jx || last_jy != jy) &&
+ Feld[last_jx][last_jy] == EL_EXPLODING)
+ {
+ int phase = Frame[last_jx][last_jy];
+ int delay = 2;
+
+ if (phase > 2)
+ DrawGraphicThruMask(SCREENX(last_jx), SCREENY(last_jy),
+ GFX_EXPLOSION + ((phase - 1) / delay - 1));
+ }
+
+ if (setup.direct_draw)
+ {
+ int dest_x = SX + SCREENX(MIN(jx, last_jx)) * TILEX;
+ int dest_y = SY + SCREENY(MIN(jy, last_jy)) * TILEY;
+ int x_size = TILEX * (1 + ABS(jx - last_jx));
+ int y_size = TILEY * (1 + ABS(jy - last_jy));
+
+ XCopyArea(display, drawto_field, window, gc,
+ dest_x, dest_y, x_size, y_size, dest_x, dest_y);
+ SetDrawtoField(DRAW_DIRECT);
+ }
+
+ MarkTileDirty(sx,sy);