Pebble Programming

I’ve been following the news about smartwatches and other forms of wearable technology for some time now and find it very encouraging. Several impressive smartwatches are now available, including one that impressed me enough to buy it: the Pebble, which connects to iOS and Android phones via Bluetooth.

Pebble
My Pebble smartwatch.

I find it to be a fun, helpful, and stylish device, but my primary reason for purchasing it is tied to my interest in game development: as soon as I started reading about the Pebble I felt it would be interesting and educational to create a game or two for this unique platform. Because roleplaying games (RPGs) are my thing, I immediately whipped up design documents for a simple 3D fantasy RPG entitled PebbleQuest along with an even simpler game, MazeCrawler, that is in the final stages of development and will serve as PebbleQuest‘s foundation. [UPDATE: MazeCrawler and PebbleQuest are now both complete, as is the sci-fi first-person shooter SpaceMerc!] Creating the virtual world for these games has entailed building my own simplistic 3D game engine: an onerous task, even given the simplicity of my design and of the Pebble platform itself, but also fascinating and instructive, just as I hoped!

MazeCrawler
Looking down a long hallway in the MazeCrawler Pebble game.

And now, with MazeCrawler nearing completion and many exciting developments on the horizon with the release of Pebble SDK 2.0, I’ve decided it’s time to share my thoughts on the pros and cons of Pebble app development and the Pebble smartwatch in general as well as some comments about my forthcoming game apps.

Pros

First of all, virtually everything intended for the Pebble OS must be written in the C programming language. This is undoubtedly a “con” for some, but it’s a “pro” in my book, partly because I’m already familiar with C, but also because I have long admired its simplicity, power, historical significance, and pedagogic value. By modern standards C is a low-level language and is thus far more challenging and error-prone than higher-level languages such as Java and Python, but this facilitates much greater speed and efficiency, and by demanding a high level of care and rigor it encourages programmers to cultivate good coding practices.

If you’re interested in building a Pebble app, but are new to C programming, I recommend Stephen Prata’s C Primer Plus, 5th Edition. For those just looking to deepen their understanding of C or hoping for a quick yet thorough tour of the language, I recommend The C Programming Language, 2nd Edition: the classic work by Brian Kernighan and Dennis Ritchie, both important figures in the history of computer science, the latter being, in fact, the creator of the C language and co-creator of Unix who passed away in 2011 (to far less fanfare than Steve Jobs, sadly, but that is a topic for another time).

The C Programming Language, 2nd Edition
The C Programming Language, 2nd Edition by Kernighan and Ritchie.

Naturally, there is also an abundance of online resources, such as cprogramming.com and the CodingUnit Programming Tutorials, and never underestimate the power of simply googling about whatever obstacles you encounter along your way.

Speaking of online resources, there are already several helpful websites for those interested specifically in Pebble app development. There is an official Develop for Pebble website complete with thorough API DocumentationDevelopment Guides, and a Developer Blog. There’s also an official Pebble Forums site that includes a Developer Discussion area, and Pebble development is also discussed on other sites such as Stack Overflow and reddit. One particularly helpful member of the Pebble development community created CloudPebble: an online IDE that greatly simplifies the development process and is now officially sponsored by Pebble.

The simplicity of the Pebble is itself a positive feature in many ways. For a solo indie game developer like me, the small, black-and-white screen can actually be liberating: high-end graphics and memory-intensive gameplay are off the table from the get-go, so there is no pressure to create anything more than a fun and relatively simple game that can be finished in a short period of time. I also personally find it nostalgic: it reminds me of the early Macintosh computers that provided my first significant exposure to the world of multimedia and software development.

A Macintosh computer.
Hooray for black-and-white screens!

It’s also nice that, for now at least, every Pebble on the planet is virtually identical. There’s no need to worry about variations in processing speed, RAM, screen resolution, etc. This makes testing very straightforward: if your app performs perfectly on one Pebble watch, it should do the same on all of them.

