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

Author Topic: universe using sf::view  (Read 1993 times)

0 Members and 1 Guest are viewing this topic.

andreaszdw

  • Newbie
  • *
  • Posts: 26
    • View Profile
universe using sf::view
« on: May 15, 2012, 09:10:13 am »
Hello,

I have for example a universe with a size of 10000 x 10000 pixel. If my ship is at a pos of 10000, 10000 and  goes on, my ship should move to 0,0. Is it possible to use sf::View?

I think if I reset the view to 0,0 and my ship is in the center of the screen, I see only the objects at 0,0 not the rest of 10000,10000.

If someone understand my weired explanations and has an example how to implement, let me know.

Best regards
Andreas

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: universe using sf::view
« Reply #1 on: May 15, 2012, 09:17:31 am »
Quote
If someone understand my weired explanations
Sorry but I didn't ;D
Laurent Gomila - SFML developer

andreaszdw

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: universe using sf::view
« Reply #2 on: May 15, 2012, 10:40:29 am »
Maybe this handrawn brings light into the dark:



On no. 1 you see the universe with dimensions 10000,10000. The ship is at 5000,5000. sf::View is at 4600, 4700, with a size to screen of 800, 600. You can see on the screen completly 4600, 4700 to 5400, 5300.

Now on no. 2 you see the ship at 100, 100.  sf::View now must show the space from 9700, 9800 to 500, 400, because on no 3 you see that if the ship comes to the right end it should move around to left end and if it comes to the bottom it should move to the top, but the objects at the rest of the bottom or on the right side must be seen too.

Is this explanation better?

Best regards
Andreas

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: universe using sf::view
« Reply #3 on: May 15, 2012, 10:53:13 am »
It's much better, thanks :)

So you want an infinite/unbounded world, and you'd like it to work out of the box. Unfortunately this is a complicated feature (as for the graphical part), and I don't even know how I would implement it.

Well, a possible solution would be to draw your objects at multiples of (10000, 10000) depending on the position of the view. If the view goes out of the world by the right edge, then anything that would normally be drawn at y=10 would then be at y=10010.
« Last Edit: May 15, 2012, 10:56:05 am by Laurent »
Laurent Gomila - SFML developer