Rogue for Android
This is the story of how I came to find myself porting rogue to Android.
I’ve played various roguelikes on a number of occasions over the years. One in particular stands out for me though. It was called PocketRogue and it was a straight port of rogue for PalmOS. I played it on a Treo, where the keyboard came in handy. I even got the source code but it was a CodeWarrior project that I never managed to port to the prc-tools environment.
When I got an Android phone I looked for roguelikes but was sorely disappointed in what I found. There were lots of apps available but most of them just didn’t work on my phone. I get the feeling most of them were designed to run on larger tablets with a physical keyboard attached or something. Luckily though, I found the excellent Pixel Dungeon (and later, its many forks) to satisfy my roguelike cravings. However, despite being an excellent roguelike that actually plays well on a phone, I find myself sometimes missing the simple charms of the classic ASCII interface and the simpler gameplay that rogue has.
So I did some experimenting…
I toyed with the idea of making a roguelike from scratch. I made some C++ code that used curses and looked a bit like Rogue. I even played around with viewport stuff (ie. handling smaller screens).
I made a Curses API for Java that called real curses to do its work. I ported the C++ game code to Java. Running on my computer in a terminal window.
I made a Curses API for Java that renders to an Android canvas and treats clicks on the screen as direction characters. Same code as before now running on my phone.
I ported the Rogue level generation code to Java. It wasn’t too bad. But porting the whole Rogue codebase to Java? That was going to be a pain (even if it was largely mechanical).
I made a Curses API for C that calls the Java API (through JNI) to do its work. My original C++ game code could now run on my phone.
Which brings me to the final arrangement, using the PocketRogue source code against my Curses API. The code was already nicely separated between core game and UI bits so it was quite easy to identify the things I needed to implement. I did put a viewport layer between the C code and the canvas so the game didn’t have to learn about small screens. Along with the pre-existing input functionality I’d done, I put up some buttons for actions, got list selection working and state save/load.
I’m sure there’s still problems and things that need to be fixed, but by and large, the game can be played.
Another old favourite from my Treo was kMoria. I might see if I can bring that codebase to life in the same way…