From: Holger Schemel Date: Sun, 14 Feb 1999 18:47:54 +0000 (+0100) Subject: rnd-19990214-3 X-Git-Tag: 1.4.0^2~45 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=c1d1d669f782d9af7dfa71159962d5a89c62f03b;p=rocksndiamonds.git rnd-19990214-3 --- diff --git a/src/editor.c b/src/editor.c index a2a9fbf1..a74d702c 100644 --- a/src/editor.c +++ b/src/editor.c @@ -247,12 +247,13 @@ #define GADGET_ID_RANDOM_QUANTITY 107 #define GADGET_ID_RANDOM_RESTRICTED 108 #define GADGET_ID_DOUBLE_SPEED 109 -#define GADGET_ID_STICK_ELEMENT 110 +#define GADGET_ID_GRAVITY 110 +#define GADGET_ID_STICK_ELEMENT 111 /* another drawing area for random placement */ -#define GADGET_ID_RANDOM_BACKGROUND 111 +#define GADGET_ID_RANDOM_BACKGROUND 112 -#define NUM_EDITOR_GADGETS 112 +#define NUM_EDITOR_GADGETS 113 /* radio button numbers */ #define RADIO_NR_NONE 0 @@ -301,10 +302,11 @@ /* values for checkbutton gadgets */ #define ED_CHECKBUTTON_ID_DOUBLE_SPEED 0 -#define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED 1 -#define ED_CHECKBUTTON_ID_STICK_ELEMENT 2 +#define ED_CHECKBUTTON_ID_GRAVITY 1 +#define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED 2 +#define ED_CHECKBUTTON_ID_STICK_ELEMENT 3 -#define ED_NUM_CHECKBUTTONS 3 +#define ED_NUM_CHECKBUTTONS 4 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_DOUBLE_SPEED #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED @@ -594,6 +596,12 @@ static struct &level.double_speed, "double speed movement", "set movement speed of player" }, + { + ED_SETTINGS_XPOS + 340, ED_COUNTER_YPOS(6) - MINI_TILEY, + GADGET_ID_GRAVITY, + &level.gravity, + "gravity", "set level gravity" + }, { ED_SETTINGS_XPOS, ED_COUNTER2_YPOS(9) - MINI_TILEY, GADGET_ID_RANDOM_RESTRICTED, @@ -3814,6 +3822,10 @@ static void HandleControlButtons(struct GadgetInfo *gi) *checkbutton_info[ED_CHECKBUTTON_ID_DOUBLE_SPEED].value ^= TRUE; break; + case GADGET_ID_GRAVITY: + *checkbutton_info[ED_CHECKBUTTON_ID_GRAVITY].value ^= TRUE; + break; + case GADGET_ID_STICK_ELEMENT: *checkbutton_info[ED_CHECKBUTTON_ID_STICK_ELEMENT].value ^= TRUE; break; diff --git a/src/game.c b/src/game.c index ea493de1..530345f5 100644 --- a/src/game.c +++ b/src/game.c @@ -102,6 +102,8 @@ #define NUM_GAME_BUTTONS 6 /* forward declaration for internal use */ +static void CheckGravityMovement(struct PlayerInfo *); + static void MapGameButtons(); static void HandleGameButtons(struct GadgetInfo *); @@ -3407,6 +3409,7 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) { DigField(player, 0, 0, 0, 0, DF_NO_PUSH); SnapField(player, 0, 0); + CheckGravityMovement(player); /* if (++player->frame_reset_delay > MoveSpeed) @@ -3568,6 +3571,7 @@ void GameActions() if (stored_player[i].programmed_action) { +#if 0 /* this is very bad and need to be fixed!!! */ unsigned long move_delay = stored_player[i].move_delay; @@ -3580,6 +3584,9 @@ void GameActions() actual_player_action = stored_player[i].programmed_action; stored_player[i].programmed_action = 0; } +#else + actual_player_action = stored_player[i].programmed_action; +#endif } if (recorded_player_action) @@ -3868,6 +3875,32 @@ void ScrollLevel(int dx, int dy) redraw_mask |= REDRAW_FIELD; } +static void CheckGravityMovement(struct PlayerInfo *player) +{ + if (level.gravity && !player->programmed_action) + { + int move_dir_vertical = player->action & (MV_UP | MV_DOWN); + int move_dir_horizontal = player->action & (MV_LEFT | MV_RIGHT); + int move_dir = + (player->last_move_dir & (MV_LEFT | MV_RIGHT) ? + (move_dir_vertical ? move_dir_vertical : move_dir_horizontal) : + (move_dir_horizontal ? move_dir_horizontal : move_dir_vertical)); + int jx = player->jx, jy = player->jy; + int dx = (move_dir & MV_LEFT ? -1 : move_dir & MV_RIGHT ? +1 : 0); + int dy = (move_dir & MV_UP ? -1 : move_dir & MV_DOWN ? +1 : 0); + int new_jx = jx + dx, new_jy = jy + dy; + boolean field_under_player_is_free = + (IN_LEV_FIELD(jx, jy + 1) && IS_FREE(jx, jy + 1)); + boolean player_is_moving_to_valid_field = + (IN_LEV_FIELD(new_jx, new_jy) && + (Feld[new_jx][new_jy] == EL_SP_BASE || + Feld[new_jx][new_jy] == EL_ERDREICH)); + + if (field_under_player_is_free && !player_is_moving_to_valid_field) + player->programmed_action = MV_DOWN; + } +} + boolean MoveFigureOneStep(struct PlayerInfo *player, int dx, int dy, int real_dx, int real_dy) { @@ -3953,6 +3986,9 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy) if (!FrameReached(&player->move_delay, player->move_speed) && !tape.playing) return FALSE; + /* remove the last programmed player action */ + player->programmed_action = 0; + if (player->MovPos) { /* should only happen if pre-1.2 tape recordings are played */ @@ -4093,7 +4129,11 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy) player->last_move_dir = player->MovDir; } else + { + CheckGravityMovement(player); + player->last_move_dir = MV_NO_MOVING; + } TestIfHeroHitsBadThing(jx, jy); @@ -4133,13 +4173,22 @@ void ScrollFigure(struct PlayerInfo *player, int mode) Feld[last_jx][last_jy] = EL_LEERRAUM; - /* +#if 0 if (!player->MovPos && level.gravity) { if (player->action == MV_NO_MOVING) player->programmed_action = MV_DOWN; + else if (player->action == MV_UP) + { + } + else if (player->action & (MV_LEFT | MV_RIGHT)) + { + } } - */ +#else + if (!player->MovPos) + CheckGravityMovement(player); +#endif DrawPlayer(player); @@ -5193,7 +5242,8 @@ static void HandleGameButtons(struct GadgetInfo *gi) break; } - if (Request("Do you really want to quit the game ?", + if (level_editor_test_game || + Request("Do you really want to quit the game ?", REQ_ASK | REQ_STAY_CLOSED)) { #ifndef MSDOS diff --git a/src/tools.c b/src/tools.c index 4c74046c..20a129bc 100644 --- a/src/tools.c +++ b/src/tools.c @@ -527,10 +527,12 @@ void DrawPlayer(struct PlayerInfo *player) if (game_emulation == EMU_SUPAPLEX) { static int last_dir = MV_LEFT; + int action = (player->programmed_action ? player->programmed_action : + player->action); boolean action_moving = (player_is_moving || - ((player->action & (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)) && - !(player->action & ~(MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)))); + ((action & (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)) && + !(action & ~(MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)))); graphic = GFX_SP_MURPHY;