From: Holger Schemel Date: Thu, 13 Aug 1998 09:15:58 +0000 (+0200) Subject: rnd-19980813 X-Git-Tag: 1.2.0^2~96 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=5335fd9e893a7af87a72fb78609c2eb281bd7f63;p=rocksndiamonds.git rnd-19980813 --- diff --git a/src/game.c b/src/game.c index 01d6b72c..521cc1a8 100644 --- a/src/game.c +++ b/src/game.c @@ -2764,11 +2764,21 @@ void ScrollLevel(int dx, int dy) int x,y; int softscroll_offset = (FX == TILEX ? TILEX : 0); + /* if (soft_scrolling_on) { ScreenMovPos = PlayerMovPos; redraw_mask |= REDRAW_FIELD; } + */ + + + ScreenMovPos = PlayerMovPos; + if (soft_scrolling_on) + { + redraw_mask |= REDRAW_FIELD; + } + XCopyArea(display,drawto_field,drawto_field,gc, FX + TILEX*(dx==-1) - softscroll_offset, @@ -2850,8 +2860,8 @@ BOOL MoveFigureOneStep(int dx, int dy, int real_dx, int real_dy) JY = newJY; - JX2 = oldJX; - JY2 = oldJY; + lastJX = oldJX; + lastJY = oldJY; PlayerMovPos = (dx > 0 || dy > 0 ? -1 : 1) * 3*TILEX/4; @@ -2980,29 +2990,49 @@ BOOL MoveFigure(int dx, int dy) void ScrollFigure(int init) { static long actual_frame_counter; - static int oldX = -1, oldY = -1; + static int oldJX = -1, oldJY = -1; if (init) { - if (PlayerMovPos && oldX != -1 && oldY != -1) + /* + if (PlayerMovPos && oldJX != -1 && oldJY != -1) + { + if (Feld[lastJX][lastJY] == EL_LEERRAUM) + Feld[lastJX][lastJY] = EL_PLAYER_IS_LEAVING; + DrawLevelElement(oldJX,oldJY, Feld[oldJX][oldJY]); + DrawPlayerField(); + } + */ + + if (oldJX != -1 && oldJY != -1) { - if (Feld[JX2][JY2] == EL_LEERRAUM) - Feld[JX2][JY2] = EL_UNSICHTBAR; - DrawLevelElement(oldX,oldY, Feld[oldX][oldY]); + /* + if (Feld[lastJX][lastJY] == EL_LEERRAUM) + Feld[lastJX][lastJY] = EL_PLAYER_IS_LEAVING; + */ + DrawLevelElement(oldJX,oldJY, Feld[oldJX][oldJY]); + /* + DrawLevelElement(lastJX,lastJY, Feld[lastJX][lastJY]); DrawPlayerField(); + */ } - oldX = JX2; - oldY = JY2; + if (Feld[lastJX][lastJY] == EL_LEERRAUM) + Feld[lastJX][lastJY] = EL_PLAYER_IS_LEAVING; + DrawLevelElement(lastJX,lastJY, Feld[lastJX][lastJY]); + DrawPlayerField(); + + oldJX = lastJX; + oldJY = lastJY; actual_frame_counter = FrameCounter; /* - redraw[redraw_x1 + oldX][redraw_y1 + oldY] = 1; + redraw[redraw_x1 + oldJX][redraw_y1 + oldJY] = 1; redraw_tiles++; */ /* - DrawLevelElement(oldX,oldY, Feld[oldX][oldY]); + DrawLevelElement(oldJX,oldJY, Feld[oldJX][oldJY]); */ DrawPlayerField(); @@ -3020,16 +3050,33 @@ void ScrollFigure(int init) redraw_mask |= REDRAW_FIELD; } - if (Feld[oldX][oldY] == EL_UNSICHTBAR) - Feld[oldX][oldY] = EL_LEERRAUM; + if (Feld[oldJX][oldJY] == EL_PLAYER_IS_LEAVING) + Feld[oldJX][oldJY] = EL_LEERRAUM; - DrawLevelElement(oldX,oldY, Feld[oldX][oldY]); + 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 (!PlayerMovPos) { - JX2 = JX; - JY2 = JY; + lastJX = JX; + lastJY = JY; + + oldJX = oldJY = -1; } } @@ -3539,7 +3586,7 @@ BOOL PlaceBomb(void) { int element; - if (PlayerGone) + if (PlayerGone || PlayerMovPos) return(FALSE); element = Feld[JX][JY]; diff --git a/src/main.c b/src/main.c index f8077436..bd5edbb8 100644 --- a/src/main.c +++ b/src/main.c @@ -84,7 +84,7 @@ int lev_fieldx,lev_fieldy, scroll_x,scroll_y; int FX = SX, FY = SY, ScreenMovPos = 0; int BX1 = 0, BY1 = 0, BX2 = SCR_FIELDX-1, BY2 = SCR_FIELDY-1; -int JX,JY, JX2,JY2, ZX,ZY, ExitX,ExitY; +int JX,JY, lastJX,lastJY, ZX,ZY, ExitX,ExitY; int PlayerMovDir, PlayerMovPos, PlayerFrame, PlayerPushing; int PlayerGone,LevelSolved,GameOver; int FrameCounter,TimeFrames,TimeLeft,Score; diff --git a/src/main.h b/src/main.h index 90dcd6d2..455037c2 100644 --- a/src/main.h +++ b/src/main.h @@ -71,7 +71,7 @@ typedef int BOOL; #define IS_PLAYER(x,y) (JX==(x) && JY==(y)) /* -#define IS_PLAYER(x,y) ((JX==(x) && JY==(y)) || (JX2==(x) && JY2==(y))) +#define IS_PLAYER(x,y) ((JX==(x) && JY==(y)) || (lastJX==(x) && lastJY==(y))) */ #define IS_FREE(x,y) (Feld[x][y]==EL_LEERRAUM && !IS_PLAYER(x,y)) @@ -308,7 +308,7 @@ extern int lev_fieldx,lev_fieldy, scroll_x,scroll_y; extern int FX,FY, ScreenMovPos; extern int BX1,BY1, BX2,BY2; -extern int JX,JY, JX2,JY2, ZX,ZY, ExitX,ExitY; +extern int JX,JY, lastJX,lastJY, ZX,ZY, ExitX,ExitY; extern int PlayerMovDir, PlayerMovPos, PlayerFrame, PlayerPushing; extern int PlayerGone,LevelSolved,GameOver; extern int FrameCounter,TimeFrames,TimeLeft,Score; @@ -565,6 +565,7 @@ extern char *progname; #define EL_AMOEBING 305 #define EL_MAUERND 306 #define EL_BURNING 307 +#define EL_PLAYER_IS_LEAVING 308 /* game graphics: ** 0 - 255: graphics from "RocksScreen" diff --git a/src/tools.c b/src/tools.c index bbf81e33..8dd25fcf 100644 --- a/src/tools.c +++ b/src/tools.c @@ -98,8 +98,8 @@ void BackToFront() */ /* - if (IN_SCR_FIELD(JX2,JY2)) - redraw[redraw_x1 + JX2][redraw_y1 + JY2] = 0; + if (IN_SCR_FIELD(lastJX,lastJY)) + redraw[redraw_x1 + lastJX][redraw_y1 + lastJY] = 0; */ @@ -140,8 +140,13 @@ void BackToFront() if (redraw_mask & REDRAW_FIELD) { - int fx = FX + (PlayerMovDir & (MV_LEFT|MV_RIGHT) ? ScreenMovPos : 0); - int fy = FY + (PlayerMovDir & (MV_UP|MV_DOWN) ? ScreenMovPos : 0); + int fx = FX, fy = FY; + + if (soft_scrolling_on) + { + fx += (PlayerMovDir & (MV_LEFT|MV_RIGHT) ? ScreenMovPos : 0); + fy += (PlayerMovDir & (MV_UP|MV_DOWN) ? ScreenMovPos : 0); + } if (game_status == PLAYING && !(redraw_mask & REDRAW_FROM_BACKBUFFER)) { @@ -409,16 +414,37 @@ void DrawPlayerField() /* 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 */ @@ -442,13 +468,42 @@ void DrawPlayerField() syy = PlayerMovPos; } +#if 0 + if (!soft_scrolling_on) + { + int old_scroll_x=scroll_x, old_scroll_y=scroll_y; + int new_scroll_x=scroll_x, new_scroll_y=scroll_y; + int offset = (scroll_delay_on ? 3 : 0); + + if ((scroll_x < lastJX-MIDPOSX-offset || scroll_x > lastJX-MIDPOSX+offset) && + lastJX>=MIDPOSX-1-offset && lastJX<=lev_fieldx-(MIDPOSX-offset)) + new_scroll_x = lastJX-MIDPOSX + (scroll_x < lastJX-MIDPOSX ? -offset : offset); + if ((scroll_y < lastJY-MIDPOSY-offset || scroll_y > lastJY-MIDPOSY+offset) && + JY>=MIDPOSY-1-offset && JY<=lev_fieldy-(MIDPOSY-offset)) + new_scroll_y = lastJY-MIDPOSY + (scroll_y < lastJY-MIDPOSY ? -offset : offset); + + if (new_scroll_x!=old_scroll_x || new_scroll_y!=old_scroll_y) + /* + ScrollLevel(old_scroll_x-scroll_x,old_scroll_y-scroll_y); + */ + sxx = syy = 0; + } +#endif + + + 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 + sxx, sy + syy, graphic); + DrawGraphic(sx, sy, graphic); */ @@ -856,6 +911,123 @@ void DrawElementShifted(int x, int y, int dx, int dy, int element,int cut_mode) DrawGraphic(x,y, graphic); } +void DrawGraphicShiftedThruMask(int x,int y, int dx,int dy, int graphic, + 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 */ + redraw[redraw_x1 + x + SIGN(dx)][redraw_y1 + y] = TRUE; + + 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; + redraw[redraw_x1 + x][redraw_y1 + y + 1] = TRUE; + } /* 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 */ + redraw[redraw_x1 + x][redraw_y1 + y + SIGN(dy)] = TRUE; + } + + 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 + + redraw_tiles++; + redraw[redraw_x1 + x][redraw_y1 + y] = TRUE; + redraw_mask |= REDRAW_TILES; +} + void ErdreichAnbroeckeln(int x, int y) { int i, width, height, cx,cy; diff --git a/src/tools.h b/src/tools.h index 10dcaaef..2d31f211 100644 --- a/src/tools.h +++ b/src/tools.h @@ -71,6 +71,7 @@ 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 DrawGraphicShiftedThruMask(int, int, int, int, int, int); void ErdreichAnbroeckeln(int, int); void DrawScreenElement(int, int, int); void DrawLevelElement(int, int, int);