LibGDX - Collision & Rendering Issues

Hi!

I am currently using LibGDX & Tiled in order to create a test game for collision and other mechanics, to get used to them.
The problem is that the collision method I am using is causing a weird issue. I believe it is most likely a problem with the cell size… anyways, check out my code:

        private boolean isCellBlocked(float xx, float yy){
                Cell cell = collisionLayer.getCell((int) (xx/collisionLayer.getTileWidth()), (int) (yy/collisionLayer.getTileHeight()));
                return cell != null && cell.getTile() != null && cell.getTile().getProperties().containsKey(blockedKey);
        }

        public boolean collidesRight() {
                for(float step = 0; step < player.height; step += collisionLayer.getTileHeight())
                        if(isCellBlocked(player.x + player.width , player.y + step))
                                return true;
                return false;
        }
 
        public boolean collidesLeft() {
                for(float step = 0; step < player.height; step += collisionLayer.getTileHeight())
                        if(isCellBlocked(player.x, player.y + step))
                                return true;
                return false;
        }
 
        public boolean collidesTop() {
                for(float step = 0; step < player.width; step += collisionLayer.getTileWidth())
                        if(isCellBlocked(player.x + step, player.y + player.height))
                                return true;
                return false;
 
        }
 
        public boolean collidesBottom() {
                for(float step = 0; step < player.width; step += collisionLayer.getTileWidth())
                        if(isCellBlocked(player.x + step, player.y))
                                return true;
                return false;
        }

The issue I am having is shown below.

I believe the issue is with the cell grid. When a collisionLeft occurs, it is right next to the block (well, 1 pixel off…). The same goes for the bottom collision, it is perfect! Top & Right collision though… not even close. The size of the tiles are 32x32 if that helps.
Any advice would be wonderful! :slight_smile:
Also, I notice that when using tiled and moving, you can see the map being de-rendered(?) slightly on the sides. How would I fix this issue?

Thanks!
-A