Recently, I have spent a lot of efforts trying to squeeze as much as possible in the tiny space of the Pebble Watch.
I now have a solid base that I can build content on.
To reach this point, I was only dealing with data in-lined directly in code as static arrays.
Convenient for prototyping, not so much for starting to produce interesting content....
This is what drive the need for tools. In the rest of article, I'm going through the various tools I have developed and used for this project.
Texture Tool - first generation
The first tool developed for this project was to generate textures as C static arrays.I made a little C# application that takes a PNG file and convert it into a static array that I could paste into my code.
From a tech point of view, really nothing fancy or complicated but this saved a lot of effort importing and testing textures in game.
The tool loads a PNG in memory, goes through the pixels, convert them in grey scale and output the values in text file.
The grey scale conversion is quite simple and is done by weight-summing the RGB values:
grey = (0.21 * red) + (0.72 * green) + (0.07 * blue)The weights are based on the human eye sensitivity to luminosity of each RGB channel.
So an image like this:
Would generates this code:
static uint8_t stone_texels[8*8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0x80, 0x00, 0x40, 0x80, 0x40, 0x00, 0x40, 0x80, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0xFF, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0x40, 0x00, 0x80, 0x80, 0x40, 0x00, 0x40, 0x80,};
This already saved me quite a lot of time, especially when creating a texture for the "Beholder-like" monster ( please do not judge my pixel coder art :) )
For the time invested in writing the tool (an hour or so), the return on investment has been great. This allowed me to have decent textures to prototype with so that I could focus on developing the features.
But I reached a point where I need to produce a larger amount of content in a more data driven way.
Level Tool - first generation
For levels are also used static arrays first. But no tool to generate those. All hand-typed...
Works great but they are increasing the size of the executable.
And most of the time, I don't need all this data in memory at the same time.
So far, I had only one level. As soon as I implemented the next-level-load feature, I needed a way to keep only one level in memory and load it on-demand from the application resources.
This necessity forced me to go write a tool to generate those levels in a binary format compatible with the resource API.
First, I decided to have each of my level as a JSON file. Having human readable and editable format is an important point to me as it helps me to iterate on the source data without having to rely on an external tools/program to generate this file.
To convert from JSON to binary format, I picked up javascript. Why?
- It parses JSON natively
- It easy to write
- There's a large set of available libraries for it
In an couple of hours (including a couple of trial and error cycles), I had my script converting my JSON levels in a binary format that I can add to my Pebble App resources.
(For the record, I do use NodeJS to execute my scripts)
I have now a mini data "pipeline" that I can use to feed content to my application without affecting its size.
Works great but they are increasing the size of the executable.
To convert from JSON to binary format, I picked up javascript. Why?
- It parses JSON natively
- It easy to write
- There's a large set of available libraries for it
In an couple of hours (including a couple of trial and error cycles), I had my script converting my JSON levels in a binary format that I can add to my Pebble App resources.
(For the record, I do use NodeJS to execute my scripts)
I have now a mini data "pipeline" that I can use to feed content to my application without affecting its size.
Texture Tool - second generation
With a tool for level, I needed now one to store textures in the application resources.
But ... why not using the SDK provided support for PNG images?
Well, I'm not using GBitmap. I'm using my own format. With my own format, I'm in control of the size, packing and performance...
In a similar way to the level tool, the texture tool is made with JavaScript and run with NodeJS.
It takes a PNG image and extract the pixel and color information and transform it into my proprietary binary format ready for the application to process once loaded from the application resources.
With this set of tools, I have a robust way to channel the content data in the application resources in an optimized way.
Tools are investment, you invest time in them, and you get returned time from using them.
(This can be measured as ROI, how many hours of work are you going to save by spending an hour writing a tool)
From the few hours I spent writing those tools, they certainly saved me my countless of hand editing, byte level tinkering headaches.
So what are the next steps now?
Well, the level editing is still done in a JSON file. It's simple enough but if I add more features in the future that requires more complex level data, I may need to develop a more friendly "level editor".
on this note, and talking from experience, writing proper level editor can quickly become a time consuming task that take you away from the main feature development.
I'm curious about what kind of tools Pebble Watch Game makers are using.
Please leave a comment to share your experience and give some feedback about it.
You can find the second part of this post here.
But ... why not using the SDK provided support for PNG images?
Well, I'm not using GBitmap. I'm using my own format. With my own format, I'm in control of the size, packing and performance...
In a similar way to the level tool, the texture tool is made with JavaScript and run with NodeJS.
It takes a PNG image and extract the pixel and color information and transform it into my proprietary binary format ready for the application to process once loaded from the application resources.
Next steps
With this set of tools, I have a robust way to channel the content data in the application resources in an optimized way.
Tools are investment, you invest time in them, and you get returned time from using them.
(This can be measured as ROI, how many hours of work are you going to save by spending an hour writing a tool)
From the few hours I spent writing those tools, they certainly saved me my countless of hand editing, byte level tinkering headaches.
So what are the next steps now?
Well, the level editing is still done in a JSON file. It's simple enough but if I add more features in the future that requires more complex level data, I may need to develop a more friendly "level editor".
on this note, and talking from experience, writing proper level editor can quickly become a time consuming task that take you away from the main feature development.
Conclusion
I hope you enjoyed this article as much as I enjoyed writing it :)I'm curious about what kind of tools Pebble Watch Game makers are using.
Please leave a comment to share your experience and give some feedback about it.
You can find the second part of this post here.

