#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
/* 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
&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,
*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;
#define NUM_GAME_BUTTONS 6
/* forward declaration for internal use */
+static void CheckGravityMovement(struct PlayerInfo *);
+
static void MapGameButtons();
static void HandleGameButtons(struct GadgetInfo *);
{
DigField(player, 0, 0, 0, 0, DF_NO_PUSH);
SnapField(player, 0, 0);
+ CheckGravityMovement(player);
/*
if (++player->frame_reset_delay > MoveSpeed)
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;
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)
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)
{
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 */
player->last_move_dir = player->MovDir;
}
else
+ {
+ CheckGravityMovement(player);
+
player->last_move_dir = MV_NO_MOVING;
+ }
TestIfHeroHitsBadThing(jx, jy);
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);
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