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

Author Topic: Updating a Specific Sprite or View  (Read 907 times)

0 Members and 1 Guest are viewing this topic.

PvPineapple

  • Newbie
  • *
  • Posts: 1
    • View Profile
Updating a Specific Sprite or View
« on: November 26, 2019, 09:25:12 pm »
I have a large map that's procedural generated and places several 30x30px tiles.  This generation is in a specific view called mapView.  I have another view for the players called playerView.  First, is it possible to just combine these views and only redraw the player sprite as it moves.  If not, is it possible to just update playerView with window.display()?  It appears to be redrawing mapView each frame, making it run really slow and jagged.  I tried setting window.setView(playerView), but this still updates both views.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Updating a Specific Sprite or View
« Reply #1 on: November 26, 2019, 11:45:48 pm »
For large maps, especially if they're changing rarely, you may want to use a render texture and draw the map to it whenever something changes. That way you won't be updating the map as often.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything