So I've managed to get my window detecting mouse input, and MouseMove.Y always properly returns coordinates, but MouseMove.X consistently returns 0, no matter where on the screen I click.
I am trying to click on a circle to reset it's color. Here are the relevant parts of code:
//This checks for mouse input.
else if(Event.Type == sf::Event::MouseButtonPressed)
{
for(int i = 0; i < (*GameBoard).theBoard.size(); ++i)
{
bool colliding = (*GameBoard).theBoard[i].CollidePoint(Event.MouseMove.X, Event.MouseMove.Y);
if(colliding)
{
(*GameBoard).theBoard[i].m_Circle.SetColor(sf::Color(20, 20, 200));
break;
}
}
}
And this:
bool Space::CollidePoint(int x, int y)
{
float xDist = abs(x - (m_X + m_radius));
float yDist = abs(y - (m_Y + m_radius));
float distance = sqrt(pow(xDist, 2) + pow(yDist, 2));
cout << "\nClick detected at: " << x << ", " << y << endl;
cout << "Center is at " << (m_X + m_radius) << ", " << (m_Y + m_radius) << endl;
cout << "Distance is: " << distance << "\n";
if(distance <= m_radius)
{
return true;
}
else
{
return false;
}
}
Now, it's possible that MouseMove.X is returning the proper value and I'm just not sending it properly to cout, but I doubt this is the issue, since none of the circles I click on want to respond to me. Anyone know what I'm doing wrong? I'm quite new to C++, coming from a background in Python; I fully expect to have made some simple mistake somewhere.