From 330d66f3f07fd38d91e0bafc46585a5723e15cf4 Mon Sep 17 00:00:00 2001 From: KikooDX Date: Sat, 2 Jan 2021 18:11:09 +0100 Subject: [PATCH] =?UTF-8?q?Horizontal=20solid=20clipping=20works=20=C2=AF\?= =?UTF-8?q?=5F(=E3=83=84)=5F/=C2=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/player.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/player.c b/src/player.c index 2a3740c..58ee7d0 100644 --- a/src/player.c +++ b/src/player.c @@ -17,10 +17,9 @@ #define JUMP_SPD (-128 * PXS) #define GRACE_UNITS (int)(UPS / 5) #define EARLY_UNITS (int)(UPS / 5) -#define H_CLIP_MARGIN (TILE_SIZE / 2) +#define H_CLIP_MARGIN (TILE_SIZE / 4) #define V_CLIP_MARGIN (TILE_SIZE / 3) #define SGN(x) (((x) > 0) ? (1) : (((x) < 0) ? (-1) : (0))) -#define ABS(x) (((x) > 0) ? (x) : (-(x))) #define PLAYER_COLLIDE(pos) player_collide(player, pos, level, level->solid_layer) void player_move(Player *player, const Level *level) { @@ -34,10 +33,7 @@ void player_move(Player *player, const Level *level) { if (PLAYER_COLLIDE(destination)) { /* Used for clipping and positionning. */ int offset = destination.y % TILE_SIZE; - if (offset > TILE_SIZE / 2) { - offset -= TILE_SIZE; - } - if (ABS(offset) > H_CLIP_MARGIN) { + if (offset > H_CLIP_MARGIN) { offset = 0; } destination.y -= offset;