From dd2537c3768ff67f16e68a2f1e037ed4e7bf5fe1 Mon Sep 17 00:00:00 2001 From: Lev Meirovitch Date: Sat, 29 May 2021 22:05:55 +0300 Subject: [PATCH] Added vertical collision check to fix the bug where player will not die at the very adge of the pit, but fall in to the ground and keep scrolling until edge of screen is reached --- src/player.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/player.cpp b/src/player.cpp index e4c316e..871eea0 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -107,9 +107,14 @@ void Player::update(Ground& ground) { velocityX = 0; } - setX(getX() + velocityX); setY(getY() + velocityY); + + //don't go into the ground if a an edge of a pit: + if (grounded || (getY() + getHeight()) < (SCREEN_HEIGHT - 64)) { + setX(getX() + velocityX); + } + if (ground.isTileBelow(getX(), getWidth())) { if (getY() + getHeight() < SCREEN_HEIGHT - 64)