X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=811d103aa769b3c0019421b88590531f9520f9a6;hb=673c51c61ad415fbdb1a69148fa67dfbeb0afcae;hp=4e716e3e9cf894b0f5d36099f07aae4526c4fbd6;hpb=f7b1cff56121f72c25e1da08f53958ddab27ce75;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index 4e716e3e..811d103a 100644 --- a/src/game.c +++ b/src/game.c @@ -1,23 +1,22 @@ /*********************************************************** -* Rocks'n'Diamonds -- McDuffin Strikes Back! * +* Rocks'n'Diamonds -- McDuffin Strikes Back! * *----------------------------------------------------------* -* (c) 1995-98 Artsoft Entertainment * -* Holger Schemel * -* Oststrasse 11a * -* 33604 Bielefeld * -* phone: ++49 +521 290471 * -* email: aeglos@valinor.owl.de * +* (c) 1995-2001 Artsoft Entertainment * +* Holger Schemel * +* Detmolder Strasse 189 * +* 33604 Bielefeld * +* Germany * +* e-mail: info@artsoft.org * *----------------------------------------------------------* -* game.c * +* game.c * ***********************************************************/ +#include "libgame/libgame.h" + #include "game.h" -#include "misc.h" #include "tools.h" #include "screens.h" -#include "sound.h" #include "init.h" -#include "buttons.h" #include "files.h" #include "tape.h" #include "joystick.h" @@ -42,9 +41,10 @@ /* for Explode() */ #define EX_PHASE_START 0 -#define EX_NORMAL 0 -#define EX_CENTER 1 -#define EX_BORDER 2 +#define EX_NO_EXPLOSION 0 +#define EX_NORMAL 1 +#define EX_CENTER 2 +#define EX_BORDER 3 /* special positions in the game control window (relative to control window) */ #define XX_LEVEL 37 @@ -167,20 +167,21 @@ static unsigned int getStateCheckSum(int counter) void GetPlayerConfig() { - if (sound_status == SOUND_OFF) + if (!audio.sound_available) setup.sound = FALSE; - if (!sound_loops_allowed) + if (!audio.loops_available) { setup.sound_loops = FALSE; setup.sound_music = FALSE; } - if (!fullscreen_available) + if (!video.fullscreen_available) setup.fullscreen = FALSE; setup.sound_simple = setup.sound; + SetAudioMode(setup.sound); InitJoysticks(); } @@ -505,7 +506,7 @@ void InitGame() network_player_action_received = FALSE; -#if !defined(MSDOS) && !defined(WIN32) +#if defined(PLATFORM_UNIX) /* initial null action */ if (network_playing) SendToServer_MovePlayer(MV_NO_MOVING); @@ -513,7 +514,6 @@ void InitGame() ZX = ZY = -1; - game.yam_content_nr = 0; FrameCounter = 0; TimeFrames = 0; TimePlayed = 0; @@ -526,12 +526,15 @@ void InitGame() ScrollStepSize = 0; /* will be correctly initialized by ScrollScreen() */ AllPlayersGone = FALSE; + + game.yam_content_nr = 0; game.magic_wall_active = FALSE; game.magic_wall_time_left = 0; game.light_time_left = 0; game.timegate_time_left = 0; game.switchgate_pos = 0; game.balloon_dir = MV_NO_MOVING; + game.explosions_delayed = TRUE; for (i=0; i<4; i++) { @@ -553,6 +556,7 @@ void InitGame() AmoebaNr[x][y] = 0; JustStopped[x][y] = 0; Stop[x][y] = FALSE; + ExplodeField[x][y] = EX_NO_EXPLOSION; } } @@ -670,10 +674,33 @@ void InitGame() } } + game.version = (tape.playing ? tape.game_version : level.game_version); game.emulation = (emulate_bd ? EMU_BOULDERDASH : emulate_sb ? EMU_SOKOBAN : emulate_sp ? EMU_SUPAPLEX : EMU_NONE); + /* dynamically adjust element properties according to game engine version */ + { + static int ep_slippery[] = + { + EL_BETON, + EL_MAUERWERK, + EL_MAUER_LEBT, + EL_MAUER_X, + EL_MAUER_Y, + EL_MAUER_XY + }; + static int ep_slippery_num = sizeof(ep_slippery)/sizeof(int); + + for (i=0; i= GAME_VERSION_2_0) + Elementeigenschaften1[ep_slippery[i]] |= EP_BIT_SLIPPERY; + else + Elementeigenschaften1[ep_slippery[i]] &= ~EP_BIT_SLIPPERY; + } + } + if (BorderElement == EL_LEERRAUM) { SBX_Left = 0; @@ -712,8 +739,7 @@ void InitGame() DrawAllPlayers(); FadeToFront(); - /* after drawing the level, corect some elements */ - + /* after drawing the level, correct some elements */ if (game.timegate_time_left == 0) CloseAllOpenTimegates(); @@ -731,7 +757,7 @@ void InitGame() int2str(level_nr, 2), FS_SMALL, FC_YELLOW); else { - DrawTextExt(drawto, gc, DX + XX_EMERALDS, DY + YY_EMERALDS, + DrawTextExt(drawto, DX + XX_EMERALDS, DY + YY_EMERALDS, int2str(level_nr, 3), FS_SMALL, FC_SPECIAL3); BlitBitmap(drawto, drawto, DX + XX_EMERALDS, DY + YY_EMERALDS + 1, @@ -761,8 +787,8 @@ void InitGame() OpenDoor(DOOR_OPEN_ALL); - if (setup.sound_music) - PlaySoundLoop(background_loop[level_nr % num_bg_loops]); + if (setup.sound_music && num_bg_loops) + PlayMusic(level_nr % num_bg_loops); KeyboardAutoRepeatOff(); @@ -960,7 +986,9 @@ void GameWon() StopSound(SND_SIRR); } +#if 0 FadeSounds(); +#endif /* Hero disappears */ DrawLevelField(ExitX, ExitY); @@ -981,11 +1009,13 @@ void GameWon() { leveldir_current->handicap_level++; SaveLevelSetup_SeriesInfo(); - - if (level_nr < leveldir_current->last_level) - raise_level = TRUE; } + if (level_editor_test_game) + local_player->score = -1; /* no highscore when playing from editor */ + else if (level_nr < leveldir_current->last_level) + raise_level = TRUE; /* advance to next level */ + if ((hi_pos = NewHiScore()) >= 0) { game_status = HALLOFFAME; @@ -1170,17 +1200,16 @@ void RemoveMovingField(int x, int y) } if (Feld[x][y] == EL_BLOCKED && - (Store[oldx][oldy] == EL_MORAST_LEER || - Store[oldx][oldy] == EL_MAGIC_WALL_EMPTY || - Store[oldx][oldy] == EL_MAGIC_WALL_BD_EMPTY || - Store[oldx][oldy] == EL_AMOEBE_NASS)) - { - Feld[oldx][oldy] = Store[oldx][oldy]; - Store[oldx][oldy] = Store2[oldx][oldy] = 0; - } + (Feld[oldx][oldy] == EL_QUICKSAND_EMPTYING || + Feld[oldx][oldy] == EL_MAGIC_WALL_EMPTYING || + Feld[oldx][oldy] == EL_MAGIC_WALL_BD_EMPTYING || + Feld[oldx][oldy] == EL_AMOEBA_DRIPPING)) + Feld[oldx][oldy] = get_next_element(Feld[oldx][oldy]); else Feld[oldx][oldy] = EL_LEERRAUM; + Store[oldx][oldy] = Store2[oldx][oldy] = 0; + Feld[newx][newy] = EL_LEERRAUM; MovPos[oldx][oldy] = MovDir[oldx][oldy] = MovDelay[oldx][oldy] = 0; MovPos[newx][newy] = MovDir[newx][newy] = MovDelay[newx][newy] = 0; @@ -1254,6 +1283,12 @@ void Explode(int ex, int ey, int phase, int mode) int half_phase = (num_phase / 2) * delay; int first_phase_after_start = EX_PHASE_START + 1; + if (game.explosions_delayed) + { + ExplodeField[ex][ey] = mode; + return; + } + if (phase == EX_PHASE_START) /* initialize 'Store[][]' field */ { int center_element = Feld[ex][ey]; @@ -2428,8 +2463,8 @@ void StartMoving(int x, int y) if (IS_FREE(x, y+1)) { InitMovingField(x, y, MV_DOWN); - Feld[x][y] = EL_FELSBROCKEN; - Store[x][y] = EL_MORAST_LEER; + Feld[x][y] = EL_QUICKSAND_EMPTYING; + Store[x][y] = EL_FELSBROCKEN; } else if (Feld[x][y+1] == EL_MORAST_LEER) { @@ -2445,21 +2480,24 @@ void StartMoving(int x, int y) Feld[x][y] = EL_MORAST_LEER; Feld[x][y+1] = EL_MORAST_VOLL; + Store[x][y+1] = Store[x][y]; + Store[x][y] = 0; } } else if ((element == EL_FELSBROCKEN || element == EL_BD_ROCK) && Feld[x][y+1] == EL_MORAST_LEER) { InitMovingField(x, y, MV_DOWN); - Store[x][y] = EL_MORAST_VOLL; + Feld[x][y] = EL_QUICKSAND_FILLING; + Store[x][y] = element; } else if (element == EL_MAGIC_WALL_FULL) { if (IS_FREE(x, y+1)) { InitMovingField(x, y, MV_DOWN); - Feld[x][y] = EL_CHANGED(Store2[x][y]); - Store[x][y] = EL_MAGIC_WALL_EMPTY; + Feld[x][y] = EL_MAGIC_WALL_EMPTYING; + Store[x][y] = EL_CHANGED(Store[x][y]); } else if (Feld[x][y+1] == EL_MAGIC_WALL_EMPTY) { @@ -2475,8 +2513,8 @@ void StartMoving(int x, int y) Feld[x][y] = EL_MAGIC_WALL_EMPTY; Feld[x][y+1] = EL_MAGIC_WALL_FULL; - Store2[x][y+1] = EL_CHANGED(Store2[x][y]); - Store2[x][y] = 0; + Store[x][y+1] = EL_CHANGED(Store[x][y]); + Store[x][y] = 0; } } else if (element == EL_MAGIC_WALL_BD_FULL) @@ -2484,8 +2522,8 @@ void StartMoving(int x, int y) if (IS_FREE(x, y+1)) { InitMovingField(x, y, MV_DOWN); - Feld[x][y] = EL_CHANGED2(Store2[x][y]); - Store[x][y] = EL_MAGIC_WALL_BD_EMPTY; + Feld[x][y] = EL_MAGIC_WALL_BD_EMPTYING; + Store[x][y] = EL_CHANGED2(Store[x][y]); } else if (Feld[x][y+1] == EL_MAGIC_WALL_BD_EMPTY) { @@ -2501,8 +2539,8 @@ void StartMoving(int x, int y) Feld[x][y] = EL_MAGIC_WALL_BD_EMPTY; Feld[x][y+1] = EL_MAGIC_WALL_BD_FULL; - Store2[x][y+1] = EL_CHANGED2(Store2[x][y]); - Store2[x][y] = 0; + Store[x][y+1] = EL_CHANGED2(Store[x][y]); + Store[x][y] = 0; } } else if (CAN_CHANGE(element) && @@ -2510,10 +2548,10 @@ void StartMoving(int x, int y) Feld[x][y+1] == EL_MAGIC_WALL_BD_EMPTY)) { InitMovingField(x, y, MV_DOWN); - Store[x][y] = - (Feld[x][y+1] == EL_MAGIC_WALL_EMPTY ? EL_MAGIC_WALL_FULL : - EL_MAGIC_WALL_BD_FULL); - Store2[x][y+1] = element; + Feld[x][y] = + (Feld[x][y+1] == EL_MAGIC_WALL_EMPTY ? EL_MAGIC_WALL_FILLING : + EL_MAGIC_WALL_BD_FILLING); + Store[x][y] = element; } else if (CAN_SMASH(element) && Feld[x][y+1] == EL_SALZSAEURE) { @@ -2535,12 +2573,21 @@ void StartMoving(int x, int y) Feld[x][y] = EL_AMOEBING; Store[x][y] = EL_AMOEBE_NASS; } + /* Store[x][y+1] must be zero, because: + (EL_MORAST_VOLL -> EL_FELSBROCKEN): Store[x][y+1] == EL_MORAST_LEER + */ +#if 0 #if OLD_GAME_BEHAVIOUR else if (IS_SLIPPERY(Feld[x][y+1]) && !Store[x][y+1]) #else else if (IS_SLIPPERY(Feld[x][y+1]) && !Store[x][y+1] && !IS_FALLING(x, y+1) && !JustStopped[x][y+1] && element != EL_DX_SUPABOMB) +#endif +#else + else if (IS_SLIPPERY(Feld[x][y+1]) && + !IS_FALLING(x, y+1) && !JustStopped[x][y+1] && + element != EL_DX_SUPABOMB) #endif { boolean left = (x>0 && IS_FREE(x-1, y) && @@ -2897,10 +2944,16 @@ void ContinueMoving(int x, int y) int newx = x + dx, newy = y + dy; int step = (horiz_move ? dx : dy) * TILEX / 8; - if (element == EL_TROPFEN) + if (element == EL_TROPFEN || element == EL_AMOEBA_DRIPPING) step /= 2; - else if (Store[x][y] == EL_MORAST_VOLL || Store[x][y] == EL_MORAST_LEER) + else if (element == EL_QUICKSAND_FILLING || + element == EL_QUICKSAND_EMPTYING) step /= 4; + else if (element == EL_MAGIC_WALL_FILLING || + element == EL_MAGIC_WALL_BD_FILLING || + element == EL_MAGIC_WALL_EMPTYING || + element == EL_MAGIC_WALL_BD_EMPTYING) + step /= 2; else if (CAN_FALL(element) && horiz_move && y < lev_fieldy-1 && IS_BELT(Feld[x][y+1])) step /= 2; @@ -2945,54 +2998,55 @@ void ContinueMoving(int x, int y) } } - if (Store[x][y] == EL_MORAST_VOLL) + if (element == EL_QUICKSAND_FILLING) { - Store[x][y] = 0; - Feld[newx][newy] = EL_MORAST_VOLL; - element = EL_MORAST_VOLL; + element = Feld[newx][newy] = get_next_element(element); + Store[newx][newy] = Store[x][y]; } - else if (Store[x][y] == EL_MORAST_LEER) + else if (element == EL_QUICKSAND_EMPTYING) { - Store[x][y] = 0; - Feld[x][y] = EL_MORAST_LEER; + Feld[x][y] = get_next_element(element); + element = Feld[newx][newy] = Store[x][y]; } - else if (Store[x][y] == EL_MAGIC_WALL_FULL) + else if (element == EL_MAGIC_WALL_FILLING) { - Store[x][y] = 0; - element = Feld[newx][newy] = - (game.magic_wall_active ? EL_MAGIC_WALL_FULL : EL_MAGIC_WALL_DEAD); + element = Feld[newx][newy] = get_next_element(element); + if (!game.magic_wall_active) + element = Feld[newx][newy] = EL_MAGIC_WALL_DEAD; + Store[newx][newy] = Store[x][y]; } - else if (Store[x][y] == EL_MAGIC_WALL_EMPTY) + else if (element == EL_MAGIC_WALL_EMPTYING) { - Store[x][y] = Store2[x][y] = 0; - Feld[x][y] = (game.magic_wall_active ? EL_MAGIC_WALL_EMPTY : - EL_MAGIC_WALL_DEAD); + Feld[x][y] = get_next_element(element); + if (!game.magic_wall_active) + Feld[x][y] = EL_MAGIC_WALL_DEAD; + element = Feld[newx][newy] = Store[x][y]; } - else if (Store[x][y] == EL_MAGIC_WALL_BD_FULL) + else if (element == EL_MAGIC_WALL_BD_FILLING) { - Store[x][y] = 0; - element = Feld[newx][newy] = - (game.magic_wall_active ? EL_MAGIC_WALL_BD_FULL : - EL_MAGIC_WALL_BD_DEAD); + element = Feld[newx][newy] = get_next_element(element); + if (!game.magic_wall_active) + element = Feld[newx][newy] = EL_MAGIC_WALL_BD_DEAD; + Store[newx][newy] = Store[x][y]; } - else if (Store[x][y] == EL_MAGIC_WALL_BD_EMPTY) + else if (element == EL_MAGIC_WALL_BD_EMPTYING) { - Store[x][y] = Store2[x][y] = 0; - Feld[x][y] = (game.magic_wall_active ? EL_MAGIC_WALL_BD_EMPTY : - EL_MAGIC_WALL_BD_DEAD); + Feld[x][y] = get_next_element(element); + if (!game.magic_wall_active) + Feld[x][y] = EL_MAGIC_WALL_BD_DEAD; + element = Feld[newx][newy] = Store[x][y]; } - else if (Store[x][y] == EL_SALZSAEURE) + else if (element == EL_AMOEBA_DRIPPING) { - Store[x][y] = 0; - Feld[newx][newy] = EL_SALZSAEURE; - element = EL_SALZSAEURE; + Feld[x][y] = get_next_element(element); + element = Feld[newx][newy] = Store[x][y]; } - else if (Store[x][y] == EL_AMOEBE_NASS) + else if (Store[x][y] == EL_SALZSAEURE) { - Store[x][y] = 0; - Feld[x][y] = EL_AMOEBE_NASS; + element = Feld[newx][newy] = EL_SALZSAEURE; } + Store[x][y] = 0; MovPos[x][y] = MovDir[x][y] = MovDelay[x][y] = 0; MovDelay[newx][newy] = 0; @@ -3390,8 +3444,8 @@ void AmoebeAbleger(int ax, int ay) else { InitMovingField(ax, ay, MV_DOWN); - Feld[ax][ay] = EL_TROPFEN; - Store[ax][ay] = EL_AMOEBE_NASS; + Feld[ax][ay] = EL_AMOEBA_DRIPPING; + Store[ax][ay] = EL_TROPFEN; ContinueMoving(ax, ay); return; } @@ -4243,7 +4297,7 @@ void GameActions() #endif */ -#if !defined(MSDOS) && !defined(WIN32) +#if defined(PLATFORM_UNIX) /* last chance to get network player actions without main loop delay */ HandleNetworking(); #endif @@ -4280,7 +4334,7 @@ void GameActions() stored_player[i].effective_action = stored_player[i].action; } -#if !defined(MSDOS) && !defined(WIN32) +#if defined(PLATFORM_UNIX) if (network_playing) SendToServer_MovePlayer(summarized_player_action); #endif @@ -4373,7 +4427,7 @@ void GameActions() ContinueMoving(x, y); else if (IS_ACTIVE_BOMB(element)) CheckDynamite(x, y); - else if (element == EL_EXPLODING) + else if (element == EL_EXPLODING && !game.explosions_delayed) Explode(x, y, Frame[x][y], EX_NORMAL); else if (element == EL_AMOEBING) AmoebeWaechst(x, y); @@ -4440,15 +4494,16 @@ void GameActions() boolean sieb = FALSE; int jx = local_player->jx, jy = local_player->jy; - if (element == EL_MAGIC_WALL_EMPTY || element == EL_MAGIC_WALL_FULL || - Store[x][y] == EL_MAGIC_WALL_EMPTY) + if (element == EL_MAGIC_WALL_FULL || + element == EL_MAGIC_WALL_EMPTY || + element == EL_MAGIC_WALL_EMPTYING) { SiebAktivieren(x, y, 1); sieb = TRUE; } - else if (element == EL_MAGIC_WALL_BD_EMPTY || - element == EL_MAGIC_WALL_BD_FULL || - Store[x][y] == EL_MAGIC_WALL_BD_EMPTY) + else if (element == EL_MAGIC_WALL_BD_FULL || + element == EL_MAGIC_WALL_BD_EMPTY || + element == EL_MAGIC_WALL_BD_EMPTYING) { SiebAktivieren(x, y, 2); sieb = TRUE; @@ -4463,6 +4518,22 @@ void GameActions() } } + if (game.explosions_delayed) + { + game.explosions_delayed = FALSE; + + for (y=0; y= 500) /* calculate fps every 0.5 seconds */ + { + global.frames_per_second = 1000 * (float)fps_frames / fps_delay_ms; + + fps_frames = 0; + fps_counter = Counter(); + } + + redraw_mask |= REDRAW_FPS; + } } static boolean AllPlayersInSight(struct PlayerInfo *player, int x, int y) @@ -5384,12 +5475,10 @@ int DigField(struct PlayerInfo *player, RemoveField(x, y); player->key[key_nr] = TRUE; RaiseScoreElement(EL_SCHLUESSEL); - DrawMiniGraphicExt(drawto, gc, - DX_KEYS+key_nr*MINI_TILEX, DY_KEYS, - GFX_SCHLUESSEL1+key_nr); - DrawMiniGraphicExt(window, gc, - DX_KEYS+key_nr*MINI_TILEX, DY_KEYS, - GFX_SCHLUESSEL1+key_nr); + DrawMiniGraphicExt(drawto, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS, + GFX_SCHLUESSEL1 + key_nr); + DrawMiniGraphicExt(window, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS, + GFX_SCHLUESSEL1 + key_nr); PlaySoundLevel(x, y, SND_PONG); break; } @@ -5404,12 +5493,10 @@ int DigField(struct PlayerInfo *player, RemoveField(x, y); player->key[key_nr] = TRUE; RaiseScoreElement(EL_SCHLUESSEL); - DrawMiniGraphicExt(drawto, gc, - DX_KEYS+key_nr*MINI_TILEX, DY_KEYS, - GFX_SCHLUESSEL1+key_nr); - DrawMiniGraphicExt(window, gc, - DX_KEYS+key_nr*MINI_TILEX, DY_KEYS, - GFX_SCHLUESSEL1+key_nr); + DrawMiniGraphicExt(drawto, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS, + GFX_SCHLUESSEL1 + key_nr); + DrawMiniGraphicExt(window, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS, + GFX_SCHLUESSEL1 + key_nr); PlaySoundLevel(x, y, SND_PONG); break; } @@ -5931,7 +6018,7 @@ void PlaySoundLevel(int x, int y, int sound_nr) volume = PSND_MAX_VOLUME; -#ifndef MSDOS +#if !defined(PLATFORM_MSDOS) stereo = (sx - SCR_FIELDX/2) * 12; #else stereo = PSND_MIDDLE + (2 * sx - (SCR_FIELDX - 1)) * 5; @@ -6067,7 +6154,7 @@ void CreateGameButtons() for (i=0; i