   Positions appear correct but no collision
  Okay this isn't as simple as it sounds or maybe it is, first off this is something I am working on using SFML/Box2D in those aspects everything is working fine, but I have draw up some dots in the tilemap that need to be checked collision but not actual react based on Box2D's physics so I am using a simple bool checkCollision function to check whether these sprites positions cross paths if they do they are no longer visible and score increases, well I have tested everything out and all works good except it will not tell if they have collide or not and I cannot see where my calculations are wrong, they appear to be on the up and up but don't ever cross paths for some reason, can someone check this out for me, the key points to look at are where I declare dots[].sprite and player.sprite follow the positions and look at my checkCollision function and see if you can find the problem where the calculations are going wrong. All of them draw in the correct places which is why I am so confused on why I am not getting a proper collision. Here is my source code below, only 400 lines of code, but it is a little sloppy since I have been coding on the fly with this learning process.#include <SFML/Graphics.hpp>#include <Box2D.h>#include <vector>#include <iostream>void handleInput();bool checkCollision(sf::Sprite, sf::Sprite);bool quit = false;typedef struct MyRect{float top, bottom, left, right;}MyRect;typedef struct Object{sf::Image image;sf::Sprite sprite;}Object;Object blank, dot, pill;Object wall0, wall1, wall2, wall3, wall4, wall5, wall6, wall7, wall8;Object wall9, wall10, wall11, wall12, wall13, empty;const float tileWidth  = 16;const float tileHeight = 16;const int tileMapWidth  = 20;const int tileMapHeight = 20;struct B2World{b2AABB worldAABB;b2World* world;b2Vec2 gravity;float scale, timestep;int iterations;bool doSleep;};B2World myWorld;//Box2D object Structurestruct B2Object{sf::Image image;sf::Sprite sprite;sf::Shape shape;b2BodyDef bodyDef;b2Body* body;b2PolygonDef polyDef;b2Vec2 position;b2Vec2 transform;float angle;bool visible;};const int colSize = 206;const int dotSize = 134;B2Object player;B2Object colObject[colSize];B2Object dots[dotSize];sf::RenderWindow Game(sf::VideoMode(352, 352, 32), "SFML-Box2D Tilemap");int main(){int tileMap[tileMapWidth][tileMapHeight] ={1, 5, 5, 5, 5, 5, 5, 5, 5, 9, 9, 5, 5, 5, 5, 5, 5, 5, 5, 2, //206,16,15,15,15,15,15,15,15, 6, 6,15,15,15,15,15,15,15,16, 6, //46,15, 1, 2,15, 1, 5, 2,15, 6, 6,15, 1, 5, 2,15, 1, 2,15, 6, //146,15, 4, 3,15, 4, 5, 3,15, 4, 3,15, 4, 5, 3,15, 4, 3,15, 6, //14 ...526,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15, 6, //26,15, 7, 8,15,14,15, 7, 5, 9, 9, 5, 8,15,14,15, 7, 8,15, 6, //146,15,15,15,15, 6,15,15,15, 6, 6,15,15,15, 6,15,15,15,15, 6, //64, 5, 5, 2,15,12, 5, 8, 0, 4, 3, 0, 7, 5,11,15, 1, 5, 5, 3, //16 ...380, 0, 0, 6,15, 6, 0, 0, 0, 0, 0, 0, 0, 0, 6,15, 6, 0, 0, 0, //45, 5, 5, 3,15,13, 0, 1, 8, 0, 0, 7, 2, 0,13,15, 4, 5, 5, 5, //100, 0, 0, 0,15, 0, 0, 6, 0, 0, 0, 0, 6, 0, 0,15, 0, 0, 0, 0, //05, 5, 5, 2,15,14, 0, 4, 5, 5, 5, 5, 3, 0,14,15, 1, 5, 5, 5, //10 ...24 ...1140, 0, 0, 6,15, 6, 0, 0, 0, 0, 0, 0, 0, 0, 6,15, 6, 0, 0, 0, //41, 5, 5, 3,15,13, 0, 7, 5, 9, 9, 5, 8, 0,13,15, 4, 5, 5, 2, //166,15,15,15,15,15,15,15,15, 6, 6,15,15,15,15,15,15,15,15, 6, //46,15, 7, 2,15, 7, 5, 8,15, 4, 3,15, 7, 5, 8,15, 1, 8,15, 6, //14 ...38    6,15,15, 6,15,15,15, 0, 0, 0, 0, 0, 0,15,15,15, 6,15,15, 6, //4   12, 8,15,13,15,14,15, 7, 5, 5, 5, 5, 8,15,14,15,13,15, 7,11, //146,16,15,15,15, 6,15,15,15,15,15,15,15,15, 6,15,15,15,16, 6, //44, 5, 5, 5, 5,10, 5, 5, 5, 5, 5, 5, 5, 5,10, 5, 5, 5, 5, 3  //20 ...42 ...80 ...194};int score = 0;int dotss  = 0;int pillss = 0;for(int x = 0; x < tileMapWidth; x++){for(int y = 0; y < tileMapHeight; y++){int index = tileMap[y][x];if(index == 15)dotss++;if(index == 16)pillss++;}}std::vector<sf::Sprite> tileTextures;blank.image.LoadFromFile("blank.png");wall0.image.LoadFromFile("wall0.png");wall1.image.LoadFromFile("wall1.png");wall2.image.LoadFromFile("wall2.png");wall3.image.LoadFromFile("wall3.png");wall4.image.LoadFromFile("wall4.png");wall5.image.LoadFromFile("wall5.png");wall6.image.LoadFromFile("wall6.png");wall7.image.LoadFromFile("wall7.png");wall8.image.LoadFromFile("wall8.png");wall9.image.LoadFromFile("wall9.png");wall10.image.LoadFromFile("wall10.png");wall11.image.LoadFromFile("wall11.png");wall12.image.LoadFromFile("wall12.png");wall13.image.LoadFromFile("wall13.png");dot.image.LoadFromFile("dot.png");pill.image.LoadFromFile("pill.png");empty.image.LoadFromFile("empty.png");player.image.LoadFromFile("player.png");blank.sprite.SetImage(blank.image);wall0.sprite.SetImage(wall0.image);wall1.sprite.SetImage(wall1.image);wall2.sprite.SetImage(wall2.image);wall3.sprite.SetImage(wall3.image);wall4.sprite.SetImage(wall4.image);wall5.sprite.SetImage(wall5.image);wall6.sprite.SetImage(wall6.image);wall7.sprite.SetImage(wall7.image);wall8.sprite.SetImage(wall8.image);wall9.sprite.SetImage(wall9.image);wall10.sprite.SetImage(wall10.image);wall11.sprite.SetImage(wall11.image);wall12.sprite.SetImage(wall12.image);wall13.sprite.SetImage(wall13.image);dot.sprite.SetImage(dot.image);pill.sprite.SetImage(pill.image);empty.sprite.SetImage(empty.image);player.sprite.SetImage(player.image);blank.sprite.SetCenter(sf::Vector2f(8, 8));wall0.sprite.SetCenter(sf::Vector2f(8, 8));wall1.sprite.SetCenter(sf::Vector2f(8, 8));wall2.sprite.SetCenter(sf::Vector2f(8, 8));wall3.sprite.SetCenter(sf::Vector2f(8, 8));wall4.sprite.SetCenter(sf::Vector2f(8, 8));wall5.sprite.SetCenter(sf::Vector2f(8, 8));wall6.sprite.SetCenter(sf::Vector2f(8, 8));wall7.sprite.SetCenter(sf::Vector2f(8, 8));wall8.sprite.SetCenter(sf::Vector2f(8, 8));wall9.sprite.SetCenter(sf::Vector2f(8, 8));wall10.sprite.SetCenter(sf::Vector2f(8, 8));wall11.sprite.SetCenter(sf::Vector2f(8, 8));wall12.sprite.SetCenter(sf::Vector2f(8, 8));wall13.sprite.SetCenter(sf::Vector2f(8, 8));dot.sprite.SetCenter(sf::Vector2f(8, 8));pill.sprite.SetCenter(sf::Vector2f(8, 8));empty.sprite.SetCenter(sf::Vector2f(8, 8));player.sprite.SetCenter(sf::Vector2f(7, 7));tileTextures.push_back(blank.sprite);tileTextures.push_back(wall0.sprite);tileTextures.push_back(wall1.sprite);tileTextures.push_back(wall2.sprite);tileTextures.push_back(wall3.sprite);tileTextures.push_back(wall4.sprite);tileTextures.push_back(wall5.sprite);tileTextures.push_back(wall6.sprite);tileTextures.push_back(wall7.sprite);tileTextures.push_back(wall8.sprite);tileTextures.push_back(wall9.sprite);tileTextures.push_back(wall10.sprite);tileTextures.push_back(wall11.sprite);tileTextures.push_back(wall12.sprite);tileTextures.push_back(wall13.sprite);tileTextures.push_back(dot.sprite);tileTextures.push_back(pill.sprite);tileTextures.push_back(empty.sprite);myWorld.gravity = b2Vec2(0, 0);myWorld.doSleep = true;myWorld.scale = 30.0f;myWorld.timestep = (1 / 60.0f) / 5;myWorld.iterations = 10;//Create the size of the world, sets world at -1 meter by 1 meter (-30p x 30p)myWorld.worldAABB.lowerBound.Set(-1000 / myWorld.scale,-1000 / myWorld.scale);myWorld.worldAABB.upperBound.Set( 1000 / myWorld.scale, 1000 / myWorld.scale);//Create the worldmyWorld.world = new b2World(myWorld.worldAABB, myWorld.gravity, myWorld.doSleep);//Create the Box2D Player objectplayer.polyDef.SetAsBox(7 / myWorld.scale, 7 / myWorld.scale);player.polyDef.friction = 0.0f;player.polyDef.restitution = 0.0f;player.polyDef.density = 1.0f;player.bodyDef.position.Set(175 / myWorld.scale, 278 / myWorld.scale);player.angle = 0.0f;player.body = myWorld.world->CreateBody(&player.bodyDef);player.body->CreateShape(&player.polyDef);player.body->SetMassFromShapes();for(int a = 0; a < colSize; a++){colObject[a].polyDef.SetAsBox(8 / myWorld.scale, 8 / myWorld.scale);colObject[a].polyDef.friction= 0.0f;colObject[a].polyDef.restitution= 0.0f;colObject[a].polyDef.density= 0.0f;}int a = 0;int e = 0;for(int x = 0; x < tileMapWidth; x++){for(int y = 0; y < tileMapHeight; y++){int index = tileMap[y][x];if(index == 1 || index == 2 || index == 3 || index == 4 || index == 5 || index == 6 ||   index == 7 || index == 8 || index == 9 || index == 10 || index == 11 || index == 12 || index == 13 || index == 14){colObject[a].bodyDef.position.Set((x * tileWidth + 24) / myWorld.scale, (y * tileHeight + 24) / myWorld.scale);a++;}if(index == 15 || index == 16){dots[e].sprite.SetPosition(sf::Vector2f((x * tileWidth + 24) / myWorld.scale, (y * tileHeight + 24) / myWorld.scale));dots[e].visible = true;e++;}}}for(int i = 0; i < colSize; i++){colObject.body = myWorld.world->CreateBody(&colObject.bodyDef);colObject.body->CreateShape(&colObject.polyDef);colObject.body->SetMassFromShapes();}while(Game.IsOpened()){sf::Event Event;while(Game.GetEvent(Event)){if(Event.Type == sf::Event::Closed)Game.Close();}if(quit)Game.Close();myWorld.world->Step(myWorld.timestep, myWorld.iterations);handleInput();for(int x = 0; x < dotSize; x++){if(dots[x].visible){if(checkCollision(player.sprite, dots[x].sprite)){dots[x].visible = false;score += 100;}}}Game.Clear(sf::Color(0, 0, 0));a = 0;e = 0;for(int x = 0; x < tileMapWidth; x++){for(int y = 0; y < tileMapHeight; y++){int textureIndex = tileMap[y][x];sf::Sprite texture = tileTextures[textureIndex];if(textureIndex == 1 || textureIndex == 2 || textureIndex == 3 || textureIndex == 4 || textureIndex == 5 || textureIndex == 6 ||textureIndex == 7 || textureIndex == 8 || textureIndex == 9 || textureIndex == 10 || textureIndex == 11 || textureIndex == 12 || textureIndex == 13 || textureIndex == 14){texture.SetPosition(colObject[a].body->GetPosition().x * myWorld.scale,colObject[a].body->GetPosition().y * myWorld.scale);Game.Draw(texture);a++;}if(textureIndex == 15 || textureIndex == 16){if(dots[e].visible){texture.SetPosition(dots[e].sprite.GetPosition().x * myWorld.scale,dots[e].sprite.GetPosition().y * myWorld.scale);Game.Draw(texture);}e++;}// else if(textureIndex == 0)// {// texture.SetPosition(x * tileWidth + 24, y * tileHeight + 24); //Fix for box2D coordinates// Game.Draw(texture);// }}}a = 0;std::cout << "Score: " << score << std::endl;system("cls");Game.Draw(player.sprite);Game.Display();}for(int x = 0; x < colSize; x++){//Destroy the worlds bodiesmyWorld.world->DestroyBody(colObject[x].body);//Set the bodies to NULLcolObject[x].body = NULL;}myWorld.world->DestroyBody(player.body);player.body = NULL;//Delete the worlddelete myWorld.world;return EXIT_SUCCESS;}void handleInput(){if(Game.GetInput().IsKeyDown(sf::Key::Escape))quit = true;float thrust = 30.0f;if(Game.GetInput().IsKeyDown(sf::Key::W)){player.body->SetLinearVelocity(b2Vec2(0, -thrust));}if(Game.GetInput().IsKeyDown(sf::Key::S)){player.body->SetLinearVelocity(b2Vec2(0, thrust));}if(Game.GetInput().IsKeyDown(sf::Key::A)){player.body->SetLinearVelocity(b2Vec2(-thrust, 0));}if(Game.GetInput().IsKeyDown(sf::Key::D)){player.body->SetLinearVelocity(b2Vec2(thrust, 0));}if(player.body->GetPosition().x * myWorld.scale <= 16){float posY = player.body->GetPosition().y * myWorld.scale;player.body->SetXForm(b2Vec2((352 - 16) / myWorld.scale, posY / myWorld.scale), 0.0f);}if(player.body->GetPosition().x * myWorld.scale >= (352 - 16)){float posY = player.body->GetPosition().y * myWorld.scale;player.body->SetXForm(b2Vec2((16) / myWorld.scale, posY / myWorld.scale), 0.0f);}player.sprite.SetPosition(player.body->GetPosition().x * myWorld.scale, player.body->GetPosition().y * myWorld.scale);}bool checkCollision(sf::Sprite object1, sf::Sprite object2){MyRect Rect1;Rect1.top = (object1.GetPosition().y) * myWorld.scale;Rect1.bottom = Rect1.top + 14;Rect1.left = (object1.GetPosition().x) * myWorld.scale;Rect1.right = Rect1.left + 14;MyRect Rect2;Rect2.top = (object2.GetPosition().y) * myWorld.scale;Rect2.bottom = Rect2.top + 16;Rect2.left = (object2.GetPosition().x) * myWorld.scale;Rect2.right = Rect2.left + 16;if(Rect1.top > Rect2.bottom || Rect1.right < Rect2.left|| Rect1.bottom < Rect2.top || Rect1.left > Rect2.right)return false;return true;}
  **SOLVED: With some console output, I was able to find out that the player position was already converted and I was re-doing the conversion (* myWorld.scale) on object1 in the collision function, thus, putting my collision position in MyRect our of whack. I also realized that the only one needing this * scale was object2 in the collision function and by also removing the extra I had going for object2. Here is the correction function...bool checkCollision(sf::Sprite object1, sf::Sprite object2){MyRect Rect1;Rect1.top = object1.GetPosition().y;Rect1.bottom = Rect1.top + 14;Rect1.left = object1.GetPosition().x;Rect1.right = Rect1.left + 14;MyRect Rect2;Rect2.top = (object2.GetPosition().y) * myWorld.scale;Rect2.bottom = Rect2.top + 16;Rect2.left = (object2.GetPosition().x) * myWorld.scale;Rect2.right = Rect2.left + 16;if(Rect1.top > Rect2.bottom || Rect1.right < Rect2.left|| Rect1.bottom < Rect2.top || Rect1.left > Rect2.right)return false;return true;}