+void DrawPlayerField()
+{
+ int x = JX, y = JY;
+ int sx = SCROLLX(x), sy = SCROLLY(y);
+ 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(): This should never happen!\n");
+ return;
+ }
+#endif
+
+ if (element == EL_EXPLODING)
+ return;
+
+ if (direct_draw_on)
+ drawto_field = backbuffer;
+
+ /* draw things behind the player (EL_PFORTE* || mole/penguin/pig/dragon) */
+
+ if (Store[x][y])
+ {
+ DrawGraphic(sx,sy, el2gfx(Store[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 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 (draw_thru_mask)
+ DrawGraphicThruMask(sx,sy, graphic);
+ else
+ DrawGraphic(sx,sy, graphic);
+
+ /* 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;
+
+ XCopyArea(display,backbuffer,window,gc,
+ dest_x,dest_y, TILEX,TILEY, dest_x,dest_y);
+ drawto_field = window;
+ }
+}
+
+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);
+}
+