Rise of Kramora, now available for Android (phone)

Well,  I just felt like I had to make the game available for phones as well because:

  • … not many people has Android Wear smartwatches these days
  • … specially, wanted the 7DRL jurors to be able to play.
  • … wanted to create a native android app
  • … wanted to test how hard it’d be to create an app to run in both type of devices.

This mean you can play the game now in your Android Phone! have in mind that this is STILL the original 7DRL edition. I haven’t made any enhancements to it! You can find more info about the 7DRL release here. Basically, don’t expect a revolutionary game, but I hope you can find it entertaining: The main goal (game-design-wise) was making something you could play any time, without any commitment, but still find challenging.

Play now for free!

onphne

In order to make it happen I had to move some things around, creating an Android Library module on Android Studio, moving all the generic code and resources into it and linking the wear and mobile modules with it. This module contains the game classes (the “model”), the sprite “engine” (i.e. the library for sprite management and tweens) and the generic view (based on an android.graphics.Canvas, and thus compatible with both the wear and mobile modules) and controller.

Screen Shot 2016-03-21 at 7.53.42 PM

The wear module was then left with just the WatchfaceService (wired to the Game, View and Controller); since it has built-in messaging-based timing functionality, it could easily be wired to the sprite engine, to provide animations at a given frame rate (24FPS).

The mobile module, on the other hand, had none of this…. Fortunately I stumbled upon this tutorial, which was very helpful on creating a simple rendering engine backed by a SurfaceView, which in turn was wired to the game, view and controller. Lastly, there was a simple Activity which set the SurfaceView as its ContentView.

The hardest part however was memory management… because of its 7DRL nature I was pretty sloppy, loading all bitmaps (AND their scaled version) into memory. For some reason it went well on the initial Android Wear version, but the bitmaps on memory were just too big for the phone.

The first change I had to make was no longer storing the scaled versions, but rather using methods to scale them on the fly while drawing. It’s a balance of processing power vs. memory, but it seems to be able to handle it pretty well. However there’s still room for improvement, I may revisit this if I find out it’s a big problem.

After this, and adding a “wristwatch” border, the phone version  was almost working, then I wanted to double check the watch version and, weirdly, tons of memory errors happened.

Oddly, I spent lots of time just trying to get the Wear version working back again…  I did lots of changes, including loading bitmaps on request instead of caching them, but I did it on the main thread because I needed them available immediately (bad idea). It worked, but was pretty choppy so in the end I discarded that, and settled for manually downscaling all the game graphics from a 512×512 base to a 320×320 one, which made sense since in any case that’s what most Android Wear watches are up to now. (and in any case it should upscale for newer devices).

In any case, I hope you enjoy it! Please let me know if you run into any issues running it!

Leave a comment