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

Author Topic: Reusing sprites  (Read 2769 times)

0 Members and 1 Guest are viewing this topic.

awsumpwner27

  • Newbie
  • *
  • Posts: 27
    • View Profile
Reusing sprites
« 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?)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Reusing sprites
« Reply #1 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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

masskiller

  • Sr. Member
  • ****
  • Posts: 284
  • Pointers to Functions rock!
    • MSN Messenger - kyogre_jb@hotmail.com
    • View Profile
    • Email
Re: Reusing sprites
« Reply #2 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

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.
Programmer, Artist, Composer and Storyline/Script Writer of "Origin of Magic". If all goes well this could turn into a commercial project!

Finally back into the programming world!

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Reusing sprites
« Reply #3 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).
Back to C++ gamedev with SFML in May 2023

 

anything