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

Author Topic: Sprites or View movement  (Read 1423 times)

0 Members and 1 Guest are viewing this topic.

JackPS9

  • Newbie
  • *
  • Posts: 28
    • View Profile
Sprites or View movement
« on: March 28, 2017, 03:45:28 am »
Which would be faster to move?
I'm thinking it would be faster to move the view around as the player moves, but just looking for a second opinion on the matter.

Turbine

  • Full Member
  • ***
  • Posts: 102
    • View Profile
Re: Sprites or View movement
« Reply #1 on: March 28, 2017, 08:48:04 am »
This can be a bit of a mind bender. You actually need to move both the player's position and the view.

This is why, your map is likely larger than your view. So as you walk, the view needs to move so you don't run off the screen.

-Map size.
-View size and position.
-Player position.

--

If you mean making the view move smoothly, then the best way is to have the view move at a different consistent rate than the player. So you smoothly go through all of the pixels, so rather than say 1.3 + 0.8px you'd move at 1px. Because after 10 frames, you'll get a pixel jump with these example values.
« Last Edit: March 28, 2017, 08:54:05 am by Turbine »

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Sprites or View movement
« Reply #2 on: March 28, 2017, 12:46:44 pm »
I read this question as a question about whether or not to move the drawables to simulate a moving camera or to change the view to do that.

If that is the question, the answer is: it doesn't really matter!
It's probably simpler to move just the view as all the sprites are moved correctly and the view acts like a camera anyway.
The sprites' transformations are applied to the view's transformations so whichever you change (sprite's position or view's position), the same calculations are still done.
The main thing to consider really is not draw things that aren't visible. How they are transformed isn't really an issue.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything