-
-
Save technoAl/459c1f8b4b8998fd43a028c549a36ec0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Platform { | |
int x, y, width, height; | |
public boolean isColliding(Player player){ | |
int distanceX = Math.abs(player.getX() - this.x); | |
int distanceY = Math.abs(player.getY() - this.y); | |
int widthSum = this.width / 2 + player.getWidth() / 2; | |
int heightSum = this.height / 2 + player.getHeight() / 2; | |
return distanceX < widthSum && distanceY < heightSum; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment