Make a Frogger-style arcade game

Straight from Code the Classics, here’s how to make your own road-crossing action game akin to Konami’s Frogger

AUTHORS EBEN UPTON, DAVID CROOKES, AND ANDREW GILLET

Released in 1981, *Frogger* was one of the most popular and enduring games from the golden age of arcades – a top-down platformer with rules that could be understood at a glance. Players guided five frogs from the bottom of the screen to the safety of their home at the top, with such obstacles as a busy road and a treacherous river full of predators complicating their journey. To keep players coming back for more, the developers made it difficult enough to ensure that failure would, at some point, be inevitable. The frustration resulting from not being able to get all five frogs to their various homes on the riverbank was all that was needed to ensure the flow of cash into the arcade cabinet. *Frogger* was a big hit for Japanese studio Konami, but what really helped spread its popularity was its array of ports to home computers and consoles. Programmer John D. Harris was responsible for two of those ports – the Atari 400 and 800 computer versions, which were among the games used at the first video game world championships, held in January 1983.

Harris used the 48kB Atari 800 as his development platform, albeit with some extra hardware to help out: he had an Axlon RAMDisk that lent an extra 128kB of memory, a highspeed floppy disk interface made by LE Systems, and an Austin-Franklin 80-Column Board which presented an 80-column by 25-character screen display on a monitor. With those in hand, he began to deconstruct the original game and make notes about the various aspects of its gameplay. “In the years to come, the Atari would forever establish itself in my mind as one of the greatest computers ever made,” Harris says. “People were still discovering new graphic tricks and techniques ten years after the machine was introduced. If you compare the latest programs written for the Atari with the earliest programs, the huge difference between them is a testament to the magic they accomplished with its design.” You’ll find the full story of *Frogger*’s Atari 400/800 development in *Code the Classics*, Raspberry Pi’s book about classic games, how they were made, and how you can recreate them in Python. The *Frogger* chapter goes into far more detail about Harris’ experiences – including the heart-stopping moment where the original source code was stolen, and work had to start over almost from the beginning. In the meantime, though, here’s how to make your own modern take on *Frogger* – with code by Raspberry Pi’s Eben Upton and graphics designed by the legendary Dan Malone, may we present Infinite Bunner…

*Infinite Bunner*… is our take on the classic *Frogger* gameplay. The original game takes place on a single screen, with a busy road at the bottom and a river at the top. In our game, the level is procedurally generated and scrolls continuously. The player must progress fast enough to avoid falling off the bottom of the screen – if this happens, an **Eagle** flies down the screen and catches the player, resulting in Game Over. The level is divided into a series of sections, each of a particular type – **Grass**, **Dirt**, **Road**, **Pavement**, **Rail**, or **Water**. Each section is made up of a series of rows, where each row corresponds to one sprite from the images folder. Rows are 40 pixels high, although you may notice that some of the sprites are 60 pixels high; this is just a visual effect – the sprite overhangs the row

“What helped Frogger spread its popularity was its array of ports to home computers”

above, but the row is still considered 40 pixels high for gameplay purposes. **Road**, **Water**, and **Rail** sections all feature moving objects: **Cars**, **Logs**, and trains (the latter has no class of its own). **Grass** sections may contain **Hedges**, which the player must walk around. Because these objects always stay within their rows, we classify them as child objects of the rows. Child objects are drawn relative to their parent rows – e.g. if a road row has a Y coordinate of 200, and a car on the road has a Y coordinate of 10, the car would be drawn at Y coordinate 210. To provide this functionality, all objects in the game inherit from a class called **MyActor**, which in turn inherits from Pygame Zero’s built-in **Actor** class. **MyActor** works just like **Actor** except that it overrides the **update** and **draw** methods in order to update and draw the list of child objects. It also ensures objects are drawn at the correct position on screen, taking the scrolling of the level into account.

“All rows inherit from the Row class. This performs several important tasks, such as collision detection”