-
-
Save saschagehlich/ea934f7829b3055e47fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Screen::render(string fileName, sf::Vector2<int> destPosition) { | |
sf::Sprite sprite(spriteSheet); | |
struct spriteFrame frame = _frames[fileName]; | |
float widthRatio = _game->actualScreenWidth / _game->originalScreenWidth; | |
float heightRatio = _game->actualScreenHeight / _game->originalScreenHeight; | |
sprite.setTextureRect(frame.frame); | |
sprite.setPosition(destPosition.x * widthRatio, destPosition.y * heightRatio); | |
sprite.scale(1.0 / _game->originalScreenWidth * _game->actualScreenWidth, 1.0 / _game->originalScreenHeight * _game->actualScreenHeight); | |
_mainWindow->draw(sprite); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment