reset_delay = TRUE;
/* Fill empty backbuffer for animation functions */
- if (direct_draw_on && game_status==PLAYING)
+ if (direct_draw_on && game_status == PLAYING)
{
int xx,yy;
SetDrawtoField(DRAW_DIRECT);
}
- if (soft_scrolling_on && game_status==PLAYING)
+ if (soft_scrolling_on && game_status == PLAYING)
{
int fx = FX, fy = FY;
has its own synchronization and is CPU friendly, too */
if (game_status != PLAYING)
- Delay(1000);
+ {
+ XSync(display, FALSE);
+ Delay(10000);
+ }
}
- if (game_status==EXITGAME)
+ if (game_status == EXITGAME)
return;
}
}
SetDrawtoField(DRAW_DIRECT);
}
- if (soft_scrolling_on && game_status==PLAYING)
+ if (soft_scrolling_on && game_status == PLAYING)
+ {
+ int fx = FX, fy = FY;
+
+ fx += (PlayerMovDir & (MV_LEFT|MV_RIGHT) ? ScreenMovPos : 0);
+ fy += (PlayerMovDir & (MV_UP|MV_DOWN) ? ScreenMovPos : 0);
+
XCopyArea(display,fieldbuffer,backbuffer,gc,
- FX,FY, SXSIZE,SYSIZE,
+ fx,fy, SXSIZE,SYSIZE,
SX,SY);
+ }
XCopyArea(display,drawto,window,gc, x,y, width,height, x,y);
}
}
-int GameSpeed = 2;
-int MoveSpeed = 8;
-
void HandleKey(KeySym key, int key_status)
{
int joy = 0;
break;
case PLAYING:
{
+ static int player_frame_reset_delay = 0;
BOOL moved = FALSE, snapped = FALSE, bombed = FALSE;
if (GameOver && newbutton)
if (joy)
{
+ player_frame_reset_delay = 0;
+
if (button1)
snapped = SnapField(dx,dy);
else
{
DigField(0,0,0,0,DF_NO_PUSH);
SnapField(0,0);
- PlayerFrame = 0;
+ if (++player_frame_reset_delay > MoveSpeed)
+ PlayerFrame = 0;
}
if (tape.playing && !tape.pausing && !joy && tape.counter<tape.length)
#include "tape.h"
#include "joystick.h"
-
-
-int tst = 0;
-int tst2 = 0;
-
-
-
-extern int GameSpeed;
-extern int MoveSpeed;
-
void GetPlayerConfig()
{
int old_joystick_nr = joystick_nr;
void SiebAktivieren(int x, int y, int typ)
{
- if (SiebAktiv%2 && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
+ if (!(SiebAktiv % 4) && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
DrawGraphic(SCROLLX(x),SCROLLY(y),
- (typ==1 ? GFX_SIEB_VOLL : GFX_SIEB2_VOLL)+3-(SiebAktiv%8)/2);
+ (typ==1 ? GFX_SIEB_VOLL : GFX_SIEB2_VOLL)+3-(SiebAktiv%16)/4);
}
void AusgangstuerPruefen(int x, int y)
{
static long action_delay = 0;
long action_delay_value;
+ int sieb_x = 0, sieb_y = 0;
+ int x, y, element;
if (game_status != PLAYING)
return;
-/*
- action_delay_value =
- (tape.playing && tape.fast_forward ? FFWD_FRAME_DELAY : GAME_FRAME_DELAY);
-*/
-
+#ifdef DEBUG
action_delay_value =
(tape.playing && tape.fast_forward ? FFWD_FRAME_DELAY : GameSpeed);
-
- /*
- if (DelayReached(&action_delay, action_delay_value))
- */
-
-
+#else
+ action_delay_value =
+ (tape.playing && tape.fast_forward ? FFWD_FRAME_DELAY : GAME_FRAME_DELAY);
+#endif
if (PlayerMovPos)
ScrollFigure(0);
- DrawPlayerField();
-
-
-
-
- tst++;
-
- if (0)
- {
- static long last_Counter = 0;
- long new_Counter = Counter();
-
- printf("--> %ld / %ld [%d]\n",
- new_Counter - last_Counter,
- new_Counter,
- FrameCounter);
- last_Counter = new_Counter;
- }
-
-
-
-
- /*
- if (!DelayReached(&action_delay, action_delay_value))
- return;
- */
-
-
while(!DelayReached(&action_delay, action_delay_value))
- Delay(1000);
-
-
-
-
- /*
- printf("-----------\n");
- */
-
+ Delay(5000);
+ if (tape.pausing || (tape.playing && !TapePlayDelay()))
+ return;
+ else if (tape.recording)
+ TapeRecordDelay();
FrameCounter++;
+ TimeFrames++;
-
-
- /*
- if (PlayerMovPos)
- ScrollFigure(0);
-
- DrawPlayerField();
- */
-
-
- tst2 = tst;
- tst = 0;
-
-
-
- if (0)
- {
- static long last_Counter = 0;
- long new_Counter = Counter();
-
- printf("--> %ld / %ld [%d]\n",
- new_Counter - last_Counter,
- new_Counter,
- FrameCounter);
- last_Counter = new_Counter;
- }
-
-
- /*
- printf("--> %ld / ", Counter());
- */
-
-
+ for(y=0;y<lev_fieldy;y++) for(x=0;x<lev_fieldx;x++)
{
- int x,y,element;
- int sieb_x = 0, sieb_y = 0;
-
- if (tape.pausing || (tape.playing && !TapePlayDelay()))
- return;
- else if (tape.recording)
- TapeRecordDelay();
-
-
- /*
- FrameCounter++;
- */
-
+ Stop[x][y] = FALSE;
+ if (JustHit[x][y]>0)
+ JustHit[x][y]--;
- TimeFrames++;
-
- for(y=0;y<lev_fieldy;y++) for(x=0;x<lev_fieldx;x++)
+#if DEBUG
+ if (IS_BLOCKED(x,y))
{
- Stop[x][y] = FALSE;
- if (JustHit[x][y]>0)
- JustHit[x][y]--;
+ int oldx,oldy;
-#if DEBUG
- if (IS_BLOCKED(x,y))
+ Blocked2Moving(x,y,&oldx,&oldy);
+ if (!IS_MOVING(oldx,oldy))
{
- int oldx,oldy;
-
- Blocked2Moving(x,y,&oldx,&oldy);
- if (!IS_MOVING(oldx,oldy))
- {
- printf("GameActions(): (BLOCKED=>MOVING) context corrupted!\n");
- printf("GameActions(): BLOCKED: x = %d, y = %d\n",x,y);
- printf("GameActions(): !MOVING: oldx = %d, oldy = %d\n",oldx,oldy);
- printf("GameActions(): This should never happen!\n");
- }
+ printf("GameActions(): (BLOCKED=>MOVING) context corrupted!\n");
+ printf("GameActions(): BLOCKED: x = %d, y = %d\n",x,y);
+ printf("GameActions(): !MOVING: oldx = %d, oldy = %d\n",oldx,oldy);
+ printf("GameActions(): This should never happen!\n");
}
+ }
#endif
+ }
- }
+ for(y=0;y<lev_fieldy;y++) for(x=0;x<lev_fieldx;x++)
+ {
+ element = Feld[x][y];
- for(y=0;y<lev_fieldy;y++) for(x=0;x<lev_fieldx;x++)
- {
- element = Feld[x][y];
+ if (IS_INACTIVE(element))
+ continue;
- if (IS_INACTIVE(element))
- continue;
+ if (!IS_MOVING(x,y) && (CAN_FALL(element) || CAN_MOVE(element)))
+ {
+ StartMoving(x,y);
+
+ if (IS_GEM(element))
+ EdelsteinFunkeln(x,y);
+ }
+ else if (IS_MOVING(x,y))
+ ContinueMoving(x,y);
+ else if (element==EL_DYNAMIT || element==EL_DYNABOMB)
+ CheckDynamite(x,y);
+ else if (element==EL_EXPLODING)
+ Explode(x,y,Frame[x][y],EX_NORMAL);
+ else if (element==EL_AMOEBING)
+ AmoebeWaechst(x,y);
+ else if (IS_AMOEBALIVE(element))
+ AmoebeAbleger(x,y);
+ else if (element==EL_LIFE || element==EL_LIFE_ASYNC)
+ Life(x,y);
+ else if (element==EL_ABLENK_EIN)
+ Ablenk(x,y);
+ else if (element==EL_SALZSAEURE)
+ Blubber(x,y);
+ else if (element==EL_BLURB_LEFT || element==EL_BLURB_RIGHT)
+ Blurb(x,y);
+ else if (element==EL_CRACKINGNUT)
+ NussKnacken(x,y);
+ else if (element==EL_AUSGANG_ZU)
+ AusgangstuerPruefen(x,y);
+ else if (element==EL_AUSGANG_ACT)
+ AusgangstuerOeffnen(x,y);
+ else if (element==EL_AUSGANG_AUF)
+ AusgangstuerBlinken(x,y);
+ else if (element==EL_MAUERND)
+ MauerWaechst(x,y);
+ else if (element==EL_MAUER_LEBT)
+ MauerAbleger(x,y);
+ else if (element==EL_BURNING)
+ CheckForDragon(x,y);
- if (!IS_MOVING(x,y) && (CAN_FALL(element) || CAN_MOVE(element)))
- {
- StartMoving(x,y);
+ if (SiebAktiv)
+ {
+ BOOL sieb = FALSE;
- if (IS_GEM(element))
- EdelsteinFunkeln(x,y);
+ if (element==EL_SIEB_LEER || element==EL_SIEB_VOLL ||
+ Store[x][y]==EL_SIEB_LEER)
+ {
+ SiebAktivieren(x, y, 1);
+ sieb = TRUE;
}
- else if (IS_MOVING(x,y))
- ContinueMoving(x,y);
- else if (element==EL_DYNAMIT || element==EL_DYNABOMB)
- CheckDynamite(x,y);
- else if (element==EL_EXPLODING)
- Explode(x,y,Frame[x][y],EX_NORMAL);
- else if (element==EL_AMOEBING)
- AmoebeWaechst(x,y);
- else if (IS_AMOEBALIVE(element))
- AmoebeAbleger(x,y);
- else if (element==EL_LIFE || element==EL_LIFE_ASYNC)
- Life(x,y);
- else if (element==EL_ABLENK_EIN)
- Ablenk(x,y);
- else if (element==EL_SALZSAEURE)
- Blubber(x,y);
- else if (element==EL_BLURB_LEFT || element==EL_BLURB_RIGHT)
- Blurb(x,y);
- else if (element==EL_CRACKINGNUT)
- NussKnacken(x,y);
- else if (element==EL_AUSGANG_ZU)
- AusgangstuerPruefen(x,y);
- else if (element==EL_AUSGANG_ACT)
- AusgangstuerOeffnen(x,y);
- else if (element==EL_AUSGANG_AUF)
- AusgangstuerBlinken(x,y);
- else if (element==EL_MAUERND)
- MauerWaechst(x,y);
- else if (element==EL_MAUER_LEBT)
- MauerAbleger(x,y);
- else if (element==EL_BURNING)
- CheckForDragon(x,y);
-
- if (SiebAktiv)
+ else if (element==EL_SIEB2_LEER || element==EL_SIEB2_VOLL ||
+ Store[x][y]==EL_SIEB2_LEER)
{
- BOOL sieb = FALSE;
-
- if (element==EL_SIEB_LEER || element==EL_SIEB_VOLL ||
- Store[x][y]==EL_SIEB_LEER)
- {
- SiebAktivieren(x, y, 1);
- sieb = TRUE;
- }
- else if (element==EL_SIEB2_LEER || element==EL_SIEB2_VOLL ||
- Store[x][y]==EL_SIEB2_LEER)
- {
- SiebAktivieren(x, y, 2);
- sieb = TRUE;
- }
+ SiebAktivieren(x, y, 2);
+ sieb = TRUE;
+ }
- if (sieb && ABS(x-JX)+ABS(y-JY) < ABS(sieb_x-JX)+ABS(sieb_y-JY))
- {
- sieb_x = x;
- sieb_y = y;
- }
+ if (sieb && ABS(x-JX)+ABS(y-JY) < ABS(sieb_x-JX)+ABS(sieb_y-JY))
+ {
+ sieb_x = x;
+ sieb_y = y;
}
}
+ }
- if (SiebAktiv)
+ if (SiebAktiv)
+ {
+ if (!(SiebAktiv%4))
+ PlaySoundLevel(sieb_x,sieb_y,SND_MIEP);
+ SiebAktiv--;
+ if (!SiebAktiv)
{
- if (!(SiebAktiv%4))
- PlaySoundLevel(sieb_x,sieb_y,SND_MIEP);
- SiebAktiv--;
- if (!SiebAktiv)
+ for(y=0;y<lev_fieldy;y++) for(x=0;x<lev_fieldx;x++)
{
- for(y=0;y<lev_fieldy;y++) for(x=0;x<lev_fieldx;x++)
+ element = Feld[x][y];
+ if (element==EL_SIEB_LEER || element==EL_SIEB_VOLL)
{
- element = Feld[x][y];
- if (element==EL_SIEB_LEER || element==EL_SIEB_VOLL)
- {
- Feld[x][y] = EL_SIEB_TOT;
- DrawLevelField(x,y);
- }
- else if (element==EL_SIEB2_LEER || element==EL_SIEB2_VOLL)
- {
- Feld[x][y] = EL_SIEB2_TOT;
- DrawLevelField(x,y);
- }
+ Feld[x][y] = EL_SIEB_TOT;
+ DrawLevelField(x,y);
+ }
+ else if (element==EL_SIEB2_LEER || element==EL_SIEB2_VOLL)
+ {
+ Feld[x][y] = EL_SIEB2_TOT;
+ DrawLevelField(x,y);
}
}
}
}
-
- /*
- printf("%ld\n", Counter());
- */
-
-
if (TimeLeft>0 && TimeFrames>=(100/GameSpeed) && !tape.pausing)
{
TimeFrames = 0;
}
DrawPlayerField();
-
- BackToFront();
}
void ScrollLevel(int dx, int dy)
void ScrollFigure(int init)
{
static long actual_frame_counter = 0;
- static int oldJX = -1, oldJY = -1;
if (init)
{
-
-
-
PlayerGfxPos = ScrollStepSize * (PlayerMovPos / ScrollStepSize);
-
-
-
- /*
- ScreenMovPos = PlayerGfxPos;
- redraw_mask |= REDRAW_FIELD;
- */
-
-
-
- if (0)
- {
- static long last_Counter = 0;
- long new_Counter = Counter();
-
- printf("--> %ld / %ld [%d, %d]\n",
- new_Counter - last_Counter,
- new_Counter,
- FrameCounter,
- tst2);
- last_Counter = new_Counter;
- }
-
-
-
-
- if (oldJX != -1 && oldJY != -1)
- DrawLevelElement(oldJX,oldJY, Feld[oldJX][oldJY]);
+ actual_frame_counter = FrameCounter;
if (Feld[lastJX][lastJY] == EL_LEERRAUM &&
IN_LEV_FIELD(lastJX,lastJY-1) &&
CAN_FALL(Feld[lastJX][lastJY-1]))
Feld[lastJX][lastJY] = EL_PLAYER_IS_LEAVING;
- DrawLevelElement(lastJX,lastJY, Feld[lastJX][lastJY]);
- DrawPlayerField();
-
- oldJX = lastJX;
- oldJY = lastJY;
- actual_frame_counter = FrameCounter;
-
- if (PlayerPushing)
- {
- int nextJX = JX + (JX - lastJX);
- int nextJY = JY + (JY - lastJY);
-
- if (Feld[nextJX][nextJY] == EL_SOKOBAN_FELD_VOLL)
- DrawLevelElement(nextJX,nextJY, EL_SOKOBAN_FELD_LEER);
- else
- DrawLevelElement(nextJX,nextJY, EL_LEERRAUM);
- }
DrawPlayerField();
-
- if (Store[lastJX][lastJY])
- {
- DrawGraphic(SCROLLX(lastJX),SCROLLY(lastJY),
- el2gfx(Store[lastJX][lastJY]));
- DrawGraphicThruMask(SCROLLX(lastJX),SCROLLY(lastJY),
- el2gfx(Feld[lastJX][lastJY]));
- }
- else if (Feld[lastJX][lastJY]==EL_DYNAMIT)
- DrawDynamite(lastJX,lastJY);
- else
- DrawLevelField(lastJX,lastJY);
-
return;
}
else if (!FrameReached(&actual_frame_counter,1))
PlayerMovPos += (PlayerMovPos > 0 ? -1 : 1) * TILEX/8;
PlayerGfxPos = ScrollStepSize * (PlayerMovPos / ScrollStepSize);
-
- /*
- printf("PlayerGfxPos = %d\n", PlayerGfxPos);
- */
-
-
if (ScreenMovPos && ScreenMovPos != PlayerGfxPos)
{
ScreenMovPos = PlayerGfxPos;
redraw_mask |= REDRAW_FIELD;
}
- if (Feld[oldJX][oldJY] == EL_PLAYER_IS_LEAVING)
- Feld[oldJX][oldJY] = EL_LEERRAUM;
+ if (Feld[lastJX][lastJY] == EL_PLAYER_IS_LEAVING)
+ Feld[lastJX][lastJY] = EL_LEERRAUM;
- DrawLevelElement(oldJX,oldJY, Feld[oldJX][oldJY]);
DrawPlayerField();
-
-
- if (Store[oldJX][oldJY])
- {
- DrawGraphic(SCROLLX(oldJX),SCROLLY(oldJY),el2gfx(Store[oldJX][oldJY]));
- DrawGraphicThruMask(SCROLLX(oldJX),SCROLLY(oldJY),
- el2gfx(Feld[oldJX][oldJY]));
- }
- else if (Feld[oldJX][oldJY]==EL_DYNAMIT)
- DrawDynamite(oldJX,oldJY);
- else
- DrawLevelField(oldJX,oldJY);
-
- if (PlayerPushing)
- {
- int nextJX = JX + (JX - lastJX);
- int nextJY = JY + (JY - lastJY);
-
- if (PlayerGfxPos)
- {
- if (Feld[nextJX][nextJY] == EL_SOKOBAN_FELD_VOLL)
- DrawLevelElement(nextJX,nextJY, EL_SOKOBAN_FELD_LEER);
- else
- DrawLevelElement(nextJX,nextJY, EL_LEERRAUM);
- }
- else
- DrawLevelElement(nextJX,nextJY, Feld[nextJX][nextJY]);
- }
-
if (!PlayerMovPos)
{
lastJX = JX;
lastJY = JY;
-
- oldJX = oldJY = -1;
}
}
return(NULL);
}
+
+
+ /*
printf("%s:\n %dx%d %s%s image with %d colors at depth %d\n",
fullname, gifin_img_width, gifin_img_height,
(gifin_interlace_flag ? "interlaced " : ""),
gif_version_name[gifin_version],
(gifin_l_cmap_flag ? gifin_l_ncolors : gifin_g_ncolors),
(gifin_l_cmap_flag ? gifin_l_pixel_bits : gifin_g_pixel_bits));
+ */
+
+
image = newRGBImage(gifin_img_width, gifin_img_height, (gifin_l_cmap_flag ?
gifin_l_pixel_bits :
#include "xli.h"
#ifdef DEBUG
+/*
#define DEBUG_TIMING
+*/
#endif
#include <signal.h>
#ifdef DEBUG
+/*
#define DEBUG_TIMING
+*/
#endif
struct PictureFileInfo
#include "main.h"
#include "init.h"
+#include "game.h"
#include "events.h"
#include "sound.h"
#include "joystick.h"
int lev_fieldx,lev_fieldy, scroll_x,scroll_y;
int FX = SX, FY = SY, ScreenMovPos = 0, ScrollStepSize = TILEX/8;
+int GameSpeed = GAME_FRAME_DELAY, MoveSpeed = 8;
int BX1 = 0, BY1 = 0, BX2 = SCR_FIELDX-1, BY2 = SCR_FIELDY-1;
int JX,JY, lastJX,lastJY, ZX,ZY, ExitX,ExitY;
int PlayerMovDir, PlayerMovPos, PlayerPushing;
extern int lev_fieldx,lev_fieldy, scroll_x,scroll_y;
extern int FX,FY, ScreenMovPos, ScrollStepSize;
+extern int GameSpeed, MoveSpeed;
extern int BX1,BY1, BX2,BY2;
extern int JX,JY, lastJX,lastJY, ZX,ZY, ExitX,ExitY;
extern int PlayerMovDir, PlayerMovPos, PlayerPushing;
void microsleep(unsigned long usec)
{
- struct timeval delay;
+ if (usec < 5000)
+ {
+ /* we want to wait less than 5 ms -- if we assume that we have a
+ kernel timer resolution of 10 ms, we would wait far to long;
+ therefore it's better to do a short interval of busy waiting
+ to get our sleeping time more accurate */
- delay.tv_sec = usec / 1000000;
- delay.tv_usec = usec % 1000000;
+ long base_counter = Counter2(), actual_counter = Counter2();
+ long delay = usec/1000;
- if (select(0,NULL,NULL,NULL,&delay)!=0)
- fprintf(stderr,"%s: in function microsleep: select failed!\n",
- progname);
+ while (actual_counter < base_counter+delay &&
+ actual_counter >= base_counter)
+ actual_counter = Counter2();
+ }
+ else
+ {
+ struct timeval delay;
+
+ delay.tv_sec = usec / 1000000;
+ delay.tv_usec = usec % 1000000;
+
+ if (select(0,NULL,NULL,NULL,&delay) != 0)
+ fprintf(stderr,"%s: in function microsleep: select failed!\n",
+ progname);
+ }
}
long mainCounter(int mode)
TapeStop();
GameActions();
+
+ BackToFront();
}
void HandleVideoButtons(int mx, int my, int button)
int element = Feld[x][y];
int graphic, phase;
- BOOL draw_thru_mask = FALSE;
if (PlayerGone)
return;
if (direct_draw_on)
SetDrawtoField(DRAW_BUFFERED);
- /* draw things behind the player (EL_PFORTE* || mole/penguin/pig/dragon) */
-
-
+ /* draw things in the field the player is leaving, if needed */
+ if (lastJX != JX || lastJY != JY)
+ {
+ if (Store[lastJX][lastJY])
+ {
+ DrawLevelElement(lastJX,lastJY, Store[lastJX][lastJY]);
+ DrawLevelElementThruMask(lastJX,lastJY, Feld[lastJX][lastJY]);
+ }
+ else if (Feld[lastJX][lastJY] == EL_DYNAMIT)
+ DrawDynamite(lastJX,lastJY);
+ else
+ DrawLevelField(lastJX,lastJY);
- DrawLevelField(x,y);
+ if (PlayerPushing)
+ {
+ int nextJX = JX + (JX - lastJX);
+ int nextJY = JY + (JY - lastJY);
+ if (PlayerGfxPos)
+ {
+ if (Feld[nextJX][nextJY] == EL_SOKOBAN_FELD_VOLL)
+ DrawLevelElement(nextJX,nextJY, EL_SOKOBAN_FELD_LEER);
+ else
+ DrawLevelElement(nextJX,nextJY, EL_LEERRAUM);
+ }
+ else
+ DrawLevelField(nextJX,nextJY);
+ }
+ }
+ /* draw things behind the player, if needed */
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)
- {
+ DrawLevelElement(x,y, Store[x][y]);
+ else if (element != EL_DYNAMIT && element != EL_DYNABOMB)
DrawLevelField(x,y);
- draw_thru_mask = TRUE;
- }
- */
-
-
- draw_thru_mask = TRUE;
-
-
-
/* draw player himself */
graphic += PlayerFrame;
-
if (PlayerGfxPos)
{
if (PlayerMovDir == MV_LEFT || PlayerMovDir == MV_RIGHT)
syy = PlayerGfxPos;
}
-
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);
-
-
+ DrawGraphicShiftedThruMask(sx,sy, sxx,syy, graphic, NO_CUTTING);
if (PlayerPushing && PlayerGfxPos)
{
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);
+ DrawGraphicShiftedThruMask(px,py,sxx,syy, GFX_SOKOBAN_OBJEKT,NO_CUTTING);
else
{
int element = Feld[nextJX][nextJY];
graphic += phase;
else
graphic += (phase+4)%4;
-
-
- /*
- printf("----> (%d, %d, %d)\n",
- PlayerGfxPos, phase, graphic);
- */
-
}
- DrawGraphicShifted(px,py, sxx,syy, graphic, CUT_NO_CUTTING);
+ 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)
dest_x,dest_y, x_size,y_size, dest_x,dest_y);
SetDrawtoField(DRAW_DIRECT);
}
+
+ MarkTileDirty(sx,sy);
}
static int getGraphicAnimationPhase(int frames, int delay, int mode)
MarkTileDirty(x,y);
}
-void DrawElementThruMask(int x, int y, int element)
+void DrawScreenElementThruMask(int x, int y, int element)
{
DrawGraphicThruMask(x,y,el2gfx(element));
}
+void DrawLevelElementThruMask(int x, int y, int element)
+{
+ if (IN_LEV_FIELD(x,y) && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
+ DrawScreenElementThruMask(SCROLLX(x),SCROLLY(y),element);
+}
+
void DrawMiniGraphic(int x, int y, int graphic)
{
DrawMiniGraphicExt(drawto, gc, x, y, graphic);
XFillRectangle(display,d,gc, x,y, MINI_TILEX,MINI_TILEY);
}
-void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, int cut_mode)
+void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic,
+ int cut_mode, int mask_mode)
{
int width = TILEX, height = TILEY;
int cx = 0, cy = 0;
+ int src_x,src_y, dest_x,dest_y;
if (graphic < 0)
{
if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN)
{
graphic -= GFX_START_ROCKSSCREEN;
- XCopyArea(display,pix[PIX_BACK],drawto_field,gc,
- SX+(graphic % GFX_PER_LINE)*TILEX+cx,
- SY+(graphic / GFX_PER_LINE)*TILEY+cy,
- width,height, FX+x*TILEX+dx,FY+y*TILEY+dy);
+ src_x = SX+(graphic % GFX_PER_LINE)*TILEX+cx;
+ src_y = SY+(graphic / GFX_PER_LINE)*TILEY+cy;
+ dest_x = FX+x*TILEX+dx;
+ dest_y = FY+y*TILEY+dy;
+
+ if (mask_mode == USE_MASKING)
+ {
+ XSetClipOrigin(display,clip_gc[PIX_BACK],dest_x-src_x,dest_y-src_y);
+ XCopyArea(display,pix[PIX_BACK],drawto_field,clip_gc[PIX_BACK],
+ src_x,src_y, width,height, dest_x,dest_y);
+ }
+ else
+ XCopyArea(display,pix[PIX_BACK],drawto_field,gc,
+ src_x,src_y, width,height, dest_x,dest_y);
}
else if (graphic >= GFX_START_ROCKSHEROES && graphic <= GFX_END_ROCKSHEROES)
{
graphic -= GFX_START_ROCKSHEROES;
- XCopyArea(display,pix[PIX_HEROES],drawto_field,gc,
- (graphic % HEROES_PER_LINE)*TILEX+cx,
- (graphic / HEROES_PER_LINE)*TILEY+cy,
- width,height, FX+x*TILEX+dx,FY+y*TILEY+dy);
+ src_x = (graphic % HEROES_PER_LINE)*TILEX+cx;
+ src_y = (graphic / HEROES_PER_LINE)*TILEY+cy;
+ dest_x = FX+x*TILEX+dx;
+ dest_y = FY+y*TILEY+dy;
+
+ if (mask_mode == USE_MASKING)
+ {
+ XSetClipOrigin(display,clip_gc[PIX_HEROES],dest_x-src_x,dest_y-src_y);
+ XCopyArea(display,pix[PIX_HEROES],drawto_field,clip_gc[PIX_HEROES],
+ src_x,src_y, width,height, dest_x,dest_y);
+ }
+ else
+ XCopyArea(display,pix[PIX_HEROES],drawto_field,gc,
+ src_x,src_y, width,height, dest_x,dest_y);
}
#if DEBUG
MarkTileDirty(x,y);
}
-void DrawElementShifted(int x, int y, int dx, int dy, int element,int cut_mode)
+void DrawGraphicShiftedThruMask(int x,int y, int dx,int dy, int graphic,
+ int cut_mode)
+{
+ DrawGraphicShifted(x,y, dx,dy, graphic, cut_mode, USE_MASKING);
+}
+
+void DrawScreenElementShifted(int x, int y, int dx, int dy, int element,
+ int cut_mode)
{
int ux = UNSCROLLX(x), uy = UNSCROLLY(y);
int graphic = el2gfx(element);
}
if (dx || dy)
- DrawGraphicShifted(x,y, dx,dy, graphic, cut_mode);
+ DrawGraphicShifted(x,y, dx,dy, graphic, cut_mode, NO_MASKING);
else
DrawGraphic(x,y, graphic);
}
-void DrawGraphicShiftedThruMask(int x,int y, int dx,int dy, int graphic,
- int cut_mode)
+void DrawLevelElementShifted(int x, int y, int dx, int dy, int element,
+ int cut_mode)
{
- int width = TILEX, height = TILEY;
- int cx = 0, cy = 0;
- int src_x,src_y, dest_x,dest_y;
-
- if (graphic < 0)
- {
- DrawGraphic(x,y,graphic);
- return;
- }
-
- if (dx || dy) /* Verschiebung der Grafik? */
- {
- if (x < BX1) /* Element kommt von links ins Bild */
- {
- x = BX1;
- width = dx;
- cx = TILEX - dx;
- dx = 0;
- }
- else if (x > BX2) /* Element kommt von rechts ins Bild */
- {
- x = BX2;
- width = -dx;
- dx = TILEX + dx;
- }
- else if (x==BX1 && dx<0) /* Element verläßt links das Bild */
- {
- width += dx;
- cx = -dx;
- dx = 0;
- }
- else if (x==BX2 && dx>0) /* Element verläßt rechts das Bild */
- width -= dx;
- else if (dx) /* allg. Bewegung in x-Richtung */
- MarkTileDirty(x + SIGN(dx), y);
-
- if (y < BY1) /* Element kommt von oben ins Bild */
- {
- if (cut_mode==CUT_BELOW) /* Element oberhalb des Bildes */
- return;
-
- y = BY1;
- height = dy;
- cy = TILEY - dy;
- dy = 0;
- }
- else if (y > BY2) /* Element kommt von unten ins Bild */
- {
- y = BY2;
- height = -dy;
- dy = TILEY + dy;
- }
- else if (y==BY1 && dy<0) /* Element verläßt oben das Bild */
- {
- height += dy;
- cy = -dy;
- dy = 0;
- }
- else if (dy > 0 && cut_mode==CUT_ABOVE)
- {
- if (y == BY2) /* Element unterhalb des Bildes */
- return;
-
- height = dy;
- cy = TILEY-dy;
- dy = TILEY;
- MarkTileDirty(x, y + 1);
- } /* Element verläßt unten das Bild */
- else if (dy > 0 && (y == BY2 || cut_mode==CUT_BELOW))
- height -= dy;
- else if (dy) /* allg. Bewegung in y-Richtung */
- MarkTileDirty(x, y + SIGN(dy));
- }
-
- if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN)
- {
- graphic -= GFX_START_ROCKSSCREEN;
- src_x = SX+(graphic % GFX_PER_LINE)*TILEX+cx;
- src_y = SY+(graphic / GFX_PER_LINE)*TILEY+cy;
- dest_x = FX+x*TILEX+dx;
- dest_y = FY+y*TILEY+dy;
-
- XSetClipOrigin(display,clip_gc[PIX_BACK],dest_x-src_x,dest_y-src_y);
- XCopyArea(display,pix[PIX_BACK],drawto_field,clip_gc[PIX_BACK],
- src_x,src_y, width,height, dest_x,dest_y);
- }
- else if (graphic >= GFX_START_ROCKSHEROES && graphic <= GFX_END_ROCKSHEROES)
- {
- graphic -= GFX_START_ROCKSHEROES;
- src_x = (graphic % HEROES_PER_LINE)*TILEX+cx;
- src_y = (graphic / HEROES_PER_LINE)*TILEY+cy;
- dest_x = FX+x*TILEX+dx;
- dest_y = FY+y*TILEY+dy;
-
- XSetClipOrigin(display,clip_gc[PIX_HEROES],dest_x-src_x,dest_y-src_y);
- XCopyArea(display,pix[PIX_HEROES],drawto_field,clip_gc[PIX_HEROES],
- src_x,src_y, width,height, dest_x,dest_y);
- }
-
-#if DEBUG
- if (!IN_SCR_FIELD(x,y))
- {
- printf("DrawGraphicShiftedThruMask(): x = %d, y = %d, graphic = %d\n",
- x,y,graphic);
- printf("DrawGraphicShifted(): This should never happen!\n");
- return;
- }
-#endif
-
- MarkTileDirty(x,y);
+ if (IN_LEV_FIELD(x,y) && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
+ DrawScreenElementShifted(SCROLLX(x),SCROLLY(y), dx,dy, element, cut_mode);
}
void ErdreichAnbroeckeln(int x, int y)
else
element = Feld[uxx][uyy];
-/*
- if (element==EL_ERDREICH || IS_SOLID(element))
- continue;
-*/
if (element==EL_ERDREICH)
continue;
yy = y+xy[i][1];
uxx = ux+xy[i][0];
uyy = uy+xy[i][1];
-/*
- if (!IN_LEV_FIELD(uxx,uyy) || Feld[uxx][uyy]!=EL_ERDREICH ||
- !IN_SCR_FIELD(xx,yy) || IS_SOLID(element))
- continue;
-*/
if (!IN_LEV_FIELD(uxx,uyy) || Feld[uxx][uyy]!=EL_ERDREICH ||
!IN_SCR_FIELD(xx,yy))
void DrawScreenElement(int x, int y, int element)
{
- DrawElementShifted(x,y,0,0,element,CUT_NO_CUTTING);
+ DrawScreenElementShifted(x,y, 0,0, element, NO_CUTTING);
ErdreichAnbroeckeln(x,y);
}
if (IS_MOVING(ux,uy))
{
int horiz_move = (MovDir[ux][uy]==MV_LEFT || MovDir[ux][uy]==MV_RIGHT);
- BOOL cut_mode = CUT_NO_CUTTING;
+ BOOL cut_mode = NO_CUTTING;
if (Store[ux][uy]==EL_MORAST_LEER ||
Store[ux][uy]==EL_SIEB_LEER ||
cut_mode = CUT_BELOW;
if (cut_mode==CUT_ABOVE)
- DrawElementShifted(x,y,0,0,Store[ux][uy],CUT_NO_CUTTING);
+ DrawScreenElementShifted(x,y, 0,0, Store[ux][uy], NO_CUTTING);
else
DrawScreenElement(x,y,EL_LEERRAUM);
if (horiz_move)
- DrawElementShifted(x,y,MovPos[ux][uy],0,element,CUT_NO_CUTTING);
+ DrawScreenElementShifted(x,y, MovPos[ux][uy],0, element, NO_CUTTING);
else
- DrawElementShifted(x,y,0,MovPos[ux][uy],element,cut_mode);
+ DrawScreenElementShifted(x,y, 0,MovPos[ux][uy], element, cut_mode);
}
else if (IS_BLOCKED(ux,uy))
{
int oldx,oldy;
int sx, sy;
int horiz_move;
- BOOL cut_mode = CUT_NO_CUTTING;
+ BOOL cut_mode = NO_CUTTING;
Blocked2Moving(ux,uy,&oldx,&oldy);
sx = SCROLLX(oldx);
element = Feld[oldx][oldy];
if (horiz_move)
- DrawElementShifted(sx,sy,MovPos[oldx][oldy],0,element,CUT_NO_CUTTING);
+ DrawScreenElementShifted(sx,sy, MovPos[oldx][oldy],0,element,NO_CUTTING);
else
- DrawElementShifted(sx,sy,0,MovPos[oldx][oldy],element,cut_mode);
+ DrawScreenElementShifted(sx,sy, 0,MovPos[oldx][oldy],element,cut_mode);
}
else if (IS_DRAWABLE(element))
DrawScreenElement(x,y,element);
BackToFront();
- if (game_status==MAINMENU)
+ if (game_status == MAINMENU)
DoAnimation();
}
}
#include <sys/time.h>
-/* für SetDrawtoField */
+/* for SetDrawtoField */
#define DRAW_DIRECT 0
#define DRAW_BUFFERED 1
#define DRAW_BACKBUFFER 2
-/* für DrawElementShifted */
-#define CUT_NO_CUTTING 0
+/* for DrawElementShifted */
+#define NO_CUTTING 0
#define CUT_ABOVE 1
#define CUT_BELOW 2
#define CUT_LEFT 4
#define CUT_RIGHT 8
-/* für MoveDoor */
+/* for masking functions */
+#define NO_MASKING 0
+#define USE_MASKING 1
+
+/* for MoveDoor */
#define DOOR_OPEN_1 1
#define DOOR_OPEN_2 2
#define DOOR_CLOSE_1 4
#define DOOR_NO_DELAY 32
#define DOOR_GET_STATE 64
-/* für AreYouSure */
+/* for AreYouSure */
#define AYS_ASK 1
#define AYS_OPEN 2
#define AYS_CLOSE 4
void DrawGraphicExt(Drawable, GC, int, int, int);
void DrawGraphicExtHiRes(Drawable, GC, int, int, int);
void DrawGraphicThruMask(int, int, int);
-void DrawElementThruMask(int, int, int);
+void DrawScreenElementThruMask(int, int, int);
+void DrawLevelElementThruMask(int, int, int);
void DrawMiniGraphic(int, int, int);
void DrawMiniGraphicExt(Drawable, GC, int, int, int);
void DrawMiniGraphicExtHiRes(Drawable, GC, int, int, int);
-void DrawGraphicShifted(int, int, int, int, int, int);
-void DrawElementShifted(int, int, int, int, int, int);
+void DrawGraphicShifted(int, int, int, int, int, int, int);
void DrawGraphicShiftedThruMask(int, int, int, int, int, int);
+void DrawScreenElementShifted(int, int, int, int, int, int);
+void DrawLevelElementShifted(int, int, int, int, int, int);
void ErdreichAnbroeckeln(int, int);
void DrawScreenElement(int, int, int);
void DrawLevelElement(int, int, int);