Tag Archives: Programming

Teaching myself programming under lockdown

As with many of us, COVID-19 has given me an abundance of free time, and I’ve been using it to do something I’ve tried and failed to do numerous times over the years: to teach myself to code.

I can remember going straight from devouring HTML For Dummies and using it to build the Shenmue Fan Site, circa 1998, to C For Dummies – how different could they be? The realisation of those surefire smash hit game ideas I’d sent to my favourite developers as a kid was imminent.

That plan lasted all of an evening. HTML and C are quite different, as it turns out.

Since then JavaScript, PHP, more attempts at C, Python and Swift have fallen by the wayside. Books, PDFs, online tutorials, and even children’s learning resources clutter my hard drive. I’d done enough to understand the fundamentals but have always failed to find the time or impetus to make it stick.

So, in the early days of lockdown, when I was climbing the walls with boredom, I had a go with Swift Playgrounds, which has recently made its way to macOS from the iPad. It’s designed for kids, but I found myself sitting up late, replaying levels and trying to craft more efficient solutions or get my head around the logic.

At a certain point, though, it seemed like a waste to be putting so much effort into a kids’ game, when I could be learning the real thing. I had time with a three-week furlough coming up, so I set a lockdown resolution: I will learn to code.

Python Crash Course cover
Python Crash Course by Eric Matthes

The book that finally cracked it for me was Python Crash Course by Eric Matthes, which I got in a Humble Bundle and, at the time of writing, is once again available there. Python is a popular choice as a first programming language and it gets a thumbs-up from me – it’s quite straightforward, and an interpreted language is more friendly when you’re making those beginner’s mistakes.

What’s more, Python is the de facto programming language of the Raspberry Pi if you want to get into hardware projects and is a big player in proper fields like machine learning too.

Anyway, like most coding books, it takes you through the principles of programming chapter-by-chapter, then into several larger projects that apply your new knowledge into crafting actual useful software. Get that far and the sense of achievement when hours of work takes you from a blank text file to an actual playable game – the first I’ve written in 30-odd years of merely playing them – is something else.

I wrote that! So will anyone else who works through that book, admittedly, but I’ve carried on working on it until my version has music and sound effects, and I replaced the single, ephemeral high score with a persistent top 10 leaderboard. Even writing the lion’s share of the game’s functionality parrot-fashion has taught me so much about the inner workings of how a game is structured.

A project like this, which will give you a useful skill and a sense of achievement, is what everyone needs in these strange times. I’m now confident enough to try putting together a few software ideas that have been rattling around in my head for a while, I’m dabbling in more applied Python books, and I’ve got my eye on finally cracking C this time.

Stay safe, and take advantage of lockdown while you’ve got it.

Makin’ Games

Although I know a lot about games and I’ve certainly played a significant number, making my own has never really crossed my mind. I came in when consoles were in full swing and so missed the days of easily programmable home micros, and a couple of attempts to learn anything more complicated than HTML have come to nothing.

It’s been at the back of my mind, though. Working on Retro Gamer, I frequently read interviews with people who made masterpieces in their bedrooms before they’d even finished school, which I suppose has made an impact, and then I’ve run into something of a perfect storm: Code Year, talk of the recent overhaul of school computing – which, as someone with an A-level in the useless old-style ICT, makes me insanely jealous – and the push behind the homebrew-friendly Raspberry Pi, all mixed in with a bit of a self-improvement bent on which I’ve found myself.

So Code Year’s been teaching me the fundamentals through building basic applications and games in JavaScript, and on the recommendation of some forum buddies I’ve started learning Python as well. I can’t do much beyond play with variables, but within a couple of weeks I know enough to make my computer draw a grid, simulate a dice roll, or move a sprite wherever I tell it. Baby steps, but I can see how these fundamentals build up into something that could legitimately be called a game.

I’m not going to go so far as to drop everything and embark on a career in development – not the most stable area right now – or get ahead of myself by announcing that I’m creating the next Minecraft, but man, it’s a good feeling when you can feel it clicking. It’s a string to my bow and something I want as a hobby so that I’m not strictly a consumer when it comes to computing.

I will make Shenmue III once I’ve worked out how to get lookingForSailors() running on a Dreamcast, though.