My first Android app


I published my first Android app last night. It's a pretty but fairly boring game (called RockinRoll) that I originally did for the iPhone, which I ported mostly as a learning exercise. The game has nothing to do with music; it is a match-3 style game crossed with a 2D physics engine that is hooked up to the phone's accelerometer. Different colored stones come out on top and fall, and how you tilt the phone controls where they fall toward. Making 3 or more of the same kind touch makes them disappear, and you get points. There are a few kinds of powerups that help you out too.




Here's one of the powerups about to go off:





The iPhone version of the game is written in C++, with as little Objective-C as I could get away with. I do not approve of Objective-C. It includes rendering code for both OpenGL ES 1.1, which was available on 2nd generation hardware, and OpenGL ES 2.0 which uses programmable shaders, and was available on 3rd gen hardware and up. The shaders let me do some special effects, and much better anti-aliasing than the 1.1 renderer. The iOS version of the game looks roughly like this:





Android applications are written in Java. Google also provides a native development kit, which lets your Java application load separately compiled C or C++ code and make calls into it. I tried pretty hard to port the GL ES 2.0 rendering path to Android; I have a Nexus 1, which supports ES 2.0 and it looks quite a bit better. Alas, nothing doing. I could not get it to work. I am pretty certain that the ES 2.0 support is just busted, either in the phone itself (unlikely) or in the NDK (I hope). There is a newer release of the NDK available than what I built with, so I should probably try again. Anyway, there are no shaders in the Android version, which looks about like this:





Some random thoughts on the two platforms:

- Sound on Android is tremendously easier than on iOS. It is still harder than it should be, but Core Audio on iOS can provoke true rage.

- When I published RockinRoll for the iPhone, I uploaded it and clicked publish and waited for over 5 weeks while Apple debated its worthiness for their platform. Last night I clicked publish on the Android Market backend, waited a few minutes, and it was available to my phone.

- Google's architectural aesthetic is much better than Apple's, IMO. The APIs are better thought out, easier to use, and Java is a much better language than Obj-C.

- Apple's technical domeepentation sucks meep. Google's is better, but still sucks.

- The busted shader layer really bums me out.

Decider: Admin

  • Wotak
  • Sep28 '10

    posts

    46.9k rads

    46882 rads

    #

*jealous

  • vasudeva
  • Sep28 '10

    posts

    254k rads

    254010 rads

    #

Nice. Hard to get my head around how those two diagrams can look so different. How much extra engineering effort was it to re-jigger for Android?

Tried to download it just now and couldn't find it on the market. Found a reference to it on another site via QR code that brought me to a "Not found" page on Market.

It shows up for me still, tho I had to reboot my phone before it would show me up-to-date data; it was still showing me what was cached from last night. The app declares that it needs Android 2.1 or better, which may not be entirely true; I should re-examine that.

In terms of code changes:
- there are about 600 lines of new Java code, which are responsible for app startup and lifecycle, setting up OpenGL, receiving touches and passing them on to the native layer, reading the accelerometer, running the sound engine. this replaced about 1500 lines of equivalent iOS code, with the sound layer making up most of the difference in size. there are about 500 lines of C++ code in the Android version that just handle interfacing to the Java side. JNI is a meep.
- time is very different on the 2 platforms. on iOS, time is a floating point number of seconds; on 1 frame "time" may be 1.0 and on the next, it will be 1.03. on Android, time is an integer number of milliseconds. all of the code that did timing related stuff - anything with animation, pretty much - had to be changed.
- loading resources is quite different, and was much easier on iOS: you pretty much just open a file and read it. that's how it would be on the Java side on Android too, but for the C++ code loading textures, and using save game files, it had to call back to Java and let the Java layer do all the I/O.

I guess that was about it. The GLES 1.1 code worked as-is once I got initialization working, as did most of the actual game, aside from the time issues. It was probably 2-3 weeks of actual work to port it, vs about 10-12 weeks for the original iOS version (including the ES 2 stuff, which was about 50% of that).

Wotak, it's a skill that can be learned very cheaply these days, if you have patience (and a certain degree of OCD helps a lot). The Android dev tools are all free, will run on Linux, Windows or Mac, and most new phones (I think?) will let you load apps over the USB port for testing and experimenting. Give it a try!

  • GrapeApe
  • Sep28 '10

    posts

    16.6k rads

    16646 rads

    #

I wrote a "paperweight" app for my blackberry, and by wrote I mean throw against the wall.Back to the old Blackjack now, funny how that piece of meep has outlasted 2 new phones. Got windows 6 loaded on it finally so I might actually stick with it for now. Hats off to your programming skills, it seams like pure voo-doo to me.

Turns out I'm not very good at this game, but it runs great on my Galaxy S: Runs smooth and the movement response feels good.

Ooh, now I'm the jealous one. The Galaxy S looks awesome. Any complaints with it?