Another positive aspect of Pebble development is the fact that the level of competition in smartwatch app markets isn’t (yet) as intense as that of Android, iOS, and other smartphone markets. There is excellent potential for finding a unique niche and attracting significant attention to your app. Of course, this is primarily due to smartwatch markets being smaller, but they are significant and growing larger by the minute: Pebble alone has already sold over 250,000 watches!

Finally, I’m ecstatic that the newly-released Pebble SDK 2.0 (and associated firmware update) provide several improvements and new capabilities, including:

  • New development tools that make it quicker and easier to build apps and send them to your watch.
  • Persistent storage and caching of data. This will make saving game progress much more straightforward!
  • Improved memory protection and logging of memory usage.
  • Dynamic memory management. Huzzah! Now we can use good ol’ malloc() and free()!
  • Improved data logging between watch and phone.
  • PebbleKit JS, which provides easy Android/iOS cross-platform integration via JavaScript.
  • Access to GPS data from the connected phone.
  • Access to raw, 3-axis accelerometer data (i.e., data about the watch’s movement and tilt). I’m not sure yet whether I’ll incorporate this into MazeCrawler or PebbleQuest, but from a game design perspective this opens up many new possibilities! Perhaps I should also start developing a 2D, top-down, maze-navigation game controlled by wrist movements…
Cons

Naturally, there are also a few cons to Pebble app development. Foremost among these, in my mind, is the current lack of a Pebble emulator and certain other more feature-rich, Pebble-specific tools to assist in testing and debugging apps. For my purposes, I’ve often been content to use an in-app text layer to report on the status of variables as the player moves about in MazeCrawler‘s virtual world, and the Pebble SDK also includes a handy logging feature that has been greatly improved in version 2.0, but it would be nice to have even more extensive debugging tools designed specifically for Pebble programs. Of course, there is an abundance of resources for general debugging of C code, but these are of limited use when dealing with issues peculiar to the Pebble environment. Perhaps CloudPebble will eventually expand to include more advanced debugging tools, including an online Pebble emulator?

While we’re on the topic of debugging, I suppose I should acknowledge more fully that, yes, there is one significant drawback to the Pebble’s reliance on the C programming language: even with modern compilers, it is a remarkably error-prone language. Knowing this from the outset, I swore I would never read or write past the end of an array or make any other memory-related mistakes, but it has happened a few times, causing my Pebble to temporarily freeze or immediately restart. One time, I even sent my Pebble into recovery mode! At first, I was concerned that I might inadvertently damage my Pebble, possibly even “bricking” it, but so far none of my misadventures have caused permanent harm (phew!) and the latest version of the Pebble SDK now provides more robust memory protection (again, phew!).

Another minor con: the standard C library is not available in its entirety on Pebble devices. This can be mildly frustrating at times, but at most it simply means a modicum of extra effort or ingenuity is required to complete certain tasks, and once you’ve accepted this fact, you may even find that writing your own ad hoc helper functions is yet another enjoyable challenge…or have I gone completely insane?

The Standard C Library, by P.J. Plauger
Not familiar with the standard C library? This book will get you up to speed.

As mentioned above, the small screen size and dearth of colors may be viewed as a pro or con depending on one’s taste and the task at hand. True, it makes some things simpler, but if you want certain kinds of visual effects—such as perspective, shading, and clear differentiation of surfaces in a 3D environment—don’t expect a walk in the park. Nonetheless, if you have the requisite patience and didn’t sleep too much during your math classes, you’ll find you can accomplish just about anything with the graphics functions, animationsbitmap layers, etc., provided by the SDK. Furthermore, I’m a firm believer that, so long as the overall experience is great, most people are willing to accept “retro” graphics and allow their imagination to fill in the details.

For game development, it would also be nice to have a few more buttons on the device. The Pebble has one button on its left side, usually reserved as a “Back” button, and three buttons on its right side, generally referred to as the “Up,” “Select,” and “Down” buttons.

The Pebble watch with its four buttons clearly visible.
The Pebble has four buttons: “Back” button on the left, “Up,” “Select,” and “Down” buttons on the right.

