SFML community forums

Help => Graphics => Topic started by: gyscos on November 24, 2009, 10:55:48 pm

Title: Tiles : many sprites or many moves ? [SOLVED]
Post by: gyscos on November 24, 2009, 10:55:48 pm
Hello !
I have to draw a grid with many little sprites ; yet I have a question : would it be better to have only a few sprites (one for each kind of cell) and move & draw them repeatedly, or to have many sprites (one for each cell) and change their image each time, or to have many many many sprites (one for each kind of cell for each cell) and just choose wich one to draw ?

Thanks !

EDIT : the grid would not have to move, it's just a game board.
Title: Tiles : many sprites or many moves ? [SOLVED]
Post by: panithadrum on November 25, 2009, 08:47:30 am
My advice is to have just few sprites and draw them in different places. You will save a lot of memory.
Title: Tiles : many sprites or many moves ? [SOLVED]
Post by: K-Bal on November 25, 2009, 09:19:19 am
Depends on your platform. On a new PC I would go the many sprites way. On a gameboy you probably would use the other method.
Title: Tiles : many sprites or many moves ? [SOLVED]
Post by: gyscos on November 25, 2009, 09:47:18 am
Thanks. I'll be using a PC, so let's go for the many sprites...

(the main question was : is it faster to move a sprite and draw it or to change its image and draw it ?)
Title: Tiles : many sprites or many moves ? [SOLVED]
Post by: Laurent on November 25, 2009, 10:29:23 am
It's basically the same. Sprites in SFML are very cheap to handle, only the call to Draw has an impact on performances. So it doesn't really matter if you draw the same sprite X times, or if you draw X sprites once, in both cases you have X calls to Draw.
Title: Tiles : many sprites or many moves ? [SOLVED]
Post by: gyscos on November 25, 2009, 12:53:58 pm
Ok, thanks !
So I'll rather use a few sprites, since it doesn't decrease perf and uses less memory. :D