if (element == EL_KAEFER || element == EL_BUTTERFLY)
{
- TestIfBadThingHitsOtherBadThing(x, y);
+ TestIfBadThingTouchesOtherBadThing(x, y);
if (IN_LEV_FIELD(right_x, right_y) &&
IS_FREE(right_x, right_y))
else if (element == EL_FLIEGER || element == EL_FIREFLY ||
element == EL_SP_SNIKSNAK || element == EL_SP_ELECTRON)
{
- TestIfBadThingHitsOtherBadThing(x, y);
+ TestIfBadThingTouchesOtherBadThing(x, y);
if (IN_LEV_FIELD(left_x, left_y) &&
IS_FREE(left_x, left_y))
{
#if 1
- TestIfBadThingHitsHero(x, y);
+ TestIfBadThingRunsIntoHero(x, y, MovDir[x][y]);
return;
#else
/* enemy got the player */
DrawGraphicAnimation(x, y, GFX2_SP_ELECTRON, 8, 2, ANIM_NORMAL);
if (DONT_TOUCH(element))
- TestIfBadThingHitsHero(x, y);
+ TestIfBadThingTouchesHero(x, y);
return;
}
if (DONT_TOUCH(element)) /* object may be nasty to player or others */
{
- TestIfBadThingHitsHero(newx, newy);
- TestIfBadThingHitsFriend(newx, newy);
- TestIfBadThingHitsOtherBadThing(newx, newy);
+ TestIfBadThingTouchesHero(newx, newy);
+ TestIfBadThingTouchesFriend(newx, newy);
+ TestIfBadThingTouchesOtherBadThing(newx, newy);
}
else if (element == EL_PINGUIN)
- TestIfFriendHitsBadThing(newx, newy);
+ TestIfFriendTouchesBadThing(newx, newy);
if (CAN_SMASH(element) && direction == MV_DOWN &&
(newy == lev_fieldy-1 || !IS_FREE(x, newy+1)))
SnapField(player, 0, 0);
CheckGravityMovement(player);
- player->last_move_dir = MV_NO_MOVING;
+ if (player->MovPos == 0) /* needed for tape.playing */
+ player->last_move_dir = MV_NO_MOVING;
if (++player->frame_reset_delay > player->move_delay_value)
player->Frame = 0;
BuryHero(player);
}
else
- TestIfBadThingHitsHero(new_jx, new_jy);
+ TestIfHeroRunsIntoBadThing(jx, jy, player->MovDir);
return MF_MOVING;
}
player->last_move_dir = MV_NO_MOVING;
}
- TestIfHeroHitsBadThing(jx, jy);
+ TestIfHeroTouchesBadThing(jx, jy);
if (!player->active)
RemoveHero(player);
ScreenMovDir = MV_NO_MOVING;
}
-void TestIfGoodThingHitsBadThing(int goodx, int goody)
+void TestIfGoodThingHitsBadThing(int goodx, int goody, int move_dir)
{
int i, killx = goodx, killy = goody;
static int xy[4][2] =
{ +1, 0 },
{ 0, +1 }
};
- static int harmless[4] =
+ static int xy_dir[4] =
{
MV_UP,
MV_LEFT,
element = MovingOrBlocked2ElementIfNotLeaving(x, y);
#endif
- if (DONT_TOUCH(element))
+ /* 1st case: good thing is moving towards DONT_GO_TO style bad thing;
+ 2nd case: DONT_TOUCH style bad thing does not move away from good thing
+ */
+ if ((DONT_GO_TO(element) && move_dir == xy_dir[i]) ||
+ (DONT_TOUCH(element) && MovDir[x][y] != xy_dir[i]))
{
- if (MovDir[x][y] == harmless[i])
- continue;
-
killx = x;
killy = y;
break;
}
}
-void TestIfBadThingHitsGoodThing(int badx, int bady)
+void TestIfBadThingHitsGoodThing(int badx, int bady, int move_dir)
{
int i, killx = badx, killy = bady;
+ int bad_element = Feld[badx][bady];
static int xy[4][2] =
{
{ 0, -1 },
{ +1, 0 },
{ 0, +1 }
};
- static int harmless[4] =
+ static int xy_dir[4] =
{
MV_UP,
MV_LEFT,
MV_DOWN
};
- if (Feld[badx][bady] == EL_EXPLODING) /* skip just exploding bad things */
+ if (bad_element == EL_EXPLODING) /* skip just exploding bad things */
return;
for (i=0; i<4; i++)
element = Feld[x][y];
- if (IS_PLAYER(x, y))
- {
- killx = x;
- killy = y;
- break;
- }
- else if (element == EL_PINGUIN)
+ /* 1st case: good thing is moving towards DONT_GO_TO style bad thing;
+ 2nd case: DONT_TOUCH style bad thing does not move away from good thing
+ */
+ if ((DONT_GO_TO(bad_element) && move_dir == xy_dir[i]) ||
+ (DONT_TOUCH(bad_element) && MovDir[x][y] != xy_dir[i]))
{
- if (MovDir[x][y] == harmless[i] && IS_MOVING(x, y))
- continue;
+ /* good thing is player or penguin that does not move away */
+ if (IS_PLAYER(x, y))
+ {
+ struct PlayerInfo *player = PLAYERINFO(x, y);
- killx = x;
- killy = y;
- break;
+ if (bad_element == EL_ROBOT && player->last_move_dir)
+ continue; /* robot does not kill player if he moves */
+
+ killx = x;
+ killy = y;
+ break;
+ }
+ else if (element == EL_PINGUIN &&
+ (MovDir[x][y] != xy_dir[i] || !IS_MOVING(x, y)))
+ {
+ killx = x;
+ killy = y;
+ break;
+ }
}
}
{
struct PlayerInfo *player = PLAYERINFO(killx, killy);
- if (Feld[badx][bady] == EL_ROBOT && player->last_move_dir)
+#if 0
+ int dir = player->MovDir;
+ int newx = player->jx + (dir == MV_LEFT ? -1 : dir == MV_RIGHT ? +1 : 0);
+ int newy = player->jy + (dir == MV_UP ? -1 : dir == MV_DOWN ? +1 : 0);
+
+ if (Feld[badx][bady] == EL_ROBOT && player->last_move_dir &&
+ newx != badx && newy != bady)
; /* robot does not kill player if he moves */
- else if (player->shield_active_time_left > 0)
+ else
+ printf("-> %d\n", player->MovDir);
+
+ if (Feld[badx][bady] == EL_ROBOT && player->last_move_dir &&
+ newx != badx && newy != bady)
+ ; /* robot does not kill player if he moves */
+ else
+ ;
+#endif
+
+ if (player->shield_active_time_left > 0)
Bang(badx, bady);
else if (!PLAYER_PROTECTED(killx, killy))
KillHero(player);
}
}
-void TestIfHeroHitsBadThing(int x, int y)
+void TestIfHeroTouchesBadThing(int x, int y)
+{
+ TestIfGoodThingHitsBadThing(x, y, MV_NO_MOVING);
+}
+
+void TestIfHeroRunsIntoBadThing(int x, int y, int move_dir)
+{
+ TestIfGoodThingHitsBadThing(x, y, move_dir);
+}
+
+void TestIfBadThingTouchesHero(int x, int y)
{
- TestIfGoodThingHitsBadThing(x, y);
+ TestIfBadThingHitsGoodThing(x, y, MV_NO_MOVING);
}
-void TestIfBadThingHitsHero(int x, int y)
+void TestIfBadThingRunsIntoHero(int x, int y, int move_dir)
{
- TestIfBadThingHitsGoodThing(x, y);
+ TestIfBadThingHitsGoodThing(x, y, move_dir);
}
-void TestIfFriendHitsBadThing(int x, int y)
+void TestIfFriendTouchesBadThing(int x, int y)
{
- TestIfGoodThingHitsBadThing(x, y);
+ TestIfGoodThingHitsBadThing(x, y, MV_NO_MOVING);
}
-void TestIfBadThingHitsFriend(int x, int y)
+void TestIfBadThingTouchesFriend(int x, int y)
{
- TestIfBadThingHitsGoodThing(x, y);
+ TestIfBadThingHitsGoodThing(x, y, MV_NO_MOVING);
}
-void TestIfBadThingHitsOtherBadThing(int badx, int bady)
+void TestIfBadThingTouchesOtherBadThing(int badx, int bady)
{
int i, killx = badx, killy = bady;
static int xy[4][2] =
void ScrollFigure(struct PlayerInfo *, int);
void ScrollScreen(struct PlayerInfo *, int);
-void TestIfGoodThingHitsBadThing(int, int);
-void TestIfBadThingHitsGoodThing(int, int);
-void TestIfHeroHitsBadThing(int, int);
-void TestIfBadThingHitsHero(int, int);
-void TestIfFriendHitsBadThing(int, int);
-void TestIfBadThingHitsFriend(int, int);
-void TestIfBadThingHitsOtherBadThing(int, int);
+void TestIfGoodThingHitsBadThing(int, int, int);
+void TestIfBadThingHitsGoodThing(int, int, int);
+void TestIfHeroTouchesBadThing(int, int);
+void TestIfHeroRunsIntoBadThing(int, int, int);
+void TestIfBadThingTouchesHero(int, int);
+void TestIfBadThingRunsIntoHero(int, int, int);
+void TestIfFriendTouchesBadThing(int, int);
+void TestIfBadThingTouchesFriend(int, int);
+void TestIfBadThingTouchesOtherBadThing(int, int);
void KillHero(struct PlayerInfo *);
void BuryHero(struct PlayerInfo *);
void RemoveHero(struct PlayerInfo *);