Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [SFML 2.0] Background and multi-resolution game  (Read 2650 times)

0 Members and 1 Guest are viewing this topic.

owenattard

  • Newbie
  • *
  • Posts: 2
    • View Profile
[SFML 2.0] Background and multi-resolution game
« on: December 08, 2012, 12:48:04 pm »
I started using sfml just a few days ago and was wondering how i could set a background image to my game. This is not my first game i already  done a small game using xna. Now i want to make a bigger game using sfml and would like to know how to implement multi-resolutions in game and how everything is scaled according to the resolution or if i have to code the design aspect for every reolution. If any ones a good tutorial or knows how to do this i would be like to share it with me i would be grateful. I am using c++.
thanks in advance

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: [SFML 2.0] Background and multi-resolution game
« Reply #1 on: December 08, 2012, 01:16:05 pm »
You could simply take one of the examples and play around with it for a bit, so you'd see what SFML can do and what you have to do on your own.

For a background image, you'd take a sf::Texture and a sf::Sprite, load your image into the texture, set the texture on the sprite and draw it every frame iteration.

If you don't change the view of the RenderTarget things will get automatically scaled when you resize the window, but the aspect ratio is not preserved, thus in most cases you'll want to change the view accordingly. For more information about the usage of sf::View you can check out my tutorial on the wiki.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

owenattard

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: [SFML 2.0] Background and multi-resolution game
« Reply #2 on: December 08, 2012, 04:37:55 pm »
thx alot for the help :)