SFML community forums

Help => Graphics => Topic started by: awsumpwner27 on February 09, 2013, 04:22:23 pm

Title: Reusing sprites
Post by: awsumpwner27 on February 09, 2013, 04:22:23 pm
Let's say I have multiple enemies that look the same, would it be better to give each of them a sprite, or would it be better to draw each one with the same sprite, but changing the necessary properties to fit the properties of one individual enemy? (Like position.) Is there just one better way? Or can there be specific cases where one or the other should be applied?

(Also, I have another question, but I'll give it less priority. How would one reduce the amount of draw calls? What counts as a draw call? Can one ever have a big 2D platformer with parallax scrolling and have everything drawn in 1 call?)
Title: Re: Reusing sprites
Post by: Nexus on February 09, 2013, 04:34:45 pm
Use one sprite per enemy. Sprites are lightweight objects, it's usually not an issue to have lot of them.

To reduce draw calls, you can look at sf::VertexArray.
Title: Re: Reusing sprites
Post by: masskiller on February 09, 2013, 04:59:14 pm
Take a look at my container: https://github.com/SFML/SFML/wiki/Source%3A-High-Performance-Sprite-Container (https://github.com/SFML/SFML/wiki/Source%3A-High-Performance-Sprite-Container)

I am going to make a rework of it soon (more eficiency and a better API), but it's quite complete on reducing draw calls and allowing sprites to be transformed.
Title: Re: Reusing sprites
Post by: FRex on February 09, 2013, 05:17:03 pm
If you're ok with tight square tilemaps like in spelunky 1 that are limited to one graphics spreadsheet and limited in x and y by max texture size in pixels that graphics card can support then you can use my shader map:
https://github.com/SFML/SFML/wiki/Source%3A-ShaderTileMap
You also need to have shaders working obviously. But sadly you'd have to give me credit(mit license :( ,just link to wiki site).