X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=fada15db70f1733e76a78b67ac8cfdfea807e05f;hb=fd18ece8535cd87bd72989d7d39092d55b283939;hp=0bd65fdb476fe8b3c45d4b186275e070c661c44a;hpb=2a4878a4c2873df0426a22c357533656928748c8;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index 0bd65fdb..fada15db 100644 --- a/src/game.c +++ b/src/game.c @@ -91,6 +91,21 @@ #define SC_SCHLUESSEL 9 #define SC_ZEITBONUS 10 +/* game button identifiers */ +#define GAME_CTRL_ID_STOP 0 +#define GAME_CTRL_ID_PAUSE 1 +#define GAME_CTRL_ID_PLAY 2 +#define SOUND_CTRL_ID_MUSIC 3 +#define SOUND_CTRL_ID_LOOPS 4 +#define SOUND_CTRL_ID_SIMPLE 5 + +#define NUM_GAME_BUTTONS 6 + +/* forward declaration for internal use */ +static void MapGameButtons(); +static void HandleGameButtons(struct GadgetInfo *); + +static struct GadgetInfo *game_gadget[NUM_GAME_BUTTONS]; @@ -390,16 +405,8 @@ void InitGame() ScreenMovPos = 0; ScreenGfxPos = 0; - if (level.high_speed) - { - MoveSpeed = 4; - ScrollStepSize = TILEX/4; - } - else - { - MoveSpeed = 8; - ScrollStepSize = TILEX/8; - } + MoveSpeed = (level.double_speed ? 4 : 8); + ScrollStepSize = TILEX / MoveSpeed; AllPlayersGone = FALSE; SiebAktiv = FALSE; @@ -535,15 +542,40 @@ void InitGame() emulate_sb ? EMU_SOKOBAN : emulate_sp ? EMU_SUPAPLEX : EMU_NONE); - scroll_x = scroll_y = -1; - if (local_player->jx >= MIDPOSX-1) - scroll_x = (local_player->jx <= lev_fieldx-MIDPOSX ? + /* determine border element for this level */ + SetBorderElement(); + + if (BorderElement == EL_LEERRAUM) + { + SBX_Left = 0; + SBX_Right = lev_fieldx - SCR_FIELDX; + SBY_Upper = 0; + SBY_Lower = lev_fieldy - SCR_FIELDY; + } + else + { + SBX_Left = -1; + SBX_Right = lev_fieldx - SCR_FIELDX + 1; + SBY_Upper = -1; + SBY_Lower = lev_fieldy - SCR_FIELDY + 1; + } + + if (lev_fieldx + (SBX_Left == -1 ? 2 : 0) <= SCR_FIELDX) + SBX_Left = SBX_Right = -1 * (SCR_FIELDX - lev_fieldx) / 2; + + if (lev_fieldy + (SBY_Upper == -1 ? 2 : 0) <= SCR_FIELDY) + SBY_Upper = SBY_Lower = -1 * (SCR_FIELDY - lev_fieldy) / 2; + + scroll_x = SBX_Left; + scroll_y = SBY_Upper; + if (local_player->jx >= SBX_Left + MIDPOSX) + scroll_x = (local_player->jx <= SBX_Right + MIDPOSX ? local_player->jx - MIDPOSX : - lev_fieldx - SCR_FIELDX + 1); - if (local_player->jy >= MIDPOSY-1) - scroll_y = (local_player->jy <= lev_fieldy-MIDPOSY ? + SBX_Right); + if (local_player->jy >= SBY_Upper + MIDPOSY) + scroll_y = (local_player->jy <= SBY_Lower + MIDPOSY ? local_player->jy - MIDPOSY : - lev_fieldy - SCR_FIELDY + 1); + SBY_Lower); CloseDoor(DOOR_CLOSE_1); @@ -570,19 +602,33 @@ void InitGame() DOOR_GFX_PAGEX1 + XX_TIME, DOOR_GFX_PAGEY1 + YY_TIME, int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); + + +#if 0 DrawGameButton(BUTTON_GAME_STOP); DrawGameButton(BUTTON_GAME_PAUSE); DrawGameButton(BUTTON_GAME_PLAY); DrawSoundDisplay(BUTTON_SOUND_MUSIC | (setup.sound_music ? BUTTON_ON : 0)); DrawSoundDisplay(BUTTON_SOUND_LOOPS | (setup.sound_loops ? BUTTON_ON : 0)); DrawSoundDisplay(BUTTON_SOUND_SIMPLE | (setup.sound_simple ? BUTTON_ON : 0)); +#else + UnmapGameButtons(); + game_gadget[SOUND_CTRL_ID_MUSIC]->checked = setup.sound_music; + game_gadget[SOUND_CTRL_ID_LOOPS]->checked = setup.sound_loops; + game_gadget[SOUND_CTRL_ID_SIMPLE]->checked = setup.sound_simple; + MapGameButtons(); + MapTapeButtons(); +#endif + XCopyArea(display, drawto, pix[PIX_DB_DOOR], gc, DX + GAME_CONTROL_XPOS, DY + GAME_CONTROL_YPOS, GAME_CONTROL_XSIZE, 2 * GAME_CONTROL_YSIZE, DOOR_GFX_PAGEX1 + GAME_CONTROL_XPOS, DOOR_GFX_PAGEY1 + GAME_CONTROL_YPOS); - OpenDoor(DOOR_OPEN_1); + + + OpenDoor(DOOR_OPEN_ALL); if (setup.sound_music) PlaySoundLoop(background_loop[level_nr % num_bg_loops]); @@ -1030,6 +1076,7 @@ void Explode(int ex, int ey, int phase, int mode) int num_phase = 9, delay = 2; int last_phase = num_phase * delay; int half_phase = (num_phase / 2) * delay; + int first_phase_after_start = EX_PHASE_START + 1; if (phase == EX_PHASE_START) /* initialize 'Store[][]' field */ { @@ -1051,7 +1098,7 @@ void Explode(int ex, int ey, int phase, int mode) RemoveMovingField(x, y); } - if (!IN_LEV_FIELD(x, y) || IS_MASSIV(element) || element == EL_BURNING) + if (!IN_LEV_FIELD(x, y) || IS_MASSIVE(element) || element == EL_BURNING) continue; if ((mode!=EX_NORMAL || center_element == EL_AMOEBA2DIAM) && @@ -1144,9 +1191,20 @@ void Explode(int ex, int ey, int phase, int mode) x = ex; y = ey; - Frame[x][y] = (phaseMovDir == MV_LEFT && scroll_x > jx-MIDPOSX+offset) || - (player->MovDir == MV_RIGHT && scroll_x < jx-MIDPOSX-offset)) + if ((player->MovDir == MV_LEFT && scroll_x > jx - MIDPOSX + offset) || + (player->MovDir == MV_RIGHT && scroll_x < jx - MIDPOSX - offset)) scroll_x = jx-MIDPOSX + (scroll_x < jx-MIDPOSX ? -offset : +offset); /* don't scroll over playfield boundaries */ - if (scroll_x < -1 || scroll_x > lev_fieldx - SCR_FIELDX + 1) - scroll_x = (scroll_x < -1 ? -1 : lev_fieldx - SCR_FIELDX + 1); + if (scroll_x < SBX_Left || scroll_x > SBX_Right) + scroll_x = (scroll_x < SBX_Left ? SBX_Left : SBX_Right); /* don't scroll more than one field at a time */ scroll_x = old_scroll_x + SIGN(scroll_x - old_scroll_x); @@ -3889,13 +3947,13 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy) } else /* player has moved vertically */ { - if ((player->MovDir == MV_UP && scroll_y > jy-MIDPOSY+offset) || - (player->MovDir == MV_DOWN && scroll_y < jy-MIDPOSY-offset)) + if ((player->MovDir == MV_UP && scroll_y > jy - MIDPOSY + offset) || + (player->MovDir == MV_DOWN && scroll_y < jy - MIDPOSY - offset)) scroll_y = jy-MIDPOSY + (scroll_y < jy-MIDPOSY ? -offset : +offset); /* don't scroll over playfield boundaries */ - if (scroll_y < -1 || scroll_y > lev_fieldy - SCR_FIELDY + 1) - scroll_y = (scroll_y < -1 ? -1 : lev_fieldy - SCR_FIELDY + 1); + if (scroll_y < SBY_Upper || scroll_y > SBY_Lower) + scroll_y = (scroll_y < SBY_Upper ? SBY_Upper : SBY_Lower); /* don't scroll more than one field at a time */ scroll_y = old_scroll_y + SIGN(scroll_y - old_scroll_y); @@ -4775,3 +4833,237 @@ void RaiseScoreElement(int element) break; } } + +/* ---------- new game button stuff ---------------------------------------- */ + +/* graphic position values for game buttons */ +#define GAME_BUTTON_XSIZE 30 +#define GAME_BUTTON_YSIZE 30 +#define GAME_BUTTON_XPOS 5 +#define GAME_BUTTON_YPOS 215 +#define SOUND_BUTTON_XPOS 5 +#define SOUND_BUTTON_YPOS (GAME_BUTTON_YPOS + GAME_BUTTON_YSIZE) + +#define GAME_BUTTON_STOP_XPOS (GAME_BUTTON_XPOS + 0 * GAME_BUTTON_XSIZE) +#define GAME_BUTTON_PAUSE_XPOS (GAME_BUTTON_XPOS + 1 * GAME_BUTTON_XSIZE) +#define GAME_BUTTON_PLAY_XPOS (GAME_BUTTON_XPOS + 2 * GAME_BUTTON_XSIZE) +#define SOUND_BUTTON_MUSIC_XPOS (SOUND_BUTTON_XPOS + 0 * GAME_BUTTON_XSIZE) +#define SOUND_BUTTON_LOOPS_XPOS (SOUND_BUTTON_XPOS + 1 * GAME_BUTTON_XSIZE) +#define SOUND_BUTTON_SIMPLE_XPOS (SOUND_BUTTON_XPOS + 2 * GAME_BUTTON_XSIZE) + +static struct +{ + int x, y; + int gadget_id; + char *infotext; +} gamebutton_info[NUM_GAME_BUTTONS] = +{ + { + GAME_BUTTON_STOP_XPOS, GAME_BUTTON_YPOS, + GAME_CTRL_ID_STOP, + "stop game" + }, + { + GAME_BUTTON_PAUSE_XPOS, GAME_BUTTON_YPOS, + GAME_CTRL_ID_PAUSE, + "pause game" + }, + { + GAME_BUTTON_PLAY_XPOS, GAME_BUTTON_YPOS, + GAME_CTRL_ID_PLAY, + "play game" + }, + { + SOUND_BUTTON_MUSIC_XPOS, SOUND_BUTTON_YPOS, + SOUND_CTRL_ID_MUSIC, + "background music on/off" + }, + { + SOUND_BUTTON_LOOPS_XPOS, SOUND_BUTTON_YPOS, + SOUND_CTRL_ID_LOOPS, + "sound loops on/off" + }, + { + SOUND_BUTTON_SIMPLE_XPOS, SOUND_BUTTON_YPOS, + SOUND_CTRL_ID_SIMPLE, + "normal sounds on/off" + } +}; + +void CreateGameButtons() +{ + int i; + + for (i=0; icustom_id; + + if (game_status != PLAYING) + return; + + switch (id) + { + case GAME_CTRL_ID_STOP: + if (AllPlayersGone) + { + CloseDoor(DOOR_CLOSE_1); + game_status = MAINMENU; + DrawMainMenu(); + break; + } + + if (Request("Do you really want to quit the game ?", + REQ_ASK | REQ_STAY_CLOSED)) + { +#ifndef MSDOS + if (options.network) + SendToServer_StopPlaying(); + else +#endif + { + game_status = MAINMENU; + DrawMainMenu(); + } + } + else + OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK); + break; + + case GAME_CTRL_ID_PAUSE: + if (options.network) + { +#ifndef MSDOS + if (tape.pausing) + SendToServer_ContinuePlaying(); + else + SendToServer_PausePlaying(); +#endif + } + else + TapeTogglePause(); + break; + + case GAME_CTRL_ID_PLAY: + if (tape.pausing) + { +#ifndef MSDOS + if (options.network) + SendToServer_ContinuePlaying(); + else +#endif + { + tape.pausing = FALSE; + DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0); + } + } + break; + + case SOUND_CTRL_ID_MUSIC: + if (setup.sound_music) + { + setup.sound_music = FALSE; + FadeSound(background_loop[level_nr % num_bg_loops]); + } + else if (sound_loops_allowed) + { + setup.sound = setup.sound_music = TRUE; + PlaySoundLoop(background_loop[level_nr % num_bg_loops]); + } + break; + + case SOUND_CTRL_ID_LOOPS: + if (setup.sound_loops) + setup.sound_loops = FALSE; + else if (sound_loops_allowed) + setup.sound = setup.sound_loops = TRUE; + break; + + case SOUND_CTRL_ID_SIMPLE: + if (setup.sound_simple) + setup.sound_simple = FALSE; + else if (sound_status==SOUND_AVAILABLE) + setup.sound = setup.sound_simple = TRUE; + break; + + default: + break; + } +}