Horizontal solid clipping works ¯\_(ツ)_/¯

This commit is contained in:
KikooDX 2021-01-02 18:11:09 +01:00
parent 4818b21ec8
commit 330d66f3f0
1 changed files with 2 additions and 6 deletions

View File

@ -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;