I am learning SFML by making Pong. My project is set up to build on Windows, MacOS, and Linux. I currently build on all 3 on every PR (thanks SFML template).
I also test on Windows and MacOS. I have made an odd observation, and I am not sure if it's an error on my side, or something funny going on with MacOS.
Below is a Windows screenshot, and both of the player and enemy paddles are perfectly aligned:
Below is a MacOS screenshot of the same build:
Some of the interesting observations:
- Dividing Lane is perfectly down the middle
- Both Player and Enemy paddles are shifted to the right
Below is the code snipped that determines the position of both paddles:
Player::Player(bool main_player, const float& width, const float& length)
: _main_player{ main_player }, _width{ width }, _length{ length }, _size(_width, _length), _rect(_size)
{
float x_pos_from_side = 200.f;
float centered_y_pos = 0.5f * (_window_y_size - _length);
float x_pos = _main_player ? x_pos_from_side : _window_x_size - x_pos_from_side - _width;
_rect.setPosition(sf::Vector2f(x_pos, centered_y_pos));
}