X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=31bc2f526da3b26d602cee4b88c07186ed93d26d;hb=2d235297197dd0c325184f7fc401d9c5c41c2616;hp=eaf9ee12e8bb92dae1e76654a6dbbc120132c40b;hpb=5a2237add0a19d1559c0fe20c3f27651a71adf6c;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index eaf9ee12..31bc2f52 100644 --- a/src/game.c +++ b/src/game.c @@ -1062,12 +1062,12 @@ inline void DrawGameValue_Dynamite(int value) DrawText(DX_DYNAMITE, DY_DYNAMITE, int2str(value, 3), FONT_TEXT_2); } -inline void DrawGameValue_Keys(struct PlayerInfo *player) +inline void DrawGameValue_Keys(int key[4]) { int i; for (i = 0; i < MAX_KEYS; i++) - if (player->key[i]) + if (key[i]) DrawMiniGraphicExt(drawto, DX_KEYS + i * MINI_TILEX, DY_KEYS, el2edimg(EL_KEY_1 + i)); } @@ -1109,19 +1109,43 @@ inline void DrawGameValue_Level(int value) } } +void DrawAllGameValues(int emeralds, int dynamite, int score, int time, + int key_bits) +{ + int key[4]; + int i; + + for (i = 0; i < MAX_KEYS; i++) + key[i] = key_bits & (1 << i); + + DrawGameValue_Emeralds(emeralds); + DrawGameValue_Dynamite(dynamite); + DrawGameValue_Score(score); + DrawGameValue_Time(time); + + DrawGameValue_Keys(key); +} + void DrawGameDoorValues() { int i; - DrawGameValue_Level(level_nr); + if (level.game_engine_type == GAME_ENGINE_TYPE_EM) + { + DrawGameDoorValues_EM(); - for (i = 0; i < MAX_PLAYERS; i++) - DrawGameValue_Keys(&stored_player[i]); + return; + } + + DrawGameValue_Level(level_nr); DrawGameValue_Emeralds(local_player->gems_still_needed); DrawGameValue_Dynamite(local_player->inventory_size); DrawGameValue_Score(local_player->score); DrawGameValue_Time(TimeLeft); + + for (i = 0; i < MAX_PLAYERS; i++) + DrawGameValue_Keys(stored_player[i].key); } static void resolve_group_element(int group_element, int recursion_depth) @@ -1691,6 +1715,7 @@ void InitGame() #endif ZX = ZY = -1; + ExitX = ExitY = -1; FrameCounter = 0; TimeFrames = 0; @@ -2052,18 +2077,27 @@ void InitGame() CloseDoor(DOOR_CLOSE_1); - DrawLevel(); - DrawAllPlayers(); + /* !!! FIX THIS (START) !!! */ + if (level.game_engine_type == GAME_ENGINE_TYPE_EM) + { + InitGameEngine_EM(); + } + else + { + DrawLevel(); + DrawAllPlayers(); - /* after drawing the level, correct some elements */ - if (game.timegate_time_left == 0) - CloseAllOpenTimegates(); + /* after drawing the level, correct some elements */ + if (game.timegate_time_left == 0) + CloseAllOpenTimegates(); - if (setup.soft_scrolling) - BlitBitmap(fieldbuffer, backbuffer, FX, FY, SXSIZE, SYSIZE, SX, SY); + if (setup.soft_scrolling) + BlitBitmap(fieldbuffer, backbuffer, FX, FY, SXSIZE, SYSIZE, SX, SY); - redraw_mask |= REDRAW_FROM_BACKBUFFER; - FadeToFront(); + redraw_mask |= REDRAW_FROM_BACKBUFFER; + FadeToFront(); + } + /* !!! FIX THIS (END) !!! */ /* copy default game door content to main double buffer */ BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto, @@ -2104,6 +2138,15 @@ void InitGame() #endif } +void UpdateEngineValues(int actual_scroll_x, int actual_scroll_y) +{ + /* this is used for non-R'n'D game engines to update certain engine values */ + + /* needed to determine if sounds are played within the visible screen area */ + scroll_x = actual_scroll_x; + scroll_y = actual_scroll_y; +} + void InitMovDir(int x, int y) { int i, element = Feld[x][y]; @@ -2374,8 +2417,9 @@ void GameWon() } /* close exit door after last player */ - if ((Feld[ExitX][ExitY] == EL_EXIT_OPEN || - Feld[ExitX][ExitY] == EL_SP_EXIT_OPEN) && AllPlayersGone) + if (AllPlayersGone && ExitX >= 0 && ExitY >= 0 && + (Feld[ExitX][ExitY] == EL_EXIT_OPEN || + Feld[ExitX][ExitY] == EL_SP_EXIT_OPEN)) { int element = Feld[ExitX][ExitY]; @@ -2386,7 +2430,9 @@ void GameWon() } /* Hero disappears */ - DrawLevelField(ExitX, ExitY); + if (ExitX >= 0 && ExitY >= 0) + DrawLevelField(ExitX, ExitY); + BackToFront(); if (tape.playing) @@ -3108,8 +3154,15 @@ void Explode(int ex, int ey, int phase, int mode) return; #endif +#if 1 + if (mode == EX_TYPE_NORMAL || + mode == EX_TYPE_CENTER || + mode == EX_TYPE_CROSS) + PlayLevelSoundAction(ex, ey, ACTION_EXPLODING); +#else if (mode == EX_TYPE_NORMAL || mode == EX_TYPE_CENTER) PlayLevelSoundAction(ex, ey, ACTION_EXPLODING); +#endif /* remove things displayed in background while burning dynamite */ if (Back[ex][ey] != EL_EMPTY && !IS_INDESTRUCTIBLE(Back[ex][ey])) @@ -8512,8 +8565,8 @@ void AdvanceFrameAndPlayerCounters(int player_nr) void GameActions() { - static unsigned long action_delay = 0; - unsigned long action_delay_value; + static unsigned long game_frame_delay = 0; + unsigned long game_frame_delay_value; int magic_wall_x = 0, magic_wall_y = 0; int i, x, y, element, graphic; byte *recorded_player_action; @@ -8525,15 +8578,15 @@ void GameActions() if (game_status != GAME_MODE_PLAYING) return; - action_delay_value = + game_frame_delay_value = (tape.playing && tape.fast_forward ? FfwdFrameDelay : GameFrameDelay); if (tape.playing && tape.warp_forward && !tape.pausing) - action_delay_value = 0; + game_frame_delay_value = 0; /* ---------- main game synchronization point ---------- */ - WaitUntilDelayReached(&action_delay, action_delay_value); + WaitUntilDelayReached(&game_frame_delay, game_frame_delay_value); if (network_playing && !network_player_action_received) { @@ -8572,6 +8625,7 @@ void GameActions() recorded_player_action = (tape.playing ? TapePlayAction() : NULL); #if 1 + /* !!! CHECK THIS (tape.pausing is always FALSE here!) !!! */ if (recorded_player_action == NULL && tape.pausing) return; #endif @@ -11498,7 +11552,7 @@ int DigField(struct PlayerInfo *player, player->key[key_nr] = TRUE; - DrawGameValue_Keys(player); + DrawGameValue_Keys(player->key); redraw_mask |= REDRAW_DOOR_1; } @@ -12376,6 +12430,151 @@ static void PlayLevelMusic() PlayMusic(MAP_NOCONF_MUSIC(level_nr)); /* from music dir */ } +void PlayLevelSound_EM(int x, int y, int element_em, int sample) +{ + int element = (element_em > -1 ? map_element_EM_to_RND(element_em) : 0); + +#if 0 + if (sample == SAMPLE_bug) + printf("::: PlayLevelSound_EM: %d, %d: %d\n", x, y, sample); +#endif + + switch (sample) + { + case SAMPLE_blank: + PlayLevelSoundElementAction(x, y, element, ACTION_WALKING); + break; + + case SAMPLE_roll: + PlayLevelSoundElementAction(x, y, element, ACTION_PUSHING); + break; + + case SAMPLE_stone: + PlayLevelSoundElementAction(x, y, element, ACTION_IMPACT); + break; + + case SAMPLE_nut: + PlayLevelSoundElementAction(x, y, element, ACTION_IMPACT); + break; + + case SAMPLE_crack: + PlayLevelSoundElementAction(x, y, element, ACTION_BREAKING); + break; + + case SAMPLE_bug: + PlayLevelSoundElementAction(x, y, EL_BUG, ACTION_MOVING); + break; + + case SAMPLE_tank: + PlayLevelSoundElementAction(x, y, EL_SPACESHIP, ACTION_MOVING); + break; + + case SAMPLE_android: + PlayLevelSoundElementAction(x, y, element, ACTION_DROPPING); + break; + + case SAMPLE_spring: + PlayLevelSoundElementAction(x, y, element, ACTION_IMPACT); + break; + + case SAMPLE_slurp: + PlayLevelSoundElementAction(x, y, element, ACTION_SLURPED_BY_SPRING); + break; + + case SAMPLE_eater: + PlayLevelSoundElementAction(x, y, EL_YAMYAM, ACTION_WAITING); + break; + + case SAMPLE_alien: + PlayLevelSoundElementAction(x, y, element, ACTION_MOVING); + break; + + case SAMPLE_collect: + PlayLevelSoundElementAction(x, y, element, ACTION_COLLECTING); + break; + + case SAMPLE_diamond: + PlayLevelSoundElementAction(x, y, element, ACTION_IMPACT); + break; + + case SAMPLE_squash: + PlayLevelSoundElementAction(x, y, element, ACTION_SMASHED_BY_ROCK); + break; + + case SAMPLE_wonderfall: + PlayLevelSoundElementAction(x, y, EL_MAGIC_WALL, ACTION_FILLING); + break; + + case SAMPLE_drip: + PlayLevelSoundElementAction(x, y, element, ACTION_IMPACT); + break; + + case SAMPLE_push: + PlayLevelSoundElementAction(x, y, element, ACTION_PUSHING); + break; + + case SAMPLE_dirt: + PlayLevelSoundElementAction(x, y, element, ACTION_DIGGING); + break; + + case SAMPLE_acid: + PlayLevelSound(x, y, SND_ACID_SPLASHING); + break; + + case SAMPLE_ball: + PlayLevelSoundElementAction(x, y, element, ACTION_DROPPING); + break; + + case SAMPLE_grow: + PlayLevelSoundElementAction(x, y, element, ACTION_GROWING); + break; + + case SAMPLE_wonder: + PlayLevelSoundElementAction(x, y, element, ACTION_ACTIVE); + break; + + case SAMPLE_door: + PlayLevelSoundElementAction(x, y, element, ACTION_PASSING); + break; + + case SAMPLE_exit: + PlayLevelSoundElementAction(x, y, element, ACTION_PASSING); + break; + + case SAMPLE_dynamite: + PlayLevelSoundElementAction(x, y, element, ACTION_DROPPING); + break; + + case SAMPLE_tick: + PlayLevelSoundElementAction(x, y, element, ACTION_ACTIVE); + break; + + case SAMPLE_press: + PlayLevelSoundElementAction(x, y, element, ACTION_ACTIVATING); + break; + + case SAMPLE_wheel: + PlayLevelSound(x, y, SND_ROBOT_WHEEL_ACTIVE); + break; + + case SAMPLE_boom: + PlayLevelSoundElementAction(x, y, element, ACTION_EXPLODING); + break; + + case SAMPLE_time: + PlaySoundStereo(SND_GAME_RUNNING_OUT_OF_TIME, SOUND_MIDDLE); + break; + + case SAMPLE_die: + PlayLevelSoundElementAction(x, y, element, ACTION_DYING); + break; + + default: + PlayLevelSoundElementAction(x, y, element, ACTION_DEFAULT); + break; + } +} + void RaiseScore(int value) { local_player->score += value;