Pages

Thursday, 26 October 2017

Greedy Caterpillar - a snake game for touchscreen and TV


Snake

Little by little, TheInvaderOne is growing up. She is now three and a half years old 😮

Her little sister, TheInvaderOneX 👶, is eight months old, and is now very interested in the Sensory app. She's also interested in whatever her sister happens to be up to at the time, crawling at light speed, making valiant attempts at walking, and trying her damnedest to "eat all the things".

Big sister has smashed it on the numeracy front, and has left the Count 1 to 10 app for dust. We're in the big leagues now - she has 1 to 100 cracked, addition and subtraction of small numbers sorted, and is starting to get to grips with simple multiplication and division. Of course, we're not drilling numbers, letters, languages, etc 24/7. She loves absorbing knowledge - she's like a sponge, but we don't want her to burn out before she even hits school - being bored at school from day one due to them not teaching her anything new would likely be a disaster! No, there needs to be plenty of downtime... Sure there's loads of toys to play with, and imaginative play, and creative crafts, and baking, and stories, and a bit of tv (if you have kids around this age and want to combine cartoon time with learning, check out Go Jetters and Numberblocks, both big hits in our home at the moment), and seemingly endless unrelenting viewings of Frozen, but she's also seen what Daddy does to unwind - play and make games, and she wants in!

