Skip to content

Instantly share code, notes, and snippets.

@saschagehlich
Created February 24, 2013 09:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saschagehlich/ea934f7829b3055e47fe to your computer and use it in GitHub Desktop.
Save saschagehlich/ea934f7829b3055e47fe to your computer and use it in GitHub Desktop.
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