From: Holger Schemel Date: Sat, 11 Jan 2003 13:56:46 +0000 (+0100) Subject: rnd-20030111-1-src X-Git-Tag: 3.0.0^2~181 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=a2f9307de12b6111ff7076fed2e4140619f1ac5d rnd-20030111-1-src --- diff --git a/src/conf_e2g.c b/src/conf_e2g.c index 795d21ef..49948d34 100644 --- a/src/conf_e2g.c +++ b/src/conf_e2g.c @@ -561,7 +561,7 @@ element_to_graphic[] = IMG_NUT_MOVING_RIGHT }, { - EL_NUT_CRACKING, -1, GFX_ACTION_CRACKING, + EL_NUT_CRACKING, -1, -1, IMG_NUT_CRACKING }, { @@ -749,7 +749,7 @@ element_to_graphic[] = IMG_AMOEBA_CREATING }, { - EL_AMOEBA_SHRINKING, -1, GFX_ACTION_SHRINKING, + EL_AMOEBA_SHRINKING, -1, -1, IMG_AMOEBA_SHRINKING }, { @@ -885,7 +885,7 @@ element_to_graphic[] = IMG_EXIT_CLOSED }, { - EL_EXIT_OPENING, -1, GFX_ACTION_OPENING, + EL_EXIT_OPENING, -1, -1, IMG_EXIT_OPENING }, { @@ -1213,7 +1213,7 @@ element_to_graphic[] = IMG_SWITCHGATE_CLOSED }, { - EL_SWITCHGATE_OPENING, -1, GFX_ACTION_OPENING, + EL_SWITCHGATE_OPENING, -1, -1, IMG_SWITCHGATE_OPENING }, { @@ -1221,7 +1221,7 @@ element_to_graphic[] = IMG_SWITCHGATE_OPEN }, { - EL_SWITCHGATE_CLOSING, -1, GFX_ACTION_CLOSING, + EL_SWITCHGATE_CLOSING, -1, -1, IMG_SWITCHGATE_CLOSING }, { @@ -1229,7 +1229,7 @@ element_to_graphic[] = IMG_TIMEGATE_CLOSED }, { - EL_TIMEGATE_OPENING, -1, GFX_ACTION_OPENING, + EL_TIMEGATE_OPENING, -1, -1, IMG_TIMEGATE_OPENING }, { @@ -1237,7 +1237,7 @@ element_to_graphic[] = IMG_TIMEGATE_OPEN }, { - EL_TIMEGATE_CLOSING, -1, GFX_ACTION_CLOSING, + EL_TIMEGATE_CLOSING, -1, -1, IMG_TIMEGATE_CLOSING }, { @@ -1245,7 +1245,7 @@ element_to_graphic[] = IMG_PEARL }, { - EL_PEARL_BREAKING, -1, GFX_ACTION_BREAKING, + EL_PEARL_BREAKING, -1, -1, IMG_PEARL_BREAKING }, { diff --git a/src/conftime.h b/src/conftime.h index ec1581b4..5d6ab7f2 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-01-10 20:34]" +#define COMPILE_DATE_STRING "[2003-01-11 14:56]" diff --git a/src/editor.c b/src/editor.c index 3682bbd0..c1a03a7c 100644 --- a/src/editor.c +++ b/src/editor.c @@ -2650,7 +2650,7 @@ static void PickDrawingElement(int button, int element) static void DrawDrawingWindow() { - SetMainBackgroundImage(IMG_NONE); + SetMainBackgroundImage(IMG_UNDEFINED); ClearWindow(); UnmapLevelEditorWindowGadgets(); @@ -2956,7 +2956,7 @@ static void DrawPropertiesWindow() DrawGraphicAnimationExt(drawto, SX + xstart * MINI_TILEX, SY + ystart * MINI_TILEY + MINI_TILEY / 2, - el2img(properties_element), NO_MASKING); + el2img(properties_element), -1, NO_MASKING); FrameCounter = 0; /* restart animation frame counter */ @@ -4347,7 +4347,7 @@ void HandleLevelEditorIdle() DrawGraphicAnimationExt(drawto, SX + xpos * TILEX, SY + ypos * TILEY + MINI_TILEY / 2, - el2img(properties_element), NO_MASKING); + el2img(properties_element), -1, NO_MASKING); #else DrawGraphicAnimationExt(drawto, @@ -4355,7 +4355,7 @@ void HandleLevelEditorIdle() SY + ypos * TILEY + MINI_TILEY / 2, el_dir_act2img(properties_element, MV_NO_MOVING, - ...)); + ...), -1, NO_MASKING); #endif MarkTileDirty(xpos, ypos); diff --git a/src/game.c b/src/game.c index 3b52b068..095f635e 100644 --- a/src/game.c +++ b/src/game.c @@ -114,6 +114,11 @@ static void HandleGameButtons(struct GadgetInfo *); static struct GadgetInfo *game_gadget[NUM_GAME_BUTTONS]; + +/* ------------------------------------------------------------------------- */ +/* sound definitions */ +/* ------------------------------------------------------------------------- */ + #define SND_ACTION_UNKNOWN 0 #define SND_ACTION_WAITING 1 #define SND_ACTION_MOVING 2 @@ -157,6 +162,32 @@ static boolean is_loop_sound[NUM_SOUND_FILES]; #define IS_LOOP_SOUND(x) (is_loop_sound[x]) +/* ------------------------------------------------------------------------- + definition of elements that automatically change to other elements after + a specified time, eventually calling a function when changing + ------------------------------------------------------------------------- */ + +struct ChangingElementInfo +{ + int base_element; + int next_element; + int change_delay; + void (*changer_function)(int x, int y); +}; + +static struct ChangingElementInfo changing_element_list[] = +{ + { EL_NUT_CRACKING, EL_EMERALD, 6, NULL }, + { EL_PEARL_BREAKING, EL_EMPTY, 8, NULL }, + { EL_UNDEFINED, EL_UNDEFINED, -1, NULL } +}; + +static struct ChangingElementInfo changing_element[MAX_NUM_ELEMENTS]; + +#define IS_AUTO_CHANGING(e) (changing_element[e].base_element != EL_UNDEFINED) + + + #ifdef DEBUG #if 0 static unsigned int getStateCheckSum(int counter) @@ -518,6 +549,7 @@ void InitGameSound() debug_print_timestamp(0, NULL); #endif + /* initialize sound effect for all elements to "no sound" */ for (i=0; i VERSION_IDENT(2,0,1)) - Elementeigenschaften2[EL_WALL_GROWING_ACTIVE] |= EP_BIT_EM_SLIPPERY_WALL; + Properties2[EL_WALL_GROWING_ACTIVE] |= EP_BIT_EM_SLIPPERY_WALL; else - Elementeigenschaften2[EL_WALL_GROWING_ACTIVE] &=~EP_BIT_EM_SLIPPERY_WALL; + Properties2[EL_WALL_GROWING_ACTIVE] &=~EP_BIT_EM_SLIPPERY_WALL; + } + + /* initialize changing elements information */ + for (i=0; ibase_element; + + changing_element[element].base_element = ce->base_element; + changing_element[element].next_element = ce->next_element; + changing_element[element].change_delay = ce->change_delay; + changing_element[element].changer_function = ce->changer_function; + + i++; } } @@ -3095,7 +3150,7 @@ void StartMoving(int x, int y) } } else if (element == EL_SP_ELECTRON) - DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_SP_ELECTRON); + DrawLevelElementAnimation(x, y, element); else if (element == EL_DRAGON) { int i; @@ -3353,11 +3408,11 @@ void StartMoving(int x, int y) element == EL_SP_SNIKSNAK || element == EL_MOLE) DrawLevelField(x, y); else if (element == EL_BD_BUTTERFLY || element == EL_BD_FIREFLY) - DrawGraphicAnimation(SCREENX(x), SCREENY(y), el2img(element)); + DrawLevelElementAnimation(x, y, element); else if (element == EL_SATELLITE) - DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_SATELLITE); + DrawLevelElementAnimation(x, y, element); else if (element == EL_SP_ELECTRON) - DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_SP_ELECTRON); + DrawLevelElementAnimation(x, y, element); if (DONT_TOUCH(element)) TestIfBadThingTouchesHero(x, y); @@ -4132,7 +4187,7 @@ void SiebAktivieren(int x, int y, int type) { int graphic = (type == 1 ? IMG_MAGIC_WALL_FULL : IMG_BD_MAGIC_WALL_FULL); - DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic); + DrawLevelGraphicAnimation(x, y, graphic); } void AusgangstuerPruefen(int x, int y) @@ -4343,7 +4398,7 @@ void EdelsteinFunkeln(int x, int y) return; if (Feld[x][y] == EL_BD_DIAMOND) - DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_BD_DIAMOND); + DrawLevelElementAnimation(x, y, el2img(Feld[x][y])); else { if (!MovDelay[x][y]) /* next animation frame */ @@ -4359,7 +4414,7 @@ void EdelsteinFunkeln(int x, int y) #if 0 DrawGraphic(SCREENX(x), SCREENY(y), el2img(Feld[x][y]), 0); #else - DrawGraphicAnimation(SCREENX(x), SCREENY(y), el2img(Feld[x][y])); + DrawLevelElementAnimation(x, y, Feld[x][y]); #endif if (MovDelay[x][y]) @@ -4712,15 +4767,43 @@ static void DrawBeltAnimation(int x, int y, int element) if (belt_dir != MV_NO_MOVING) { - int graphic = el2img(element); - - DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic); + DrawLevelElementAnimation(x, y, element); if (!(FrameCounter % 2)) - PlaySoundLevel(x, y, SND_CONVEYOR_BELT_ACTIVE); + PlaySoundLevelAction(x, y, SND_ACTION_ACTIVE); } } +static void ChangeElement(int x, int y) +{ + int element = Feld[x][y]; + int change_delay = changing_element[element].change_delay; + + if (!MovDelay[x][y]) /* next animation frame */ + { + MovDelay[x][y] = change_delay + 1; + GfxFrame[x][y] = 0; + } + + if (MovDelay[x][y]) /* wait some time before next frame */ + { + MovDelay[x][y]--; + + if (MovDelay[x][y]) + { + DrawLevelElementAnimation(x, y, element); + + return; + } + } + + Feld[x][y] = changing_element[element].next_element; + DrawLevelField(x, y); + + if (changing_element[element].changer_function) + changing_element[element].changer_function(x, y); +} + static void PlayerActions(struct PlayerInfo *player, byte player_action) { static byte stored_player_action[MAX_PLAYERS]; @@ -5009,7 +5092,7 @@ void GameActions() #if 1 if (new_graphic_info[graphic].anim_frames > 1) - DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic); + DrawLevelGraphicAnimation(x, y, graphic); #endif continue; @@ -5023,7 +5106,7 @@ void GameActions() if (Feld[x][y] == EL_EMERALD && new_graphic_info[graphic].anim_frames > 1 && !IS_MOVING(x, y)) - DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic); + DrawLevelGraphicAnimation(x, y, graphic); #endif if (IS_GEM(element) || element == EL_SP_INFOTRON) @@ -5040,7 +5123,7 @@ void GameActions() element == EL_SHIELD_NORMAL || element == EL_SHIELD_DEADLY) && new_graphic_info[graphic].anim_frames > 1) - DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic); + DrawLevelGraphicAnimation(x, y, graphic); #endif else if (IS_MOVING(x, y)) @@ -5070,10 +5153,12 @@ void GameActions() else if (element == EL_ACID_SPLASH_LEFT || element == EL_ACID_SPLASH_RIGHT) Blurb(x, y); +#if 0 else if (element == EL_NUT_CRACKING) NussKnacken(x, y); else if (element == EL_PEARL_BREAKING) BreakingPearl(x, y); +#endif else if (element == EL_EXIT_CLOSED) AusgangstuerPruefen(x, y); else if (element == EL_SP_EXIT_CLOSED) @@ -5093,8 +5178,10 @@ void GameActions() CheckBuggyBase(x, y); else if (element == EL_TRAP || element == EL_TRAP_ACTIVE) CheckTrap(x, y); +#if 0 else if (IS_BELT_ACTIVE(element)) DrawBeltAnimation(x, y, element); +#endif else if (element == EL_SWITCHGATE_OPENING) OpenSwitchgate(x, y); else if (element == EL_SWITCHGATE_CLOSING) @@ -5104,11 +5191,17 @@ void GameActions() else if (element == EL_TIMEGATE_CLOSING) CloseTimegate(x, y); + else if (IS_AUTO_CHANGING(element)) + ChangeElement(x, y); + #if 1 else if (new_graphic_info[graphic].anim_frames > 1) - DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic); + DrawLevelGraphicAnimation(x, y, graphic); #endif + if (IS_BELT_ACTIVE(element)) + PlaySoundLevelAction(x, y, SND_ACTION_ACTIVE); + if (game.magic_wall_active) { boolean sieb = FALSE; diff --git a/src/init.c b/src/init.c index ce1e9298..6a2777fd 100644 --- a/src/init.c +++ b/src/init.c @@ -254,6 +254,7 @@ static void InitSound() static void InitTileClipmasks() { +#if 0 #if defined(TARGET_X11) XGCValues clip_gc_values; unsigned long clip_gc_valuemask; @@ -388,10 +389,12 @@ static void InitTileClipmasks() #endif /* TARGET_X11_NATIVE */ #endif /* TARGET_X11 */ +#endif } void FreeTileClipmasks() { +#if 0 #if defined(TARGET_X11) int i; @@ -420,6 +423,7 @@ void FreeTileClipmasks() #endif #endif /* TARGET_X11 */ +#endif } void InitGfx() @@ -689,7 +693,7 @@ void InitElementInfo() int i, act, dir; /* set values to -1 to identify later as "uninitialized" values */ - for (i=0; i=BX1 && (x)<=BX2 && (y)>=BY1 &&(y)<=BY2) #define IN_LEV_FIELD(x,y) ((x)>=0 && (x)=0 &&(y)= MAX_ELEMENTS) + if (element >= MAX_NUM_ELEMENTS) { - Error(ERR_WARN, "el2gfx: element == %d >= MAX_ELEMENTS", element); + Error(ERR_WARN, "el2gfx: element == %d >= MAX_NUM_ELEMENTS", element); } if (graphic_NEW != graphic_OLD) diff --git a/src/tools.h b/src/tools.h index 7b328f21..629593df 100644 --- a/src/tools.h +++ b/src/tools.h @@ -74,8 +74,10 @@ void DrawAllPlayers(void); void DrawPlayerField(int, int); void DrawPlayer(struct PlayerInfo *); int getGraphicAnimationFrame(int, int); +void DrawGraphicAnimationExt(DrawBuffer *, int, int, int, int, int); void DrawGraphicAnimation(int, int, int); -void DrawGraphicAnimationExt(DrawBuffer *, int, int, int, int); +void DrawLevelGraphicAnimation(int, int, int); +void DrawLevelElementAnimation(int, int, int); void getGraphicSource(int, int, Bitmap **, int *, int *); void DrawGraphic(int, int, int, int); #if 0