+void DrawPlayerField()
+{
+ int x = JX, y = JY;
+ int sx = SCROLLX(x), sy = SCROLLY(y);
+
+ int sxx = 0, syy = 0;
+
+ int element = Feld[x][y];
+ int graphic, phase;
+ BOOL draw_thru_mask = FALSE;
+
+ if (PlayerGone)
+ return;
+
+#if DEBUG
+ if (!IN_LEV_FIELD(x,y) || !IN_SCR_FIELD(sx,sy))
+ {
+ printf("DrawPlayerField(): x = %d, y = %d\n",x,y);
+ printf("DrawPlayerField(): sx = %d, sy = %d\n",sx,sy);
+ printf("DrawPlayerField(): This should never happen!\n");
+ return;
+ }
+#endif
+
+ if (element == EL_EXPLODING)
+ return;
+
+ if (direct_draw_on)
+ SetDrawtoField(DRAW_BUFFERED);
+
+ /* draw things behind the player (EL_PFORTE* || mole/penguin/pig/dragon) */
+
+
+
+
+ DrawLevelField(x,y);
+
+
+
+ if (Store[x][y])
+ {
+ DrawGraphic(sx,sy, el2gfx(Store[x][y]));
+ draw_thru_mask = TRUE;
+ }
+ else if (element!=EL_DYNAMIT && element!=EL_DYNABOMB)
+ {
+ DrawLevelField(x,y);
+ draw_thru_mask = TRUE;
+ }
+
+ /*
+ else if (element!=EL_LEERRAUM && element!=EL_DYNAMIT && element!=EL_DYNABOMB)
+ {
+ DrawLevelField(x,y);
+ draw_thru_mask = TRUE;
+ }
+ */
+
+
+ draw_thru_mask = TRUE;
+
+
+
+
+ /* draw player himself */
+
+ if (PlayerMovDir==MV_LEFT)
+ graphic = (PlayerPushing ? GFX_SPIELER_PUSH_LEFT : GFX_SPIELER_LEFT);
+ else if (PlayerMovDir==MV_RIGHT)
+ graphic = (PlayerPushing ? GFX_SPIELER_PUSH_RIGHT : GFX_SPIELER_RIGHT);
+ else if (PlayerMovDir==MV_UP)
+ graphic = GFX_SPIELER_UP;
+ else /* MV_DOWN || MV_NO_MOVING */
+ graphic = GFX_SPIELER_DOWN;
+
+ graphic += PlayerFrame;
+
+
+ if (PlayerMovPos)
+ {
+ if (PlayerMovDir == MV_LEFT || PlayerMovDir == MV_RIGHT)
+ sxx = PlayerMovPos;
+ else
+ syy = PlayerMovPos;
+ }
+
+
+ if (!soft_scrolling_on && ScreenMovPos)
+ sxx = syy = 0;
+
+
+
+ if (draw_thru_mask)
+ DrawGraphicShiftedThruMask(sx,sy,sxx,syy,graphic,CUT_NO_CUTTING);
+ /*
+ DrawGraphicThruMask(sx, sy, graphic);
+ */
+ else
+ DrawGraphicShifted(sx,sy,sxx,syy,graphic,CUT_NO_CUTTING);
+ /*
+ DrawGraphic(sx, sy, graphic);
+ */
+
+
+
+ MarkTileDirty(sx,sy);
+
+
+
+ if (PlayerPushing && PlayerMovPos)
+ {
+ int nextJX = JX + (JX - lastJX);
+ int nextJY = JY + (JY - lastJY);
+ int px = SCROLLX(nextJX), py = SCROLLY(nextJY);
+
+ if (Feld[JX][JY] == EL_SOKOBAN_FELD_LEER ||
+ Feld[nextJX][nextJY] == EL_SOKOBAN_FELD_VOLL)
+ DrawGraphicShiftedThruMask(px,py,sxx,syy,
+ GFX_SOKOBAN_OBJEKT,
+ CUT_NO_CUTTING);
+ else
+ {
+ int element = Feld[nextJX][nextJY];
+ int graphic = el2gfx(element);
+
+ if (element == EL_FELSBROCKEN && sxx)
+ {
+ int phase = PlayerMovPos / (TILEX/4);
+
+ if (PlayerMovDir == MV_LEFT)
+ graphic += phase;
+ else
+ graphic += phase+4;
+ }
+
+ DrawGraphicShifted(px,py, sxx,syy, graphic, CUT_NO_CUTTING);
+ }
+ }
+
+
+
+ /* 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 = (48-MovDelay[x][y])/6) > 6)
+ phase = 6;
+ }
+ else
+ {
+ if ((phase = ((48-MovDelay[x][y])/3) % 8) > 3)
+ phase = 7-phase;
+ }
+
+ DrawGraphicThruMask(sx,sy, graphic + phase);
+ }
+
+ if (direct_draw_on)
+ {
+ int dest_x = SX+SCROLLX(x)*TILEX;
+ int dest_y = SY+SCROLLY(y)*TILEY;
+ int x_size = TILEX;
+ int y_size = TILEY;
+
+ if (!ScreenMovPos)
+ {
+ dest_x = SX + SCROLLX(MIN(JX,lastJX))*TILEX;
+ dest_y = SY + SCROLLY(MIN(JY,lastJY))*TILEY;
+ x_size = TILEX * (1 + ABS(JX - lastJX));
+ y_size = TILEY * (1 + ABS(JY - lastJY));
+ }
+
+ XCopyArea(display,drawto_field,window,gc,
+ dest_x,dest_y, x_size,y_size, dest_x,dest_y);
+ SetDrawtoField(DRAW_DIRECT);
+ }
+}
+
+static int getGraphicAnimationPhase(int frames, int delay, int mode)
+{
+ int phase;
+
+ if (mode == ANIM_OSCILLATE)
+ {
+ int max_anim_frames = frames*2 - 2;
+ phase = (FrameCounter % (delay * max_anim_frames)) / delay;
+ phase = (phase < frames ? phase : max_anim_frames - phase);
+ }
+ else
+ phase = (FrameCounter % (delay * frames)) / delay;
+
+ return(phase);
+}
+
+void DrawGraphicAnimation(int x, int y, int graphic,
+ int frames, int delay, int mode)
+{
+ int phase = getGraphicAnimationPhase(frames, delay, mode);
+
+/*
+ int phase;
+
+ if (mode == ANIM_OSCILLATE)
+ {
+ int max_anim_frames = frames*2 - 2;
+ phase = (FrameCounter % (delay * max_anim_frames)) / delay;
+ phase = (phase < frames ? phase : max_anim_frames - phase);
+ }
+ else
+ phase = (FrameCounter % (delay * frames)) / delay;
+*/
+
+ if (!(FrameCounter % delay) && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
+ DrawGraphic(SCROLLX(x),SCROLLY(y), graphic + phase);
+}
+