Replicated collision bug from the original codebase.

This was achieved for complete "feature parity".
This commit is contained in:
KikooDX 2021-03-06 00:15:32 +01:00
parent a2d7050139
commit f7ce3f9765
1 changed files with 5 additions and 2 deletions

View File

@ -142,10 +142,13 @@ void player_draw(Player player, i16 y_offset) {
/* Helper functions */
bool player_collide(Level level, Vec2 pos, tile_t tile, u8 margin) {
/* Note: these `* 2` are here to completely replicate the behavior of
* the original Painfull Success. If you want to reuse this in your
* game, remove them. They are a bug! */
const vec2_int_t xl = pos.x + margin;
const vec2_int_t xr = pos.x + PLAYER_WIDTH - 1 - margin;
const vec2_int_t xr = pos.x + PLAYER_WIDTH - 1 - margin * 2;
const vec2_int_t yt = pos.y + margin;
const vec2_int_t yb = pos.y + PLAYER_HEIGHT - 1 - margin;
const vec2_int_t yb = pos.y + PLAYER_HEIGHT - 1 - margin * 2;
return ((tile == level_get_tile_at_px(level, (Vec2){xl, yt})) ||
(tile == level_get_tile_at_px(level, (Vec2){xr, yt})) ||
(tile == level_get_tile_at_px(level, (Vec2){xl, yb})) ||