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

Author Topic: rotating Screen around central player (sfml 2.0)...  (Read 2613 times)

0 Members and 1 Guest are viewing this topic.

Beernutts

  • Newbie
  • *
  • Posts: 17
    • View Profile
rotating Screen around central player (sfml 2.0)...
« on: May 11, 2011, 04:46:44 pm »
Hi Guys,

I currently have a solution for this, but I'm not that satisfied with it, and I thought there might be a better way to do it that I'm not familiar with.

I want to have my player stay in the middle of the screen always pointing "up" for a top-down game.  He is controlled with a mouse (like an fps), so the screen is constantly rotating around him as the mouse moves back and forth.

The solution I've choosen is to create a RenderImage larger than the screen, blit my map onto the screen, then rotate the screen absed on the players angle in the map.  The problem is, I have to create a very large RenderImage (about twice the x/y dimensions of the screen), because, when it rotates, the corners would be cut off if the player was at a 45 degree angle.

I attempted to use views, and I found a solution, but I had to zoom in so much, it wasn't a good solution.

Is there a better way to do this that I can't find without using so much memory and have to blit my tiles and map onto the large render surface?

Thanks.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
rotating Screen around central player (sfml 2.0)...
« Reply #1 on: May 11, 2011, 05:16:39 pm »
Views are exactly made for this, what problem did you get?
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: rotating Screen around central player (sfml 2.0)...
« Reply #2 on: May 11, 2011, 05:18:01 pm »
Quote from: "Beernutts"
I attempted to use views, and I found a solution, but I had to zoom in so much, it wasn't a good solution.
Can't you draw a bigger scene (about twice x/y coordinates) and rotate the view without zooming it?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Beernutts

  • Newbie
  • *
  • Posts: 17
    • View Profile
rotating Screen around central player (sfml 2.0)...
« Reply #3 on: May 11, 2011, 05:32:30 pm »
Quote from: "Laurent"
Views are exactly made for this, what problem did you get?


I'm not sure how to rotate the view without also rotating my character, so I didn't mess with that part.  So, instead, I drew my scene on the normal RenderWindow, copied that to an Image, rotated the image, Draw()'d it on the Render Window, then used the view to zoom in so the clipped corners weren't showing.

I'll mess around with rotating the view when I get home.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
rotating Screen around central player (sfml 2.0)...
« Reply #4 on: May 11, 2011, 05:56:51 pm »
Quote
I'm not sure how to rotate the view without also rotating my character

Either rotate your player by the opposite angle, or use an unrotated view to draw it.
Laurent Gomila - SFML developer