Devblog part #4 – Working with tiles and memory management.

I think the biggest lesson I learned about making a game, is memory management, especially if you are designing for mobile, keep your asset small, in powers of 2, use tiles!, work with low number of animation frames.

Most mobile devices uses a very weak graphical processor, which has many limitation, so first of all try not going over 1024×1024 on mobile, always take power of 2 in consideration, for example a 129×129 image will use the memory of a 256×256 image, I found that rendering a lower image than scaling it up a little back doesn’t look that bad on most cases, so if I need a sprite to be 160px big, I will probably render the image in 128×128 and scale it up.

Background objects for example can be rendered in a very low resolution and then stretched back, it will make them really blurry which will give you the extra effect of distance and will save you tons of memory.

Back to Bad Pad, this time around I had a little more experience with level design and working with tiles, so first of I decided to work around a 32×32 tileset, that means most of my graphics will be designed and rendered at this resolution, that goes for backgrounds, platforms, obstacles and characters, of course there will be exceptions here and there.

Working with tiles also makes it easier to build levels, especially if your working with platforms, you know the exact distance the player can jump or move on the X axis while jumping, so you can design your levels around those parameters even on a math paper and save a lot of time testing every thing.

For the platforms and the background wall I used tiled images and 9 patched images.

Tiling an images, is a very efficient a way of building a level and saving memory, instead of loading a bunch of separated sprites and instances you just load one and spread it out in a given area.

tileEx2

tileEx1

tileEx3

tileEx4

9 patch is very similar to tile, but with the option of frame border, so if I’ll take a 32×32 image and set it to a 9 patch tile with 4px border (left, right, top and bottom), i will get 28×28 spread tile on the inside and a 4×4 tile as a border, both can be set to tile or stretch, I usually use tile for the inside and stretch for the border.

9patchEx1

9patchEx2

Stay tuned for first playable alpha version releasing early next week!

Leave a Reply