ast month, we had a look at how
to create an ultrasonic controller
for a version of Pong called Boing!
This month, we’re going to take a
step further forward through video
game history and look at the game
Frogger. In this classic game, you control a frog as it
makes its way across logs, roads, and train tracks,
avoiding falling in the water or getting hit.
The tribute to this game in the new Code
the Classics Volume 1 book (available from
hsmag.cc/VTTzPH) is called Infinite Bunner, and
works in much the same way, except you control a
bunny. All this hopping got us thinking about a
controller. Our initial idea was that since the animals
jump, so should the controller. The accelerometer
can detect freefall, so it shouldn’t be too hard to
convert those into button presses. However, it turns
out that computer-controlled frogs and rabbits can
jump much, much faster than humans can, and we
really struggled to get a working game mechanic, so
we compromised a little and worked with ‘flicks’.
The basic idea is that you tilt the controller left or
right to move left or right, but you have to flick it up to
register a jump (simply holding it upright won’t work).
We’ve used a Circuit Playground Bluefruit for this,
but it will work equally well with a Circuit Playground
Express. There are two key parts to the software.
The first is that you can read in accelerometer values
and use these to know what orientation the board is
in, and the second is that the board can mimic a USB
keyboard and send keystrokes to any software
running on it.
The first step is to get Infinite Bunner working
on your machine. You can download the code for
all the Code the Classics Volume 1 games from
hsmag.cc/w2LiEg. Press Clone or Download >
Download ZIP. Unzip this somewhere. You’ll need
Python 3 with Pygame Zero installed. The process for
this differs a little between different computers, but
there’s a good overview of all the different options on
page 186 of Code the Classics.
Once everything’s set up, open a terminal and
navigate to the directory you unzipped the code in.
Then, inside that, you should find bunner-master
and enter that. You can then run:
python3 bunner.py
Have a few goes playing the game, and you’ll find
that you need the left, right, and up arrow keys to
play (there is also the down arrow, but we’ve ignored
this since we’ve never actually used it in gameplay
FEATURE
In the workshop: Infinite Bunner game controller
Infinite Bunner
game controller
Control your character by tilting a Circuit Playground device
L
Right
Jump along the
logs, dodge the
traffic, avoid the
trains, and keep
your bunny alive for
as long as possible