Beginning Android Game Development
Tag Archives: gaming
Last week I installed the Java JDK, Eclipse, Andoid SDK, and the ADT Eclipse Plugin. I then followed the LibGDX starter project walkthrough.
That single class project weighing in at just 150 lines of code (including whitespace and proper formatting) does a lot. It uses an OpenGL camera, loads image files, draws them to screen, responds to user input, plays soundfx and music, and has a simple game mechanic that makes it a basic game. Not only that, the game could be played on my dev laptop, and on my Xperia Play with no code changes. I was impressed.
Instead of going on to create LibGDX pong and slowly working up from there (as was my original intention) I decided to play around with the example project a little. The bucket became a spaceship and the raindrops enemy UFOs (each had their own class), nobody had any weapons, the UFOs were kamikaze maniacs and moved at varying speeds, aim of the game – avoid being hit. I added the concept of score and health, for each successful evasion you earned 10 points, for each impact you lost 25 hp. Four hits and it’s game over. Still very simple, and kinda fun.
Next steps would have been to introduce weapons, after that more enemy types, then a highscore table, then animated sprites, then maybe an end of level boss, then lots of levels to work your way through. Before you know it I’d have my very own r-type clone on the marketplace! But that’s not what happened. I started worrying that I was doing it wrong, not following the ‘correct’ path, not making the right design decisions. I read a couple of great tutorials (obviam.net and steigert.blogspot.co.uk) and immediately tried to implement those best practices in my simple app. At this stage, as a beginner, it was overkill. I ended up with a confused mess of files, and when extending I was often unsure if I was putting code in the right place. It was so much more fun when I was freestyling, making it up as I went along. Sure it could end up biting me on the ass later, but maybe I should just deal with it later and focus on making a fun little app for now. That’s when I stumbled across this excellent blog post. Here are a couple of choice excerpts that resounded with me:
- Don’t Obsess – your code is your code and I know you love it but how beautifully shaped and how wonderful the architecture is doesn’t matter one bit to the end player, especially if the game doesn’t ever get to be playable. Do not obsess about your code. Make it work. Make it quick enough. Make it pretty. In that order.
- More than one way to skin a cat – there are many ways of approaching any problem in software. There are normally a set of “right” ways that are well explained in long tutorials on the web. You go off and read the tutorials and you start implementing… You’re not entirely sure you understand what you’re doing, but you just keep going. WAIT! STOP! How about you just code it the “wrong” way for now, just make it work and if it doesn’t feel right later replace it.
Wise words indeed.
Grand arcade games can wait. I’m going to follow my original plan – I’ll write a LibGDX pong game. Then I could take what I’ve learned and write a breakout game. Baby steps that result in regular releases of small working games. I’ll likely end up using really bad practices, but I’m doing this primarily for fun and the joy of creating a working game others can play, learning is a secondary concern. If and when bad design leaves me in a fix I will learn a first hand lesson and better understand the benefits of a rigid design pattern, but to start with I’m just gonna be jammin – I’m going to let myself make my own mistakes!
Way back in the 80’s I received an Atari 2600 for Christmas. It was awesome. Let’s forgive and forget the crappy graphics, the dodgy one button joystick, the awful sound processor… None of that mattered. This was a machine that transformed my tv into a damn arcade machine – how could it be anything other than awesome!?
I loved my Atari. I spent hours playing classic games like space invaders, pacman, and centipede. But the following year Santa brought me a Sinclair Spectrum +2A… The Atari’s reign as toy-king was cut short. What can I say, I was a fickle child and this new machine could not only play games – it came with the promise of me creating my own games too!
The Spectrum holds a very special place in my heart. I know many of my generation can say the same. I still have it, it has survived numerous house moves and clearouts, I will probably still have it the day I die. Why? Was it the perfect machine? Blisteringly powerful and immune from Moore’s law? No. But just like the Atari, it was awesome all the same. My time was spent playing Dizzy, Manic Miner, Chaos, Arkanoid, Klax, The Great Escape, Deathchase, Potsworth and Co, Wonderboy, New Zealand Story, Blob the Cop, Wizball, numerous text adventures, and so many other great games that I can’t quite remember right now. There was also the bundle of games that came with the machine, pretty basic games but fun nonetheless, Treasure Island, Oh Mummy, Crazy Golf, Punchy, Disco Dan, etc – poor graphics and sound, but solid game mechanics that made them fun to play regardless. I’ve played worse playstation / wii / 360 games than some of these ugly spectrum games. Sure the modern platforms have the aesthetic upper hand and bags of processing power, but if the game itself is no fun, all it boils down to is an exercise in turd polishing. A fun ugly game beats a rubbish pretty game hands down.
Sinclair did all they could to make writing your own programs pain free. The +2A had a basic parser built in, and a tape deck for saving/loading your work. The manual was mostly dedicated to the basic language, and there were loads of third party books and magazines available that included sample code for you try out. In a pre-internet era I spent a lot of time with that manual, my Your Sinclair and Sinclair User magazines, and anything relevant I could find in the library. As a result I wrote some ugly fun games of my own. Pong, breakout, space invaders, that kind of thing. They didn’t really look much worse than some of the commercially available games, and played just as well, so it was quite a rewarding process! Of course distribution was limited to a very small number of my friends who were still in the least bit interested. The Sega Master System and Nintendo Entertainment System were out by this time, the Spectrum was decidedly uncool to those who were only interested in playing games, not making them. My audience was basically me, my family, and a couple of friends from school. It was a lot of fun creating though, I didn’t really care that the resulting game was pretty much just for me to play!
After the spectrum came the closed platform years. NES, Megadrive, PSX, GBA, PS2, PSP, Wii, Xbox360. Buy a consumer unit, play games on it, nothing more. Well, that’s not completely true, I did hack the wii and write a very simple target shooting demo a couple of years ago, but I felt way out of my depth and didn’t get very far at all. Similarly I started messing about with the kinect and unity, but felt like I was spending my time configuring someone else’s tool and not actually doing anything too interesting myself, so didn’t progress too far with those either. I’d say the nearest I got to writing games since the Spectrum days was either using the Game Maker engine to make some fun platformers, or writing basic Java apps for university assignments. Game Maker is a nice tool if you just want to create something fun to play, but I’d prefer to learn a language and more transferable skills than tying myself to an existing engine. The java assignments taught me some transferable skills (mostly forgotten by now), but weren’t all that fun. There’s another problem with writing desktop games too – trying to get people to play your basic puzzler with graphics the Atari/Spectrum could have achieved when they’re used to playing CoD and Battlefield is going to be an uphill struggle.
Enter Android, the saviour. It ticks all the boxes:
- Open and free SDK
- A thriving dev community
- Chance to learn some transferable skills (java programming, game design, graphics and music creation)
- Relatively mature LibGDX library – helps developers without reducing the whole process to a game engine config exercise
- Loads of devices, lots of people already have a ‘console’ capable of playing any game you create
- Marketplace to easily distribute end product (free after one-time setup fee of about £15)
- A natural leaning towards casual games – people are more likely to play your basic 2D fun game
So for a grand total of £15 I can create some simple games in my spare time and anyone in the world can download and play them? All the while I’m learning new skills and having fun? I’m in!
I’m going to be approaching this as a complete beginner, I will make mistakes, I will be inefficient, my games will likely look like crap, and I’m certain nobody will want to pay for anything I produce. My games will be open source, and I’m hoping to get them to a “finished enough” state that I can make them available for free on the Google Play marketplace. All the while I’ll be re-learning what little Java I once knew, maybe picking up a few tips on pixel art, and hopefully learning a little about making music. Eventually, I’d like to get to the point where I could enter a game development challenge like Ludum Dare and actually end up with a working game at the end of it. I’ll post what I learn here, but please be aware that any tutorials will probably be as far from best practices as you can get – I’m just gonna be doing things my own way and posting the results!