diff --git a/sdlpp.hpp b/sdlpp.hpp index 06b432f..320b378 100644 --- a/sdlpp.hpp +++ b/sdlpp.hpp @@ -49,6 +49,9 @@ public: throw "Couldn't create window"; } } + void setResizable(bool resizable) { + SDL_SetWindowResizable(window, resizable ? SDL_TRUE : SDL_FALSE); + } ~Window() { SDL_DestroyWindow( window ); } @@ -959,10 +962,10 @@ public: virtual void updateSizeAndPosition() override { updateXY(); auto dimension = renderer->getSmallerSide(); - rect.x = x_ * dimension; - rect.y = y_ * dimension; - rect.w = w_ * dimension; - rect.h = h_ * dimension; + rect.x = std::round(x_ * dimension); + rect.y = std::round(y_ * dimension); + rect.w = std::round((x_ + w_) * dimension) - rect.x; + rect.h = std::round((y_ + h_) * dimension) - rect.y; if ( polygon ) polygon->updateCollision( collisionPushX(), collisionPushY(), collisionWidth(), collisionHeight() );