SFML TileMap collision help

I'm trying to do collision detection for my small game, it works, but it if off by half a tile.
here is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
bool collision(sf::Sprite collide, const int* level)
{
    sf::FloatRect steven_R;
    steven_R = collide.getGlobalBounds();
    int collideX = collide.getPosition().x;
    collideX = collideX%20;
    int collideY = collide.getPosition().y;
    collideY = collideY%20;
    if(collideX==0&&collideY==0)
    {
        int collideX = (collide.getPosition().x+steven_R.height)/20;
        int collideY = (collide.getPosition().y+steven_R.height)/20;
        if(level[collideX + collideY * 20]==2)
        {
            return false;
        }
    }
    return true;
}


And here is a picture of the result, it is exactly 1/2 a tile too low. https://i.imgur.com/tSNxBmA.jpg (The red dots are just the corners of the tile)
Topic archived. No new replies allowed.