Thanks for looking! I updated it last night and lowered the required OS to 2.0 so maybe it will show up in the market for more people.

The Galaxy S is great. Mine is the Captivate from AT&T. It looks great and feels solid. Its fast as meep, especially if you apply the Lagfix (i used ext4) and run the 1.2 overclock kernel. I'm getting Quadrant scores of 2000-2250.

My only real complaint would be the GPS fix time. Its taking 35-50 seconds to get anything closer than 1000m. There are some suggested fixes. but I'm not having much luck.

  • heimer66
  • Sep29 '10

    posts

    3318 rads

    3318 rads

    #

It runs smooth on my evo and I like how I can hit the back key without any "are you sure you want to quit" bullmeep, instead it pauses and is ready to start when I go back to it.

Saving your game when you quit and restoring when you start again was one of the hardest things to port from the iPhone, oddly.

Hey, anonymous person! Log in and comment.
LOki
also, dog jamming
pete56
on Interview With Charlie Watts: Great find. Charlie+
StartRecor+
Heather
(my meep)
JohnLenin
But the voice will be muffled on account of the fact that it's all the way inside a meep
JohnLenin
I'm putting you in the sequel as a talking catheter
JohnLenin
I will not be silenced
bobacus
oh shut up.
JohnLenin
Also, if dog jamming is my legacy then I will die happy
JohnLenin
fade out
JohnLenin
A bunch of meeping twats are sitting around sipping tea and making sure that one another is doing well and still in the room
JohnLenin
INT. SOME PLACE WITH MIDDLE AGED DUDES - EVENING
JohnLenin
also, the shoutbox would make a meep awful script.
JohnLenin
I didn't save the link to the script. Will have to reupload. unless someone from irc has it still.
linkswarm
queue: New link: Cold fusion, maybe p'raps?
StartRecor+
BeachGoat
MstrLance
The shoutbox could be a script, if we ever wanted to reenact the shoutbox.
spankerchi+
Linkswarm must live.
Senor_Smok+
While you're at it,fix the camphone thread stuff..kthx
Heather
Where is this LS script?
middle_age+
If a person can 'literally- step on a nail, is it safe to say that one could metaphorically step on a nail?
LOki
@ JohnLenin: Dog jamming. LOL.
spod
The Soul Rapers, great band!
bobacus
I knew I could get a rise out of you.
spankerchi+
Actually; I kinda DO.
MstrLance
You'll all sleep better knowing that JL is silently watching.
JohnLenin
I never bailed. I'm always lurking. Hard to chime in on the Dad-Bro circle. And if you compare me to dagwood again I'll rape your soul.
Cryogeneri+
bobacus
meep you JL. You bailed.You're just like Dagwood.
bobacus
By a state or two.
dragonstaf+
Hey Bobacus, sound off if the twister missed you.
dragonstaf+
JohnLenin
I'd like to cash in all of my unused textwar credits to ban everyone from this webbed establishment
spankerchi+
textwarred tesco until 2013-05-27 22:12:35
tesco
on Why Is It So Hard To Quit Smoking?: Next they will want+
linkswarm
queue: New link: Adios Ray Manzarek
bobacus
It was his rock hall acceptance speech. Its seemingly only on HBO.
dragonstaf+
Link?
bobacus
I want to give the award for the best speech, ever, to Alex Lifeson. I think he found Ozzy's dealer.
Danny_Infe+
Danny_Infe+
linkswarm
queue: New link: French theme park with giant mechanical animals
StartRecor+
Context is everything. http://www.youtube.com/watch?v=EaGKxAgCguU
StartRecor+
The drummer from Def Leppard's only got one arm!
StartRecor+
The drummer from Def Leppard's only got one arm!
StartRecor+
The drummer from Def Leppard's only got one arm!
StartRecor+
The drummer from Def Leppard's only got one arm!
meepbox
RIP http://www.lolserver.net/ like 6 months ago. :(
BeachGoat
on Why Is It So Hard To Quit Smoking?: We calculated the+
dragonstaf+
Bob Welch is DED by a shot to his own chest.
linkswarm
queue: New link: meep Trickle is Ded by a shot to his own head.
dragonstaf+
StartRecor+
StartRecor+
StartRecor+
linkswarm
queue: New link: Instagram blunder helps ID alleged thief
spankerchi+
on The Cost Of Masculine Crime: Oh, DO tell us+
  • pete56

  • pete56

  • mstrlance

  • beachgoat

  • startrecor+

  • spankerchi+

  • spankerchi+

  • spankerchi+

  • dragonstaf+

  • beachgoat

  • spankerchi+

  • pete56

  • pete56

  • pete56

  • beachgoat

  • beachgoat

  • beachgoat

  • spankerchi+

  • dragonstaf+

  • nurglets

  • beachgoat

  • startrecor+

  • spankerchi+

  • spankerchi+

  • spankerchi+