Hello! There is a code for colliding two objects and a 16x16 texture. The implementation is such that a player jumping onto the enemy from above kills him, and the x coordinate of the enemy kills the player ... Using the Rectangle class, I do a collision check and then I write such conditions inside.
This condition for the death of the player:
if((rectPlayer.x + rectPlayer.width < arrayEnemy.get(num).getRect().x + arrayEnemy.get(num).getRect().width || rectPlayer.x + rectPlayer.width > arrayEnemy.get(num).getRect().x + arrayEnemy.get(num).getRect().width) && rectPlayer.y < arrayEnemy.get(num).getRect().y + arrayEnemy.get(num).getRect().height .... тут какой либо код... } This condition is for a player to hit the enemy from above:
if((rectPlayer.x + rectPlayer.width < arrayEnemy.get(num).getRect().x + arrayEnemy.get(num).getRect().width || rectPlayer.x + rectPlayer.width > arrayEnemy.get(num).getRect().x + arrayEnemy.get(num).getRect().width) && rectPlayer.y > arrayEnemy.get(num).getRect().y + arrayEnemy.get(num).getRect().height .... тут какой либо код... } My code on the x coordinate works ... but it’s worth connecting this player cannot kill the enemy from above ... and the player dies for some reason ... or vice versa, if you remove the condition x, the player jumps to the enemy without problems .... what's my mistake?