Sunday, October 27, 2019

It is 2019. How do you develop a native Android app?

Back in 2011, my first attempt on porting to Android was to compile the existing code-base as-is, in Objective-C. With a third party Stella-SDK you could pretend your Android Device was an OpenStep device, very much like an iOS device. However, this never fully worked, so had to be abandoned.

The second approach is the approach I am using to this day, for creating my Android portfolio: Use a sliver of Java, and write the rest in C and C++. And you can use JNI and android_native_app_glue.h to bridge between them. The sliver of Java came in the form of the NativeActivity class, from which you derived your application activity. Building was initially done with ant and ndk-build, but I've moved to AndroidStudio since then.

Skip forward to 2019. I am considering an Android port for my Windows/Linux title Hexa Trains. Unsurprisingly, this is a C/C++ code base, so it would entail another native Android port. Is Java's NativeActivity still the way to do native app development?

Google has been pushing Kotlin for quite some time. I've always held off on that. I wonder if it is still something that has Google's focus, or did they move on from that already? But I guess Kotlin and NDK is an option?

I guess most (sane) gamedevs just use Unity and be done with it?

Tuesday, October 22, 2019

Horror Vacui

Aristotélēs postulated that Nature abhors a vacuum. There is probably an equivalent postulate for the Internet Age about unused computing resources.

I've been dumbfounded many times about the ridiculous amount of bloat in software.

Be it the 18,000 classes in an iOS app. That is 18,000 classes, mind you! Not 18,000 objects.

Or the enormous big ball of mud that imgur uses to serve an image.

Or the 1.2M lines of code to simply boot an OS. Not the OS it self, mind you, just the boot system that lives on top of the OS.

I think these things grew out of control purely by the grace of fast computers. Moore's law makes them faster, more powerful, and immediately sloppy engineers fill it with a plethora of layered frameworks.

It would be better if all software engineers were forced to use a decade old computer, so that teraflop machines will not be brought to their knees trying to load a webpage or something. Leave the modern and fast machinery to the users and clients, but develop the software on Raspberry Pi's maybe?

So, are you a software engineer? Please surrender your dual GPU, 16 core machine to the bureau of software simplification, and compile, link, test your software on the Raspberry Pi that will be provided to you. No ifs and buts... that Raspberry Pi is vastly more capable than the Apollo 11 Guidance Computer. It will do.

Nature abhors unused RAM and CPU cycles.

Thursday, October 10, 2019

Itch.io achievements.

I got a couple of requests for Hexa Trains to be available from itch.io and not just Steam. At first glance, that should be easy enough, I've published stuff there before.

But with Hexa Trains there is a complication in the fact that the end-goal of the game, is to unlock the Steam Achievements. And without achievements, that goal would be missing.

Itch.io has no Achievement/Leader-board API. More than that, it does not even have the concept of User IDs, nor logging in via the game. So what would achievements on an Itch.io version look like?

I thought "Can you do leader-boards without a log-in system? And then I quickly remembered the 1980s. Getting listed in the leader-boards by writing your three letter initials.

So at the very least, something like this is possible. But in modern times, there is more to record than just a single number for the high score. All sorts of statistics are tracked between sessions. For instance, in my game, the number of rail sections laid down.

So, we still have the problem of tying a player to the statistics. But do so without adding the hurdle of a log in step. And tying the player to a name should be optional, like it was on a PacMan Arcade Cabinet.

Thinking about this problem made me want to see if I could write my own Open Sourced Achievement/Leader-board system. So let's start with the requirements.

  • No log-in stage.
  • No user id.
  • No email address.
  • Name/Initials optional.
  • API similar to existing frameworks (Game Center, Steam, Google Play.)
  • A server to keep track of progress and scores.
  • Don't track between different game titles.

I think something like that could work. Step 1 would be to generate a random number to be used as a unique ID to identify a player for this specific game. All subsequent launches of the game title, should use this ID when reporting scores and achievement progress. There will be no name/initials associated with this ID, until the player chooses to do so.

To preempt any pranksters wanting to be obscene, racist, or otherwise, the optional name should come in the form as 3-letter initials. It is too hard to be obscene in English, using just three letters. (You can be in Dutch, though. But meh.) This removes the need for moderation by humans. (Duplicate initials is not much of a problem. Stats are tracked separately via the ID.) Also, Latin-alphabet only would be a safe choice with respect to obscenities as well. Less expressive means safer.

I also think it would be a good idea to be as lightweight as is conceivably possible. And it doesn't get much lighter-weight than single-UDP-packet fire-and-forget communication. Stat updates could conceivably get lost, as could scores. I think we should just ignore that. If stats are reported in absolute values, it will get corrected in a future report. If it is reported as deltas, meh.

Note that achievements could be a purely local thing. No need for a server. Only high-scores would need to be shared. But for sake of symmetry and versatility, both via a server could have benefits.

There is still the issue of presentation. The player needs to be notified of unlocking an achievement. How? Put that burden 100% on the game developer? A nice thing about Steam/iOS/GooglePlay is that you don't have to think about that as a game developer. You report the stats, the system will tell the player if it is appropriate. But how would you do this without having control over the game's window?

Let me conclude with: what are your thoughts on this? Leave a comment!