13

I am developing a 2D game, and I have a lot of sprites. I used 3D animations and models to render into 2D, to give them that "Fallout" or "Diablo" look to them. It is also easier than drawing by hand, lol.

I have already had to cut the framerate down to 15fps, which was the lowest I could lower without making them have a choppy look to them. However, it was sad due to how incredibly smooth 24 frames looked.

There are two reasons I did this:

1) Cut down on HDD space. The fewer the images, the smaller my total game will be.

2) Cut down on RAM consumption. The fewer images to load, the more likely I am to avoid issues bloating my RAM limitation.

However, if there was a way to compress the images in both HDD space and RAM, I would do so. I have tested it before, and most do not receive any change in quality when giving from RGBA8888 to RGBA5555 and only a little hit when converting to RGBA4444 in my TexturePacker program. I do not do this currently, because SFML seems to use the same amount of memory regardless of which type of .PNG image it is. I looked into researching how to load it differently, but failed to find anything on the subject.

I have read a lot about how to handle 2D video games. The consensus is overwhelming: Pack your Sprites into a Bigger Texture for great performance! So I pack my tiny sprites into a much larger spritesheet using TexturePacker.

However, I plan to have 10-15 animations per character, 5 directions to move, and 15-40 frames per animation (probably an average of 24). With 15 animations, 5 directions, and an average of 24 frames per animation; That is 1800 individual frames per character. If packed in a sprite sheet, that is only 75 images instead. (One sprite sheet per Animation, per Direction. 15 * 5)

For the one huge boss character in the game, I cannot use a spritesheet and have to program a way to simply load in one image at a time. I do not know if I can do this for performance yet.

For the characters, I already pack them in a spritesheet. For a single character walking about, this seems to work most of the time, although sometimes it stalls. However, I attribute that to my ill conceived code that swaps out textures instead of preloading all textures for that character.

If I were to preload the textures, it makes sense for sprite sheets. I would only imagine it's a bad idea to preload 1800 tiny images for each character.

However, I imagine streaming them into and out of memory one at a time would be extremely fast, so I would only need to have a single image in memory at one time. Wouldn't this mean that at any given moment I would only have each character consume a few KB instead of 45+MB?

I imagine this would kill my performance, as streaming would need to be incredibly fast (15 images going into and out of memory and rendering, per second) and although the images would be very small- it might be a better idea to load character spritesheets into memory instead. But I will have to code a single-image stream-like render system for my larger boss character anyway.

I have been experimenting, but it is not a simple process. Especially given the fact I am working on other parts of the game engine that do not deal with graphics right now.

Carter81
  • 878
  • 9
  • 18
  • You did not specified your RAM or HDD constraints. How many characters need to be in fast access? 2. There are several questions along the text, maybe you could focus them with bold or even split the questions in parts?
  • – Kromster Sep 13 '13 at 10:05
  • Oh, I'm sorry. Not many. I would imagine that the maximum number of individual characters on screen at any one time would be about 40. If people made a point to try to crash their clients, then... 130 is the absolute max.

    Typically, there would only need to be 10 for the typical max, and the absolute max would be no more than <40. Anything above 40 would be an extreme, extreme rarity, with users purposefully trying to cram in characters for no reason other than a screenshot or for the fun of cramming in characters. Anything above 10 is rare, and anything about 40 is extremely, extremely rare.

    – Carter81 Sep 13 '13 at 10:11
  • The game is a PC-only (no mobile) 2D rpg, however I would not like to rule out a mobile platform unless it's simply not feasible. I imagine that the RAM space I have is limited to whatever RAM is on the user's PC, and the user's VRAM. I severely doubt it will be very large HDD wise. It's just that it's always true for HDD consumption that the smaller it is, the better. – Carter81 Sep 13 '13 at 10:12
  • How many UNIQUE characters you need to have on screen? – Kromster Sep 13 '13 at 10:17
  • No more than 20. Anything above that would be next to impossible unless they cheated. Typically 5-10. – Carter81 Sep 13 '13 at 10:18