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

Author Topic: Tiles : many sprites or many moves ? [SOLVED]  (Read 2917 times)

0 Members and 1 Guest are viewing this topic.

gyscos

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Tiles : many sprites or many moves ? [SOLVED]
« 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.

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
Tiles : many sprites or many moves ? [SOLVED]
« Reply #1 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.

K-Bal

  • Full Member
  • ***
  • Posts: 104
    • View Profile
    • pencilcase.bandcamp.com
    • Email
Tiles : many sprites or many moves ? [SOLVED]
« Reply #2 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.
Listen to my band: pencilcase.bandcamp.com

gyscos

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Tiles : many sprites or many moves ? [SOLVED]
« Reply #3 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 ?)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Tiles : many sprites or many moves ? [SOLVED]
« Reply #4 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.
Laurent Gomila - SFML developer

gyscos

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Tiles : many sprites or many moves ? [SOLVED]
« Reply #5 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