How to make a PICO-8 game: Part 2

I like to move it.

In the last chapter, I showed you the very basic task of putting a sprite on the screen. That’s all very well, but a bit less interactive than most games are. In this chapter, let’s make it move.

Part 2: Move the player

The first task here is to make PICO-8 check to see if the player is pressing any of the direction keys. You can do this by making use of the btn() function.

The arrow keys (or joypad d-pad, depending how you’re playing the game) are referred to by the numbers 0 to 3. The left key is 0, right is 1, up is 2 and down is 3. If you check to see, for example, if btn(0) is true, then you’re checking to see if the player is pressing left.

You’ll recall that the coordinates of the player sprite on the screen are stored in the variables x and y. To physically make the sprite move left, you need to make the value of x smaller, and to move it right you have to make it larger – remember that the left of the screen is 0, the right is 127. Let’s make it move by one pixel at a time for simplicity’s sake. Ignoring up and down for the moment, this code in the _update() function will do that:

In plain English, this reads as:

“If the left key is being pressed, then decrease the value of x by 1”

“If the right key is being pressed, then increase the value of x by 1”

You could be a little more verbose and use the longer forms if you wish:

When you do a check on a function, looking for a “true” is implied, and I prefer the shorter form of the increment and decrement command, but both work. Just note that when you assign a value to a variable you use one equals sign (=), but when you do an “if” check, you use two (==).

Run your code now, and see how the sprite moves left and right as you press left and right. Magic!

Of course, this only deals with left and right. Let’s add the code for up and down, using btn(2) and (3) and changing y as appropriate:

Now, you’d think that was the end of it, but there’s a flaw here. You may have noticed that the sprite can move off the screen where you can’t see it. That in itself isn’t necessarily a bad thing, but for the purposes of this game we don’t want that to happen.

To fix it, we need an additional check for “screen edge detection”. When moving left, we need to make sure that x is only decremented when x is already greater than 0. Similarly, we can only move up if y is greater than 0.

For the right and bottom edges, it’s slightly more complicated. Although the edges are at 127 pixels, our sprite’s x and y values refer to the top left corner of the sprite, which is 7 pixels before the right and bottom edges of the sprite – the sprite is 8×8 pixels, remember. Instead of then checking to see if the sprite is at 127 pixels, we need to check for 120.

We can add this check at the same point we check for a button press by modifying the “if” statements. For example:

If we finish this off to include up and down, we can complete our code (for now!):

Next time, we’ll add an enemy to chase the player!

How to make a PICO-8 game: Part 1

Let’s Make A Game.

Since I’m now teaching people how to make programs in PICO-8, I thought I might as well put my teaching notes here for others who may find them useful.

A few caveats:

I am not an expert. Yes, there are better ways of doing some of what I’m explaining (and some of the improvements will come in later parts of the “course”), but my “class” consists of children, some of whom will have no coding experience past Scratch so bear that in mind. In particular, I will be using longhand for variables, and objects/classes will be used later on, to keep things readable, simple, and followable. Followable is definitely a word. Also, this won’t teach you how to use PICO-8 itself, just how to program with it. There’s a manual for that.

The game we’re going to create is very simple. There are two sprites, and one sprite is player controlled and chased by the other sprite. That’s it. Told you it was very simple.

Parts of a PICO-8 Game

There are three main functions to deal with in a basic PICO-8 program: _init(), _update() and _draw(). Note the underscores – without them your program won’t work.


This is called at the start of your program when you run it. Unless called again, it runs only once. It’s here where you put all your setup stuff, variable initialisation, and so on.


This is called over and over again, 30 times a second. In here you put your “game logic”, updating variables such as object locations, checking for collisions, increment the score, and so on.


This function is where all the drawing on the screen takes place. So you’d print the score, draw the sprites, and so on in the _draw() function. It is also called 30 times a second if it is possible to do so – if the code is taking to long to run it may drop  _draw() calls so that _update() has time to run properly.

Just a few things to mention before I show you any code:

Firstly, comments in the code (that is, notes to you rather than actual code) are either lines starting

which comments out that line, or

which comments out everything until

Secondly, it’s good practice to give all your functions and variables useful names. PICO-8 does have a character limit so you may need to make them shorter and therefore less useful in the future, but not yet!

