Two dull programming-related blog updates within two days? What am I thinking? Does anybody read this stuff? But I guess I'm excited because it's raining. In my game, I mean. I keep saying it's all about the small details but I genuinely think it's half the battle. Being able to add little touches without impacting too severely on the performance is one of the ways that Unity never fails to amaze me. When I set out programming this game, I assumed that my lazy techniques would soon punish the game's performance. I'm not by training an Object Orientated programmer, so it's taking time for me to come around to not writing things in a very linear fashion. I'm also writing this game for tablets and (I hope) mobile phones, which means I haven't got huge resources to play with. Each time I add a feature, I think the frame rate will be impacted hugely. Last night I added rain. Unity barely flinched. [Sidenote: the way I added rain was to create a long sprite, fading towards the upper end, a slight tear on the other. I then display about 20 or 30 of them (random intervals and timings on each) inside the camera bounds (don't waste precious CPU cycles drawing rain you can't see), and then I move them down as I very quickly stretch them. I also apply a gradual fade by adjusting the alpha values. Add a random angle of slant and with the right timing, they look just like rain. I keep reusing the same GameObjects to save time, repositioning/re-angling/retiming the line of rain as soon as it has faded from view. I also animated a few drops of rain splashing on the ground which I also randomly display. ] The effect isn't bad, as I hope you can see from this deliberately empty and uninspiring shot of my game. And, yes, it's mainly in black and white but it does have splashes of colour. The lack of objects on the screen accounts for the framerate nearly hitting 70fps, as you can see in the top left corner. I added that frame rate display to show me the average performance and the numbers are surprising. On the PC, the framerate is effectively about 450 frames a second (though, of course, my screen doesn't update that quickly). It means that the code could update the screen over four hundred times per second if called upon. In reality, 30 frames a second is what most games run at. Some of the newer games run at 60 frames a second, which is something of a gold standard for 3D games, and accounts for much of the current bickering between XBone and PS4 owners. My game is 2D so it's not quite so impressive to be hitting around 60fps on my tablet but that's (apparently) it what it's doing. It drops a little on my phone to somewhere in the 40-50fps but that hopefully means that I'm in a sweet spot given that my phone is neither the most recent nor the powerful. The more people can play this game, the more my efforts are worth it. Today it's about fixing more bugs, adding more content which I drew last night, playing and replaying each level to see if it feels right. I'm thinking about ripping out all the music since I also need to start to reduce the final size of the final app. It's compiling into a 45mb package, which is just under the Play Store's limit of 50mb (I believe you can go much higher but it involves breaking the app into different resource files, which is something I don't want to do). 45mb seems far too big for this game, even if it is packed with hand draw graphics which don't lend themselves to tight compression. The main problem seems to be five or six very large graphic files, which I'll need to reduce in quality. Hopefully there'll be no obvious visual impact on the game. Hmm… I push on.
Saturday, May 31, 2014
Friday, May 30, 2014
On Vube Talent, Alan Gogoll, Google Ads and English Folk Music
Morning was creeping over the local church by the time I finally fell asleep last night. I'd been working late trying to get a website finished but also struggling with a problem with my soon-to-be-published Android game. Taking a break from one kind of code or the other, I was browsing the web when I accidentally clicked on a link that took me a website called Vube. It seemed to consist of amateur (and not so amateur) musicians posting their work to be voted on by the public. It was apparent very quickly that these people are serious about their music. For 'unknowns', the quality of the videos was astonishingly high. The sound quality of most of the recordings sounded, to these ears at least, on par with something produced in a professional studio. Yet as I browsed through the performances, amazed by some, I was equally depressed by others. It's not the level of talent that I found depressing – though, I suppose the internet has collectively taught us that the world has an abundance of talent which routinely gets ignored. What I found depressing was the real lack of creativity. By a huge margin, the majority of these performances involved the word 'Cover' and I very quickly established how many versions of 'I See Fire' by Ed Sheeran a man needs in his life before he starts to root for dragons instead of hobbits. The answer, incidentally, is five. The experience reminded me of walking past those artists you usually find working in shopping centres. They work in pencil and produce amazingly accurate reproductions of famous faces. Because they work from published photographs, their work is a copy of another, so despite their copious ability with the pencil, it's all a mechanical effect. There's no true 'art' to their work. Nothing of themselves on the paper, though, of course, they clearly draw the chipmunk member of One Direction because that's what will sell. Likewise, there's very little of the people performing the covers on Vube, just lots of pitch perfect good looking young women singing songs that involve vocal gymnastics. Lots of seasoned instrumentalists proving they've mastered their instruments as well as their heroes but have no message of their own they feel willing or able to convey. There are exceptions to the rule, of course, such as the amazing Alan Gogoll whose genuinely original guitar work just shone above anything else on the site. It's strange how Gogoll's talent has lodged itself in my mind. I saw a video of his posted on another website a few weeks ago and (not recognising the name then) I stumbled across more here where his name has now firmly lodged. His is the kind of talent it's good to see emerging via the web. I don't know. Perhaps I'm just jaded. Everything about my work is rough and imperfect. I like that but also recognise it as a huge defect. I've mastered nothing, even if I put my heart and soul into every one of my projects. It also saddens me to see in linking to Gogoll's site that he earns a crust by performing at weddings. Reminds me of those amazing street musicians you see begging for coins as rich bankers stroll past. Some might say that the latter make the world turn but it's surely the former, people like Gogoll, who make it worth lingering around in that world. I'm neither a banker nor an artist. It's been over a week since I last blogged and I'm still slowly getting there with my game. Monday night, Unity updated to version 4.5 and immediately my game blew a fuse. As far as I can figure out by looking over their changelog, they'd fixed a problem registering touches on the screen which meant that my game had been calculating certain things based on the wrong values. With the correct values suddenly entering into my equations, things began flying all over the screen. That was a worrying few hours as I struggled to get my game back to where it had started. However, things began working again and they perhaps now work better than they did before. I'm now looking forward to trying a few of the other things the Unity gurus have fixed. Yesterday was what's commonly known as a 'ball breaker'. This week I've been trying to add ads to the app, which hasn't felt right. I've worked hard drawing every graphic in my game and I really didn't welcome the intrusion of ads for some woeful Kim Kardashian flab busting workout DVD. However, this is the world we live in, I need the money, and I had to face the more pressing problem of actually getting the game to compile with a library of code for Google Ads. At the same time, I've been using all my valuable time building a website for a nursery school (just as depressing as it sounds), with breaks from that relatively easy work broken my throwing myself into the ugly world of Java libraries, Unity plugins, and worse. Yesterday was a fourteen hour stretch of work (minus a couple of quick stops for food) but the website now looks complete but more importantly, the following appeared on my game's level select screen in the last hours of darkness. Damn, doesn't it look beautiful? The answer to my problem was to remove the old Unity plugin I'd been using to integrate my game with Google's Play Services and use the official Google plugin, which didn't conflict with Google's other plugin for AdMob, their ad delivery service. Beyond all of this, the last week has been about bug catching (both real [damn this muggy weather] and virtual) as well as adding small details, such as a credit screen that isn't a boring credit screen. I've also… Well, I really hesitate to admit this given my criticism of Vube, or perhaps out of shame, embarrassment, or what Stewart Lee once described as the horrible thought of 'a man trying to do something sincerely and well'… However, I've written a song for the game. The music has been bothering me since I began because I really like doing things myself and I didn't want to use third party music, even if it's in the public domain. I've been currently using a 1920s jazz recording as my soundtrack. I've yet to decide whether to keep it (it fits in with the theme of the game) or go without music. My song, however, is meant to accompany my credits. I can (but rarely) write songs but this, I think, isn't one of my worst. The lyrics are nicely twisted and, in my few spare minutes, I've even worked out an arrangement of odd finger-patterns for the guitar. All was good until I sat down and tried to record myself singing it. The guitar part sounds surprisingly good but the recording sounded terrible. A bad voice, my battered old Gibson acoustic fitted with new strings, and a £12 USB microphone doesn't make for a combination worthy of Vube. Yet amid the hissing and crackles, I could recognise something I've never realised about my singing before. I sound like a bloody English folk singer and that's not something that fills me with particular enthusiasm to try again, let along post to Vube, here, or the Google Play store attached to my game. I don't know why I should find this odd. Perhaps it's because I predominately listen to American musicians, with the notable exception being P.J. Harvey, so I my tastes are fairly attuned to American tones. My voice seemed naturally to drift to very different places which were purely English folk. Vocally I sounded a bit like John Renbourn or (now sadly late) Bert Jansch. My guitar work sounded like Bert Renbourn or John Jansch. Perhaps I need to hire a Vube star to record my song… I'm not sure what makes me uneasy about English folk music. Perhaps it's the image of middle-aged real ale-drinkers talking about church sculpture. I'm now trying to convince myself that it's not all bad. There's always Billy Bragg. I was buying superglue in Wilko earlier in the week (trying to repair my favourite USB cable -- yes, I have a favourite USB cables, mock as much as you like!) when they started playing Billy Bragg's 'Handyman Blues'. It's a great track from an excellent album but never before had I thought about the Englishness of Bragg's voice. Perhaps he doesn't sound enough like me to make me aware of his sameness. I suppose it's why, when I first started to read English poetry, I found Larkin unbearable. Eventually, I realised it was only because I was responding to a world he was describing which felt too much like the grim world around me whereas a poet like Ted Hughes felt elevated, distant, heroically what a poet should be. I found Larkin's similarity too unsettling and only after a very long time did I begin to enjoy his poetry without that sense of suffocating identification. All of which is me rambling slightly because I can. I needed more sleep than I got last night. This is the dull reality of what should (and, in truth, usually is) a fun business. Today I really want to devote itself to rain, as I'm suddenly taken with make a late addition to my game in the form of an aesthetically pleasing rain effect. But perhaps I should just get the game finished and out the door. It's taking far too long to get everything right.
Monday, May 19, 2014
The Angel of High Satire
I seem to spend my life between identities. What do I mean by that beyond trying to sound profound? I suppose I mean: I don't know what I am. So many people seem to define themselves by their jobs or their religion or their marital status and number of children. I don't really have any identity in those respects. I don't think of myself as 'a writer' and even when I had a book in bookshops, to say 'I'm a writer' felt hollow and not entirely truthful. I never say 'I'm a cartoonist' because I haven't had any cartoons published and I refuse to spend the rest of my life being Private Eye's least successful would-be cartoonist. I'm not an illustrator, though I occasionally provide people with illustrations. I'm not a web designer though I sometimes build websites. Nor am I an animator, though I've made a few animated shorts. I can't even say that I'm an academic because my PhD never led me into any academic post of significance. Now that I'm programming again, I am reluctant to call myself a programmer because the programming is only serving an end as far as another of my non-descriptors, that is, the cartoonist part of me. I've spent two months (or is it now three?), building a game which is little more than a very large satirical sketch or (more accurately) oafish cartoon. It's taken as much efforts drawing the graphics as it has programming the code. I'm part proud of it as I am part ashamed of it. The whole thing is meant to be satire, which is why, over the weekend, I added the following character to the game. At the moment, he flies onto the screen at random moments to add a little difficulty (and some reward) to the challenges. Yet I suppose my 'Angel of High Satire' (is the minuscule penis too much?) is a way of my acknowledging that everything I do is really directed towards satire. I suppose I might call myself 'a devil of low satire' because I think it's always been the closest description I would recognise of myself had I actually achieved anything of note in that field. I don't think my game will change that, though I hope it will have a enough edge that people might share it and laugh for all of the few moments they play it before deleting it forever. The humour might not be up to quality demanded by the real High Angel of Satire, on whom I modeled my version, but it has amused me. And that's the problem. My worry now is that the game contains too many of the things that amuse me such as the thought of a naked Ian Hislop providing the game's hardest challenge. I wish I could have created something playable by somebody other than that person I see in the mirror. Next time, perhaps.
Unity2D: Creating An Explosion Effect
A quick video I put together to show my workaround for the missing AddExplosionForce2D in the Unity engine. It's probably of interest to nobody out there but it gives a good idea of how Unity works and the very basics of making things move around on the screen.
Saturday, May 17, 2014
Small Details
Writing this feels like I'm coming up for air. I read an article somewhere the other day which suggested that it takes six months to develop even the simplest game. I'm not entirely sure that can be correct, but, perhaps taken as an average, it's probably much closer to the truth than the fabled 'couple of days' it took the Flappy Bird genius to weave his magic. At the other end of the genius scale where things don't come easily and everything is a struggle, it only feels like I get closer to the end as I tick off the increasingly mundane tasks that dominate my 'To Do 'list. Beyond that, I spend most of my time fixing bugs and populating my levels with graphics. My problem goes back to the beginning when I didn't so much design the game as start to play with Unity and a game gradually began to emerge. My game levels are potentially huge, though there are limitations which means not every square inch needs to be populated with landscape. I'm naturally reusing assets all the time but I need to break that up with unique graphics, which is where most of my efforts are not deployed. The bug fixing takes the longest. A bug earlier in the week took two days to figure out but taught me an important lesson about the difference between Unity's Awake() and Start() methods. Compared to that, coding new features is an absolute pleasure that rarely takes a very long. The exception to that rule was the problem I faced creating explosions in my game. Having explosions came pretty late in the process and I thought it would be an easy thing to add. Unity has an AddExplosiveForce method which you can add to game objects so they act as a bomb, pushing other objects away. However, Unity separates its 3D functionality from the 2D in an obvious way. If a method is designed for 2D games, it will have '2D' appended to the end of the name. So, for example, there's a RigidBody component, which makes a 3D game object respond to gravity and forces. There's also a RigidBody2D component with does the same for 2D objects. AddExplosiveForce adds an explosive force to a 3D object and, as you'd guess, AddExplosiveForce2D would do the same for 2D objects. Except Unity doesn't currently have AddExplosiveForce2D which meant I had to write my own. It took a day but I solved the problem and my explosions are now working well, with sticks of dynamite even destroying other objects with a nice blast that radiates out. However, it's an example of how I'm spending my days implementing features which are only a very small fraction of the finished game. Not everything takes so long. I'd been putting off adding more online leaderboards to the game but I finished that just now, perhaps half an hour's work to add 30 leaderboards, one for each level I'm currently planning to include in the finished game. I also finished adding the majority of my 'achievements' and they now stand around the fifty mark which means I'll have to spend extra time checking that every one of them works, which means yet another game reset so I can play through it and unlock the achievements myself. Even at this relatively late stage in the process, I'm learning new things. The surprising thing I've recently discovering is that it can be really small things that make a difference. Attention to detail is important. Just as a whim, I added a very small detail to the game about three days ago and it has completely changed the game's dynamic for the better. It was an addition I made simply to add a little variety to the gameplay but it completely changed the way the game feels. The same is true of sound effects. I still have a few sound effects that don't fit but those that do really make a difference. In a way, I suppose all of this is my way of saying that 'things are coming together'. As it stands, the game is pretty much finished in terms of the gameplay (though I constantly worry that there are times when the player doesn't have enough to do). I have quite a bit of level design to complete, but that simply comes down to my finding the time to draw custom graphics for the different challenges. On top of that, there are things to write and I have to create some tutorial mode or, at the very least, provide instructions on how to play the game. Then my final step will be to add some advertising, which I'll do simply in the vague hope that it might earn me a few bob when others try this game. I don't expect it to hang around on people's smartphones and tablets for very long but I'd like to maximise whatever revenue I can generate. All this work should have a point and, I admit, at the moment, I fail to see what that point could be beyond my own amusement.
Thursday, May 08, 2014
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.
Thursday, May 01, 2014
New Month, Old Problems
The start of a new month so I thought the very least I should (and could) do is write a blog post but, as you can see, ended up also posting a brief video about Unity. I suppose the video proves that I am actually working on something, even if my usual reticence about ongoing projects means that I'm not ready to send it out into the world. I'm also horribly aware that the previous app I wrote still hasn't emerged. To be honest, I still haven't decided what to do with it and I haven't the time to invest in finishing it with the degree of polish I'd expect from any published app. I just never have enough time. I'm not entirely sure what happened to April. The month went quickly, dominated as it was by trips to various local (and not so local) hospitals where my sister underwent a series of increasingly unpleasant (for her) investigations and then procedures. I'd like to say that she's feeling better but she isn't. Nor are we much more advanced in knowing the cause of her long time illness. Things have been found but no real explanations give. We have a few ideas, some theories, but, as ever, we await somebody who might actually understand it and wish to treat it. As for myself, I've just been trying to keep my head down and plough on without stopping to think too much. Reflection breeds misery so I haven't stopped drawing and coding. You might also have noticed that the month ended with a rarity. I exceeded my bandwidth and this blog disappeared for three whole days as I waited for the new month to bring a bandwidth reset. There might have been some way for me to keep it running but I refuse to plough what little money I don't have into something that earns me nothing. I don't honestly know why I keep on with this charade, though it was a little gratifying to learn that my outpourings are now being archived for posterity by the British Library. So, hello people of the future. [Waves forlornly across time and space] Speaking of earning nothing through my labours: as the video proves, I'm *still* toiling away on the game. I'm well past the stage where I should have abandoned it for something better. I have better ideas than this and the gameplay mechanic still has a flaw in that I still can't widen the player's view to give them better control over events. The only thing I can say positive about the game is that it makes me laugh on a regular basis and that, ultimately, is the only thing I'd intended when I set out to create this monstrosity. I now feel like I'm in the Unity2D zone. I keep getting better ideas for better games which I think I could build. Last week, I had an idea for a simple game and I built a working prototype in less than two hours. If I had time to devote to it, I might work on that simpler game. I have a Unity mindset and my projects are now mainly constructed in code rather than using the visual editor and nothing in my game exists long than they are needed. I think I've said before that the beauty of Unity is the ability to create and destroy GameObjects: which are containers for graphics, sound, and even game logic. If I were making a tennis game, I could simply create game logic for a single's match or a different set of logic if you're playing doubles. The last couple of weeks have been about small things: getting menus working, unlocking trophies, and victory messages. I have a high score system in place, though it's not connected to any internet leaderboards which I would eventually like. My one obstacle remaining is really learning about serializing data but that is for another day, week, or even month. The other stumbling block is music. Sound effects I've pretty much solved by going around the house snapping twigs, hitting pans, and making grunts into the microphone. Again, I'm not much of a foley artist but the effects don't sound too bad. I wish I could say the same about the music. Ideally, I should find some musician willing to provide a little background jingle but I've ended up doing it myself. Not having a proper MIDI keyboard limits what I can do. I've borrowed a Apogee JAM from a friend so I can connect my guitar to the PC but I don't have facilities to really record my battered old acoustic guitar and my (almost as battered) electric sounds too grungy. So far, I've had only limited success primarily because the sounds I like to make don't at all fit the game which requires something more comical, possibly played on the tuba. But I could waffle on like this all day and I have jobs to do instead of talking to myself and people in the year 2153 studying low-end blogging in the 21st century. I'll blog again, hopefully before this month's bandwidth runs out. Not that I'm complaining that the blog gets visitors but I'm sure it's only people looking for America's hugely successful Spine blogger who talks only about spines. That's clearly where I've been going wrong...
Subscribe to:
Posts (Atom)