Imperium Mini on Android (Released)

Hi all.

Having gotten bored with the strategy games on Android (a bunch of which I can’t play anyway, as Norway doesn’t have paying access to the market >:( ), I spent some time during vacation porting Imperium Mini to my phone.

http://www.micabyte.com/android/screenshot.png

It’s a pure 2D, turn-based strategy game on the rise and fall of Rome; an almost direct port of the PC game (also done in Java).

I ran into a bunch of trouble because I tried to build in support for multiple resolutions (medium and high - low resolution just didn’t look good, so I dropped it) since my phone (HTC Magic - Android 1.5) does not support this properly. Another problem was getting the screen to scroll smoothly and keeping the (rather large) background map in memory without running out. I do believe I’ve gotten most of the issues sorted out now, but I would appreciate it anyone with a little time on their hands would help me to test it out. I’m particularly interested in anyone who can test it on the Droid/Milestone or other large screen device.

Here is the link: http://www.micabyte.com/android/imperium.apk (2.6Mb)

It uses internet access and coarse location (for admob).

Here is the manual (also available in-game): http://games.micabyte.com/impmini/manual-android.html

A couple of known issues:

  • Manual and About dialogs sometimes do not load the webview on the first attempt. Very irritating problem that I haven’t found a fully satisfactory solution to yet (currently I have a WebViewClient waiting for the loading of the page to complete, but it seems it doesn’t always trigger). Anyone with a good tip on how to deal with this?
  • Dismissing dialogs in-game can take a little time. This is because the game is updating the game map, which will often require it to reload (to conserve memory) and redraw a lot of stuff (to allow for smooth scrolling).

An interesting little project to do; in particular, I found it quite interesting to note how what is in fact a very simple strategy game on the PC, easily becomes rather complicated when ported to a mobile device with all the limitations that brings with it (technically, interface wise and in terms of gameplay). But I do like the Android dev kit - just irritating with the 16Mb limitation and the problems of testing on X different combinations of screen sizes and OS versions. Anyone willing to exchange ideas on how to to deal with big bitmaps for a smoothly scrolling screen?

Running this on a Nexus One - I hired some units, tried to attack Sicilia, and got the following error:

01-26 10:02:05.156: ERROR/AndroidRuntime(23231): Uncaught handler: thread main exiting due to uncaught exception
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): java.lang.NullPointerException
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at com.micabyte.android.impmini.GameActivity.random(GameActivity.java:250)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at com.micabyte.android.impmini.game.Force.attack(Force.java:80)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at com.micabyte.android.impmini.game.Campaign.attack(Campaign.java:238)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at com.micabyte.android.impmini.game.Campaign.attackWithLegion(Campaign.java:957)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at com.micabyte.android.impmini.GameActivity.attackWithLegion(GameActivity.java:403)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at com.micabyte.android.impmini.gui.AttackDialog.onClick(AttackDialog.java:188)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at android.view.View.performClick(View.java:2364)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at android.view.View.onTouchEvent(View.java:4179)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at android.view.View.dispatchTouchEvent(View.java:3709)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at android.app.Dialog.dispatchTouchEvent(Dialog.java:643)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at android.os.Handler.dispatchMessage(Handler.java:99)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at android.os.Looper.loop(Looper.java:123)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at android.app.ActivityThread.main(ActivityThread.java:4363)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at java.lang.reflect.Method.invokeNative(Native Method)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at java.lang.reflect.Method.invoke(Method.java:521)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
01-26 10:02:05.196: ERROR/AndroidRuntime(23231): at dalvik.system.NativeStart.main(Native Method)

Thanks ernestw.

I’m pretty stunned; the variable that is being accessed there is created when GameActivity is created and only nulled if GameActivity is destroyed; I just don’t see how it is possible for that null pointer access to occur.

Nevertheless, it is easy enough to fix; I’ve uploaded a new apk that should handle the problem.

Works well now. Just finished a game and now it’s way past my bedtime :slight_smile:

I’m really liking this.

Thanks very much for the assistance. The official version 1.0.0 is released now on the Android Market. Hopefully people enjoy it.

I’ve been getting complaints that the game doesn’t save on Droid. In a true display of the usefulness of the Android market, of course, all I have to go on are a few comments, which is worse than useless as the market provides no way to follow up problems.

Would anyone with a Droid do me the kindness of taking the application out for a spin (can be downloaded from the link above or on the market), and help me by doing a little testing of the save/continue mechanism (simply break off playing the game and returning to it a couple of times). Thanks.

Nice job on 1.0.0, i’ll give it a spin later today and tell you the results.

Thanks Corvinex. I think I’ve been able to identify the problem in the emulator now, though (some malformed XML that had somehow slipped under the radar); so no need to worry too much at this particular bug. If you do find any other issues, of course, do let me know. Currently trying to see if I can make the interface a little more intuitive and streamlined. It’s interesting - but tough - to code for both small and large screens.

Well I’m glad you figured out the issue because I don’t see your game available on the android market. Must be a location issue, I’m in the U.S.

Hmm… that sounds weird. I have limited it so that it is not available on small screen devices (the text looks absolutely awful on low resolution), but that shouldn’t be a problem with a Droid. :wink:

[Edit]
Ah … I suspect I know the problem. The game is not called “Imperium Mini” in the market; it is filed under the name: “A Brief History of Rome