Finally, indent your code. When you open a function, a loop, an if/then or anything like that, indent everything in it. It makes it a lot easier to read.

If you follow these three rules, your code will be nice and readable – important if you come back to it weeks or months later, or give it to someone else, but also it helps a lot when things aren’t working as you’d expect.

Part 1: Put some stuff on the screen

First off, we’ll need a sprite to act as the player. We’ll just draw a blank square for now in the sprite editor, and use the sprite slot 1 to store it. We won’t need it yet but lets also create an enemy sprite the same only a different colour in slot 2.

Two basic sprites

Now, in the code editor, lets put the three basic functions I mentioned above:

We’ll choose now what the start coordinates of the player sprite are. The PICO-8 screen is 128×128 pixels, with the top left of the screen at 0,0, and the bottom right at 127,127. The middle will be roughly 64,64 then. We’ll call the x and y coordinates of the player, well, x and y. Why not?

Since they’re being initialised, we put these in _init():

At this point, we’re not going to move it about, but we do need to draw it. Usually in a PICO-8 game, you’ll want to clear the screen at the start of each draw frame, so we’ll make use of the cls() command to do that. We can choose what colour to clear the screen to by putting the colour number in cls(). You can use this palette to chose one:

cls(2) will clear the screen to a sort of purpley mauve, for example.

Then we’re going to draw the player sprite on the screen at 64, 64 – now known as x and y. This is done with the spr() command, and the coordinates refer to the top left corner of the sprite. We also need to tell spr which sprite to use, in this case the player sprite, which is sprite number 1.

And there we go:

Best. Game. Ever.

Next time, I’ll show you how to make the thing move around the screen, but for now, here’s all the code so far:

Making audio work on a Steam Link and a Mac

I could just turn the volume up really high and listen through the ceiling.

Yes, it’s another Steam Link post. You see, having had some success with streaming Windows to the Steam Link, I thought I’d have a proper go and making Mac streaming work. And I’ve managed it! Eventually. Apple: “It just works!”. Pff.

Firstly, and not related to the audio issue mentioned in title of this post, I found a small utility to stop my iMac from deciding to go to sleep while playing. As it did. And that was annoying. It’s called Owly, and is free. It sits in the menu bar, and you can click it to disable all sleeping, and click again to enable sleeping. There’s options to prevent sleeping for a certain number of hours or minutes too, in case you’re likely to forget to turn it back on.

Anyway, that was an aside. To the matter at hand!

After setting the Steam Link up to talk to my Mac, and configured for my controller, TV, and so on, I discovered that sound wasn’t being streamed. It’d play in the Steam Link menus and startup screen, but not in Steam itself. Only it was – on the Mac.

I trawled the Steam forums, where the issue comes up a lot, but the solution is always the same: use the Steam Beta and it’ll force some drivers to install on the Mac. Thing is, that was the issue back in 2015 and I’ve done that already.

Turns out, after much fiddling, very easy to fix. If the Steam Link itself is set to use 5.1 audio, or “auto detect”, then sound plays through the Mac. Set it to stereo, and it works. OK, in stereo, but at least that’s something. Mini Metro doesn’t need surround sound anyway.

Still, it means I don’t need to boot into Windows quite so much to play Steam games now.

Configuring Spotify to use less disk space

Download ALL the things. But nobody knows why.

When my PC hard drive reached critical capacity last week, and I was figuring out where all the space had gone, I found one of the major bit-thieves was Spotify. This folder (in Windows 7 at least):

had grown to be over 12GB. 12GB! For a streaming service where everything is online? That can’t be right. Even more odd is how this folder isn’t even the Spotify cache folder, which by default is here:

and for me was only a gig in size. The user interface for Spotify does let you reconfigure the location of this Storage folder, so you can move it to another drive to make a bit of space, but this doesn’t help with the larger issue of the Data folder – which can’t be configured like this.

Luckily, there is still a solution. Firstly, close Spotify completely (making sure it’s not still running in the system tray), then go to this folder:

Note that’s the Roaming folder, not the Local folder where the Data and Storage folders are. In here, there’s a file called “prefs”. Open this in a text editor – Wordpad is better than Notepad because the file contains UNIX style carriage returns and Notepad doesn’t cope well with them.

