A very long day yesterday thanks to Other Work but when not struggling to edit corporate videos, I found time to write some code. I also took the plunge and paid the $25 fee to become an Android Developer. By the end of the day, I had my first online leaderboard up and running as well as my first two achievements unlocked. Today I need to code a method of keeping track of all the game’s many achievements (I want there to be about 30+) as well as unlocking them as soon as they’re achieved.
The game has taken huge strides since Sunday night when, in a moment of rare clarity, I finally wrote the algorithm that had been eluding me for a month.
The game runs in 2D and involves a fair degree of parallax scrolling. Parallax is an effect you see in many games, most notably in Ubisoft’s new Child of Light, which I’ve taken a little time to play simply to enjoy the stunning artwork.
Whilst I can’t achieve anything like the Child of Light effect (my artwork is pretty woeful), I have programmed about eight layers of parallax which seems to run well on both my new tablet and my aging mobile phone. In Unity, that shouldn’t be that difficult since it’s a 3D engine and if you set up your layers in 3D and move a camera across them, they would naturally move in parallax with the more distant layers scrolling more slowly than those in the foreground. However, I’ve not followed that approach. I wasn’t sure that building an entire 2D world in memory would be the most effective use of resources so I took a programmable approach.
My 2D layers are constructed from patches and I only display those patches which are visible to the camera. I thought it would be an elegant solution so long as I could get a simple script to move each piece the right amount depending on their supposed distance from the camera. Finding that ‘simple script’ took about two months of work. Last week, I had about four different versions of my script working away at the same time, depending on the kind of scroll effect I needed for a particular layer. Each routine ran to a few hundred lines of code but, on Sunday night, half an hour of scratching on the back of an envelope and I’d managed to write a new routine which did the same job in 20 lines and could work for all my layers. It’s now running quicker and allows me to reposition the camera anywhere in the landscape. Previously I couldn't move the camera around by any large amount without leaving the landscape lagging behind as it tried to catch up. Now I can switch the view from point to point as often as I like, as well as occasionally widen the camera’s viewpoint to open up a larger view of the landscape.
I got up on Monday so delighted that I completely removed another function which allowed the user to slowly move the camera using onscreen controls. I’d been shying away from using touch gestures but found a simple explanation online and soon had written a routine to handle pinch zooming and finger scrolling.
So, the game is looking quite good, feels like a real game, and now has the online connectivity that I wanted.
I wish I could just figure out the remaining problems with the gameplay. It’s fun but I’m not entirely sure it requires enough skill. That’s my job for today, providing Other Work doesn’t slow me down.