Linux Format

Code your own Python text adventure

CORDING ACADEMY

MU

Credit: https://codewith.mu

Inthe first part of this series, we explored how to create and move between rooms, which is the basis for any solid text adventure. Hopefully by now you’ll have mapped out your own adventure, either using good old-fashioned grid paper or specialist software such as IFMapper.

Moving between areas is all well and fine but the essence of any text adventure centres around the items you find. Sometimes these are things you can pick up to use later. In other cases, examining items might give you clues on how to progress to other areas.

Setting up an inventory for your player is simply a matter of adding the attribute to the Player class:

The previous move function we used is going to get unwieldy if we keep adding the full code for player actions. It’s better to spin off commands like listing the player inventory into

You’re reading a preview, subscribe to read more.

More from Linux Format

Linux Format2 min read
Back Issues Missed One?
ISSUE 313 April 2024 Product code: LXFDB0313 In the magazine Discover how to use the ultimate hacker’s toolkit, staying out of trouble while doing so. And join us as we take the Puppy Linux developer’s new distro for a run and explore its container
Linux Format2 min read
Distro Watch
Ubuntu 24.04 LTS Noble Numbat is currently scheduled for release on 25th April. At the time of writing, we’re working with a daily build and expect a full review next issue. Nevertheless, we discovered that Canonical has announced this LTS release wi
Linux Format5 min read
Tips For Managing Docker Containers
Everyone knows how containers revolutionised application building and deployment. Using a E disposable stack of containers that make up an app that aren’t using the docker-compose command to manage the stack are missing a trick. It allows the shippin

Related