9

(Elliott) #1

Arduino programming: Build a games console (part 1/2)


SCHOOL OF MAKING


Arduino programming:


Build a games console (part 1/2)


Put some of that hard-learnt theory into action. And we really mean action,


with spaceships, analogue joysticks, and bitmap graphics


I


n the
previous
tutorial,
we dived
into the
theory behind
pointers and linked
lists. We’re going to do
away with theory this time
and put some of what we’ve
previously covered into action.
And one of the best ways of
doing this, and one of the most
entertaining, is to code a video game. The limited
performance of the Arduino means writing any
kind of modern game is impossible – we can’t use
anything like the libraries used by game developers
to skip over the programming fundamentals,
implement AI, and virtual reality reprojection. But
we can write a game just as they did in golden era
of 8-bit home computing. The limited hardware of
those old machines forced the games designer’s
creativity, and that meant injecting games with as
much simple, imaginative, and addictive gameplay
as possible. Limited hardware also meant that
every variable, function, sprite, and sound could be

hand-tuned to perfection, with playability
iterated over until it was considered perfect.
There was no other option because you couldn’t
push out a 1024 byte day-one patch, let alone
a 50GB one, and it was these limitations that
made so many of those old games playable today,
decades later.
We’re going to use the same setup we’ve
been playing with in previous tutorials – mainly
the same 128×64 I^2 C OLED display, but you can
easily replace this with something larger than the
0.96” model we’re using. For input, we’re going to
use an analogue dual-axis joystick that includes a
single momentary switch. These are cheaply and
commonly available as a single module with the
‘KY-023’ label – and you may even have one left
over from the joystick MIDI controller we featured
previously. See the ‘Get connected’ box overleaf

Above
With a bit of
ingenuity, simple
graphics can still
look great

Graham Morrison
@degville

Graham is a veteran
Linux journalist who is
on a life-long quest to
find music in the perfect
arrangement of silicon

You could replace
the analogue
joystick with five
simple momentary
buttons, but you’ll
lose the finer degree
of control.

QUICK TIP

Free download pdf