At the end of the file (although it doesn’t seem to matter where, so long as it’s on a line by itself, add this:

1024 is the maximum size, in megabytes, you want to give over to this cache. So for 1GB, use 1024. For half a gig, 512, and so on. I’m sure you can figure that bit out for yourself!

Save the file, making sure your text editor doesn’t add a rogue file extension when you do so, and then go back to the Data folder mentioned earlier and delete the contents. No, really. It’s fine. Or move them somewhere if you’re scared.

Open up Spotify again, and if it’s all working, you’re set! It isn’t clear why this folder fills up when there’s a perfectly good folder already there for caching purposes, but at least there’s a way of stopping it growing out of control.

Fitting a backlit screen to an original Game Boy

Blue is the warmest colour.

I bought a somewhat yellowed old Game Boy, along with a kit containing a new shell, buttons and some bits to make a backlight for the screen, from someone who I suspect intended to combine them all himself but perhaps didn’t feel up to the task.

He should have tried a little harder, as it wasn’t nearly as difficult as it seemed at first, and the finished product is pretty awesome. So awesome, in fact, that my daughter wanted to play a pile of old Game Boy games on it.

I won’t go into how I assembled it all here, as the guy who sells the kits has an excellent video guide to doing it:

Anyway, that’s how to do it, and this is how things went for me:

I didn’t choose the blue version of the light (there are a variety of different options), but I think it looks pretty good. One of the first titles I tried was Pokémon Blue, so it was appropriate!

Now I’ve done it once, I really want to do another. The previous owner of this one’s shell overtightened the screws causing those white pimples on the front, and although they gave me a bivert kit (to improve the contrast on the screen) it’s the bare chip version which is somewhat tricky to fit. I have another Game Boy I can use, which is missing the screen bezel and is also yellowed, and you can now get a simpler bivert kit which is much easier to install.

I just need to choose the colour scheme I want for the new one!

Cheese in Video Games

Everyone’s favourite mouldy milk product

(This suggestion, obviously, from @JayTay)

Cheese in video games

The main problem with cheese in video games is that it makes them stop working. Especially if it either blocks the cartridge slot, or it melts all over the circuit board. It doesn’t especially matter which cheese you have, either, as one way or the other it’ll clog up your console and then you won’t be able to play video games on it.

How sad you will be, just because you put cheese in your Mega Drive.

If, somehow, you have managed to get cheese in your Mega Drive, or any other console, then follow these simple steps to rectify the problem:

  1. Wash your hands: Your console doesn’t want your germs.
  2. Unplug the console from the power: A happy repair person is an unelectrocuted repair person.
  3. Wait for the cheese to set, if it has not already.
  4. Wear sunscreen. This is standard advice for most tasks.
  5. Unscrew all the screws in the console. It is important you keep the loose screws completely separate to each other, as screws are known to reproduce when in close proximity. 1
  6. Disassemble the console. Some have ribbon cables or other connectors that need disconnecting, so pay attention.
  7. Using a Brillo pad (other brands are available) scrape away as much cheese as you can. Carefully use a small screwdriver or pointy knife to dig out any cheese that may have found its way into small crevices or gaps.
  8. If you still have some cheese residue on the console innards, simply spray WD40 all over the greasy areas, leave for 20 minutes, then rinse under a cold tap.
  9. If your console is still wet, you can bake it dry in an oven. 100C for half an hour should do it. If you only have a microwave, then wrap it in a tea towel first, before “cooking” it on low power for 5 minutes.
  10. Reassemble the console.

And that’s it! Your console should be Cheese Free (you could say it’s now a vegan console) and you can get back to shooting aliens!

If for some reason your console will no longer operate, simply buy a new one.


  1. This is why whenever you reassemble something, there are screws left over.

How to capture Mac desktop audio with OBS

Because by default it’s so dumb. Literally.

OBS (Open Broadcaster Software) is a great program for streaming and recording gameplay on a PC. I’ve used it quite a lot, but it has frustrated me for a while that the Mac version has – through no fault of OBS – no ability to capture game audio. On the PC, you can capture “desktop audio” or “what U hear”, but that’s not an option on OS X. On older Macs, you could run a 3.5mm to 3.5mm cable from the headphone socket to the line in socket, but on newer Macs there’s one socket that does both directions, so that’s out.

A year or so ago I tried to get either of two solutions working: Soundflower, which sort of did but was really fiddly, and WavTap which never seemed to work at all. Recent versions of OS X have actually prevented Soundflower from working as intended at all, so there was no (free) solution and I stopped using OBS on a Mac. Until last week.

Soundflower was still in my system settings, albeit unused, and I’d never got round to uninstalling it. It irritated me every time I saw it there but was always busy doing something else and kept forgetting to remove it. This time, however, I finally looked up how to and in the process came across a new utility which effectively replaces it, and works: IShowU Audio Capture. There’s a full (paid for) software package called IShowU, but all you need for this purpose is the audio capture part, which is free.

How to make IShowU work with OBS

Firstly, download IShowU Audio Capture from this link, and install it as shown. You don’t need Step 6 yet, so do 1-5 and come back.

(time passes)

Done? Hello again!

So, step 6 is going into System Preferences > Sound and choosing IShowU Audio Capture as your sound input device, which will work, but keep reading for an additional tweak.

obs mac audio

All you need to do now is open up OBS and choose a new Audio Input Capture source (click the + under the Sources box), then choose IShowU Audio Capture as the device. That’s it!

obs mac audio

obs audio mac

Only… there’s a snag. This will indeed capture all “desktop audio” (so you’ll probably want to close or mute email notifications and so on when streaming or recording), but crucially it won’t actually output any sound to your speakers or headphones so you’ll be playing mute. This might not be a problem, but if it is, read on.

Open up the Audio MIDI Setup app from Applications > Utilities. In here we’re going to create a multi-output device, so you can output your desktop audio to both IShowU and headphones/speakers/whatever at the same time.

Click the + in the bottom left, and choose “Create Multi-Output Device”. Then, in the right-hand pane for this new device, make sure you tick “Built-in Output” and “iShow Audio Capture”. Leave drift correction set to Built-in Output.

obs audio mac

Close that, and head back over to System Preferences > Sound. You’ll now have an output option for your new Multi-Output Device. Before you choose it, make sure you set your volume level how you want it: you can’t adjust the volume of a multi-output device!

obs mac sound


With the volume set, choose Multi-Output Device as your, er, output device, and you’ll notice the volume slider grey-out. It’s time to go back to OBS and configure the Audio Input Capture there – same as before, choosing IShowU Audio Capture.

You’re done, although you might want to remember to choose your usual output settings in System Preferences when you’re finished recording!

File Server Resource Manager can’t send emails

0x8004531c, is the magic number

Upon replacing two aging fileservers with two shiny new ones, this time running Windows Server 2012 R2 rather than Server 2008, I came across a strange issue regarding File Server Resource Manager notification emails (you know, like “your quota is full” warnings and so on). As in, it can’t send them, instead giving this message when you attempt to generate a test email:

Failed to send the test e-mail due to the following error: Cannot send the email due to an error. Check the application event log for more information.

Sure enough, when I checked the application event log on the server running FSRM, I found this entry for SRMSVC with event ID 12306:

A File Server Resource Manager Service email action could not be run.

Error-specific details:
Error: IFsrmEmailExternal::SendMail, 0x8004531c, Mailbox unavailable. The server response was: 5.7.1
Client does not have permissions to send as this sender

What’s odd about this, is that it suggests that the email address I’d given FSRM as a “send-as” email address, can’t send emails via our Exchange 2010 server. On our old file servers, it worked just fine with exactly the same settings. It seems Server 2012 R2 has a new requirement!

To fix it, I created a new “Equipment Mailbox” on the Exchange Server (using the Exchange Management Console) called “FSRM-ServerName”, and gave it the email address “FSRM-ServerName@domain.tld”. Then, using the Exchange Management Shell, I gave the server the rights to use that mailbox:

It now all works as expected (and of course I repeated the task for the other server too), but it’s still a mystery to me as to why it’s unnecessary for File Server Resource Manager on Server 2008 but it is on 2012 R2, when surely the issue lies at the Exchange Server end of things?