From d72ae21e98cef0a0c6e5adefa34153cf0bc149af Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 1 Dec 2020 21:18:01 +0100 Subject: [PATCH] fixed wrap-around with entering EM style door (gate) for EM engine --- src/game_em/graphics.c | 5 +++-- src/game_em/logic.c | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/game_em/graphics.c b/src/game_em/graphics.c index 7f303a2a..a29d2e0e 100644 --- a/src/game_em/graphics.c +++ b/src/game_em/graphics.c @@ -441,16 +441,17 @@ static void blitplayer(int nr) ply[nr].x > lev.right - 1) { struct PLAYER ply_last = ply[nr]; + int direction = (ply[nr].x < lev.left ? -1 : 1); int dx = ply[nr].x - ply[nr].prev_x; - ply[nr].x = (ply[nr].x < lev.left ? lev.right - 1 : lev.left); + ply[nr].x += -direction * lev.width; ply[nr].prev_x = ply[nr].x - dx; if (!lev.infinite_true) { int dy = ply[nr].y - ply[nr].prev_y; - ply[nr].y += (ply[nr].x == lev.left ? 1 : -1); + ply[nr].y += direction; ply[nr].prev_y = ply[nr].y - dy; } diff --git a/src/game_em/logic.c b/src/game_em/logic.c index bfb387f4..a56547b1 100644 --- a/src/game_em/logic.c +++ b/src/game_em/logic.c @@ -7695,10 +7695,12 @@ void logic_move(void) if (ply[i].x < lev.left || ply[i].x > lev.right - 1) { - ply[i].x = (ply[i].x < lev.left ? lev.right - 1 : lev.left); + int direction = (ply[i].x < lev.left ? -1 : 1); + + ply[i].x += -direction * lev.width; if (!lev.infinite_true) - ply[i].y += (ply[i].x == lev.left ? 1 : -1); + ply[i].y += direction; game.centered_player_nr_next = i; game.set_centered_player = TRUE; -- 2.34.1