Ok, so making games may be a way off yet, but playing them was definitely on the cards. My other half bought me a Raspberry Pi 3 starter kit as a birthday surprise, it's now a dedicated emulation machine, with a lovingly curated list of games on there. It's pretty much a NES Mini, and a SNES Mini and a "Many Other Platforms Mini", all rolled into one. My eldest has particularly enjoyed playing Centipede and Barney's Hide & Seek. She loves the arcade action aspect of Centipede, but the move from touchscreen puzzle games to a joypad controlled action game was a pretty big step, and before she truly "got it", it was game over. Over and over again. The Barney game is actually a fantastic game for first getting to grips with the concept of pressing buttons or moving a joystick to control an onscreen character (since you can't really lose), but it seems the controller we were using (a truly excellent bluetooth one by Moga) was a bit overwhelming, and the game itself requires no real skill or engagement (drop the controller and it will complete itself on autoplay - once you realise that, what's the point in playing anymore?).

I got to thinking about what would make a good game for three year old, one who so far has only been exposed to touchscreen "jigsaw puzzles" and "smash bugs at a picnic" type games.

Here's what I came up with:
  • The control scheme should be simple and intuitive
  • Rules governing gameplay should be fairly straightforward and logical
  • Threat should be absent, or extremely mild
  • It should look and sound reasonably appealing
  • You shouldn't be able to lose too quickly i.e. before you get a handle on what you're actually meant to do
I realised that we already owned the perfect game controller for a small child. It's not really a game controller at all. It's an Amazon Fire TV Remote. I mean, just look at this thing:


It's a wonderfully simple controller, and that circle up top covers all the basic actions that should be required in a simple child friendly game: up, down, left, right, and a single fire/action/select button.

I started out with an Atari 2600 myself, nearly 30 years ago. All the games I had were controlled by one of these bad boys:
Let's all take a moment to bask in the glory of its simplicity... Up, down, left, right, and a fire/action/select button. Yes, using the Fire TV Remote looked like a winner. If it was good enough for Atari in the 80's, it's good enough for me today.

Ok, control scheme and physical controller sorted, on to the next item, a relatively simple game idea. A lot of the best simple game ideas have already been done, but I'm cool with rehashing a tried and tested mechanic, not everything has to be innovative or ground breaking ☺ Thinking about simple games, I realised very few are actually forgiving enough to meet my requirements. Pong and breakout are actually quite tough games, especially if you've never played them or handled a game controller before. Miss the ball a few times and it's game over. A game of breakout could easily be over within seconds, and before any blocks were broken. No good, frustration is not fun. What about Pac Man? Space Invaders? Centipede? Same deal. Those old simple games were actually quite challenging, I guess that's what made them so addictive, and why world records exist for acing them! Then it struck me: Snake!
  • Simple control scheme: up/down/left/right, press the relevant button to move in that direction
  • Simple rules: eat as many apples as possible and don't bite yourself - seems like reasonable advice for anyone to lead their life by
  • Minimal threat: bite yourself and you have to start again (no big deal, right?)
  • Aesthetically appealing: Ok, nokia snake wasn't the nicest looking or sounding game, back in those days we didn't have much to work with, the 3310 had a 84x48 monochrome 1.5 inch screen, midi sounds, and a processor and memory to match. Luckily we have HDTVs and even HD mobile devices these days, so we can do something about that... And thanks to awesome people like Kenney and Kevin MacLeod you don't have to be an accomplished artist or composer to pull it off!
  • Impossible to lose too quickly: This is where snake comes into it's own - all the other simple old games I considered were challenging, and you could lose them all immediately. The snake game is challenging, but with certain rules in place (no static obstacles, wrap around scenes, starting length of 4 segments or less) it is actually impossible to lose until you have at least managed a score of 1, and in most cases you're unlikely to lose before the "snake" reaches a length greater than the world height.
I put together a small prototype, and soon had a very simple snake game up and running on our living room TV via the Fire TV Stick. A "snake" comprised of green squares on a black background, a single red square representing the "mouse" or "apple", no score, no sound, nothing other than a very rudimentary snake that could be controlled via the Fire TV Remote that grew each time it "ate" a red square. My daughter loved it. I think she was excited to see that what I had been working on on my laptop had somehow appeared on the TV, and that she could press buttons to make it do stuff ☺

She referred to the snake as a caterpillar, probably due to us having played Atari's centipede on the RPi earlier in the day, and she called that a caterpillar too (I guess she has never actually seen a centipede, but has seen plenty of caterpillars). Maybe the fact we had recently borrowed The Very Hungry Caterpillar from the library had something to do with it too. Anyway, the Hungry Caterpillar name stuck, and that in turn helped me come up with a nice, bold, simple, child friendly, cartoonish skin:
Hungry Caterpillar
I could have stopped right there, as at that point I had achieved what I set out to do - I had made a little game for my three year old to play on the TV using a simple controller. However, I found the whole process of developing for a TV and remote controller quite interesting. If the game had more than a single screen, maybe a game over screen announcing when a high score had been achieved, a menu screen, a help screen, an options screen, how would all that work using the remote as a controller? More interestingly, could I get the app to work well not only on TV's using a remote/game controller, but also on the more traditional touchscreen phones and tablets? If yes, why not release it on Amazon for both Fire TV and Fire Tablet devices? Could I go one step further and release it on Google Play too? I found the answer to all that stuff and managed to build a single apk that works equally well on TV and touchscreen, and that can be uploaded to both the Amazon and Google marketplaces.

I learned a few nifty tricks that I plan to write about in future (this post is already way too long...):
  • How to suppress ads when running on an unsuitable platform (it infuriates me when ads appear in a Fire TV app with no way to avoid them or click through)
  • How to link to the appropriate app store depending on what platform you are running on without resorting to separate builds for each marketplace
  • How to handle a simple menu in LibGdx using either touchscreen or remote/game controllers
  • How to make a game/app that works well and looks good in terms of the 10-foot user interface, and that works equally well and looks equally nice on hand held devices

I also ended up with a game to play with my daughter, something to publish on the Amazon and Google marketplaces (yeah, I've been slacking again), and a reason to post on my blog again :)

Oh, and the game is totally helping TheInvaderOne get to grips with controlling an onscreen character by pressing buttons on a remote controller. She is already hitting double digit scores, which is a huge improvement over what she could manage when she first tried a couple of weeks ago. I expect she will be destroying my own high scores very soon! And if her interest in the Sensory app is anything to go by, TheInvaderOneX will be bringing more competition to the table in two or three years time! ☺

Anyway, the game is free, as always. There are some ads when you play on a mobile device (a small unobtrusive banner, and a single short interstitial plays on game over). There are no ads on Fire TV. No in app purchases or subscriptions or any kind of hidden nasties on any platforms. Just a simple fun game for you to play for free ☺
Hungry Caterpillar
Hungry Caterpillar
Hungry Caterpillar
Don't be afraid to be overly generous with your ratings and reviews, I'm cool with praise, don't worry, you won't make me blush 😙

Until next time, I hope you have fun 😀

No comments:

Post a Comment