This is sufficient for many apps, but for games it’s often desirable to have obvious “Left” and “Right” buttons. One option would be to override the standard behavior of the “Back” button and employ it as a “Left” button, but this would likely frustrate some players as it would make exiting the game more complicated (or even impossible, if the game is poorly programmed). I chose to meet this design challenge a different way: in MazeCrawler‘s first-person 3D environment, the player moves forward and backward by pressing the “Up” and “Down” buttons and turns left and right by double-clicking those same buttons (“Up” for left, “Down” for right). Though not extremely intuitive, it is easy to get used to and is at least slightly intuitive if you play the game while wearing the watch on your left wrist: the watch will then likely be tilted such that the “Up” button is slightly to the left and the “Down” button to the right. Apparently many other developers feel the same way: the vast majority of relevant Pebble games I’ve checked out, including Rogue Watch, PebblisPebloid, Paddle WarsDroptype, and Asteroids, all follow this same convention of “Up = Left” and “Down = Right”. Of course, now that the new SDK is available, wrist movements may be a viable alternative for some games!

Finally, because I currently reside in Taiwan, I feel compelled to mention my disappointment that the Pebble OS does not yet natively support Chinese characters or any other writing system not based on the Roman alphabet. There are a few apps out there that provide support for additional languages, but those apps are still a little bit buggy and the notifications they produce aren’t as “pretty” as standard Pebble notifications, so I would like to see better options in the near future, preferably provided by the official Pebble team.

MazeCrawler and PebbleQuest

I’ve found working on MazeCrawler to be extremely rewarding. Naturally, there are frustrating moments now and then, as tends to be the case for any software development project, but on the whole I am enjoying the experience, learning a great deal, and gaining increased confidence in my software engineering skills as well as my problem-solving skills more generally. But enough about that: I’d like to offer a little more detail regarding what you can expect from my forthcoming Pebble games.

MazeCrawler will offer an infinite supply of procedurally-generated mazes for the player to navigate, the size (and thus difficulty) of which may be randomized or explicitly chosen. The point of the game will be, first, the simple joy of moving about in its surprisingly immersive 3D environment and, second, to complete as many levels and accrue as many points as possible (with larger mazes awarding more points). That’s pretty much all there is to it!

Looking at the entrance to a maze in MazeCrawler.
See that hole in the ceiling? That’s how you wound up in the labyrinthine tunnels of MazeCrawler. Now you must find a way out…

With PebbleQuest, things will get a lot more interesting. Instead of a mere “maze crawler,” this will be a full-blown “dungeon crawler“: it will offer an endless supply of procedurally-generated levels, much like MazeCrawler, but this time there will be enemies to crush and treasures to claim! There will also be an optional “main quest” storyline with several pre-designed levels, but the game will continue indefinitely even after completion of that quest. In typical fantasy RPG fashion, players will have a variety of weapons, armor, artifacts, and spells at their disposal—many of them customizable according to a feature I’m keeping secret for now—and players may choose how their character develops each time they “level up.” I’m tempted to reveal a few more details, but I think that’s enough for now.

If you’d like to stay up-to-date on the progress of these games, keep your eye on this blog as well as the following social media pages:

And finally, please feel free to leave a comment below. I’m eager to get feedback on my game projects while they’re still in development and I’d also love to hear your thoughts about, and experiences with, Pebble programming.

Enter the Drake

I’ve finally decided to enter the blogosphere, so here is my glorious first post!

My blog will focus on the following topics:

  • Game design and development, especially my own indie game projects, along with other areas of computer science and computer art.
  • Philosophical reflection on mind, mental content, information, language, consciousness, personal identity, the nature of human existence and human relationships, ethics, aesthetics, politics, and the origin, evolution, and destiny of astronomical, biological, cultural, and technological phenomena.
  • Creative writing, including my occasional forays into the unruly realms of poetry and speculative fiction (science fiction, fantasy, etc.).
  • Reviews of books, essays, movies, games, and other works.
  • Occasional reflections on my own life, my travels, my experiences as an American expat in Taiwan, current events, and so forth.

For now, that’s all I have to say. If you’d like to learn more about me, my background, and some of the projects I’ve been working on in recent years, please refer to my about page as well as my online résumé and portfolio.