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

Author Topic: Draw a sprite but not at its coordinates.  (Read 1893 times)

0 Members and 1 Guest are viewing this topic.

kidchameleon

  • Newbie
  • *
  • Posts: 29
    • View Profile
    • Email
Draw a sprite but not at its coordinates.
« on: January 07, 2013, 06:05:43 pm »
Hi All!

I hope you had a good festive season!

Is there any way to draw a sprite at a position that is not the sprites actual position? Its very hard to explain what I'm trying to do, apologies if this is confusing.

Lets say I have a sprite at position x = 200, y = 100. I want my games logic update to hold these values. But I want my render update to show the sprite at say x = 210, y = 110.

Does this make sense?

Thanks for your help.

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Draw a sprite but not at its coordinates.
« Reply #1 on: January 07, 2013, 06:15:33 pm »
Does this make sense?
Not really...

If you want the sprite to be drawn at (210, 110) what do you need the postion (200, 100) for? And to fully answer your question: No it is not possible to render a sprite anywhere else then where the sprites position variable is set to. (Otherwise the position variable wouldn't make sense, would it? :D )

kidchameleon

  • Newbie
  • *
  • Posts: 29
    • View Profile
    • Email
Re: Draw a sprite but not at its coordinates.
« Reply #2 on: January 07, 2013, 06:20:48 pm »
The reason I want to do this is that I have an update logic loop and also an update graphics loop. To give smooth sprite movement I'm interpolating the sprites position. I just want to update the sprites position 25 times per second, not every time the computer wants to render. I'm trying to cut out micro stutter.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Draw a sprite but not at its coordinates.
« Reply #3 on: January 07, 2013, 06:32:16 pm »
If you don't want the sprite to change position, then don't change the position.
You'll have to manage the delay in movement on your own, at best probably with a sf::Clock.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/