Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sodthor's CodeImage - Image Converter for NGPC
With sodthor's permission, I am sharing CodeImage, which I find to be the best and simplest image converter for NGPC. The best part? You just use a normal image editor to draw up your tilesets in full color (keeping palette limits in mind)! No fussing with less than ideal dedicated applications. I like working in GIMP for level tilesets and export to PNG (with transparency!). I like working in Piskel for animated sprites, and export those to PNG (with transparency!).

I do not have a simple demo source available at the moment where I have used it.

It's a very powerful tool that supports 2-layer tiles (i.e. you can use 6 colors + transparent, but each 8x8 square in your starting image takes up 2 tiles in tile RAM).  In order to save tiles, I have tended to use single layer tiles.

You can limit the number of palettes used for a given image.

What I do is divide my work up into map tilesets, where each tileset image contains all tiles I want to use in a level, and then separate images for each sprite that contain all frames of animation.  I make sure to reserve 64 tiles that I dedicate to sprites, so the number of tiles I can devote to a level are up to 256-64=192 tiles.  I make sure not to exceed that in a given tileset image.  However, the tool supports tile flipping vertically and horizontally (or both) and so tiles can be duplicated in your image and flipped and they won't take up extra tile RAM, but you do have to manage flipping as needed when placing a tile.  Knowing that my palette limit is 16 for a given scroll plane or sprites, I try to remain conscious of the number of colors I am using when drawing a tileset so that I don't run into any surprises.  However, a really nice feature of CodeImage is that it will reduce colors as needed to get you into the palette limit that you choose.

So let's say you want to reserve tiles 0-63 for sprites, and the rest for the level.  When populating tile RAM, you would write your level tileset to tile offset #64.  Then each sprite you want takes up however many of the sprite tiles you need.  If a character is 4x4 sprites, you would perhaps devote tiles 0-15 to that character.  To manage frames of animation, simply write the given frame's tiles to tile RAM at the correct tile offset.

Sodthor's original version of CodeImage gives an output in a custom struct called SOD_IMG, and there is are included header and c files to use that format.

I manage the data a bit differently on my end where I have different structs devoted to different elements (levels, enemies, player, projectile, etc) and they each house the needed pointers to their image arrays.  I made a modified version of CodeImage, included in a separate directory that outputs only the consts that I then reference directly when building out a struct for a level, enemy, etc.

In my modified version I also added an option to save the converted image to a png file.  I like to use the converted image in Tiled when building levels.

I may have changed some of the defaults to better suit my needs, and the default name when saving.

Both original and modified versions are included.

Big thanks to sodthor for creating and sharing this tool!  I might have given up NGPC development if I had to stick with the other tools that are available.

Attached Files
.zip (Size: 121.73 KB / Downloads: 10)

Forum Jump:

Users browsing this thread: 1 Guest(s)