RPG Basics - The Show Must Go On!

computer programming maze role-playing game rpg scratch Dec 26, 2022

Role-playing games (RPGs) are a popular genre of computer games.  In many of these games, the player navigates through a maze attempting to complete a task.  The goal might be to defeat a powerful monster, to recover a lost and valuable treasure, or to uncover some mysterious secret.  Along the way, the player might encounter challenges and obstacles that hinder progress.

In The Show Must Go On, a programming project in Scratch, students create their own RPG where a rock band has left its instruments scattered around backstage.  The player must roam the halls to locate the lost instruments and get them to the stage before the concert starts.  This is harder than it may seem, though, because all the rooms look the same!

Students start by designing their maze.  Using graph paper, they draw a grid, indicating where there are walls and where there are doors.  They then encode the maze in Scratch using a list.  Each entry in the list represents a room and the value tells which of the walls have doors.  For example, if the entry at the second position in the list is "NSE", then room number 2 has doors in the north, south, and east walls.  The student also indicates which wall of which room holds the stage door.

The remainder of the program randomly "hides" the instruments in rooms in the maze.  The player, too, is randomly placed, facing a random direction.  The player has a compass to indicate in which direction it is facing.

As the player moves through the maze, the program must decide what the player can see based on the contents of and the exits in the room.  For example, if the player is in a room facing east, and the room has a door in the east wall, then the player should see a door.  If there is no room in the east wall, then the player should see a blank wall.  If the room has any of the instruments, they should be shown, too.

One of the key concepts in this project is how to create and use a data structure to represent something tangible.  Here, the backstage area with its rooms and doors is implemented as a list of values, while the player's location and facing direction are simple variables.  The items that need to be collected (i.e., the instruments) are represented as two lists, one which contains the names of the items and other containing their locations.  Collectively, all these bits of data may be thought of as a single entity.  In the C programming language, this could be a struct.  In Pascal, it would be a record.  In most object-oriented programming languages, the backstage area would be represented with a class.

With just a few relatively simple changes, students can take the foundation for this project and turn it into virtually any kind of hide-and-seek style adventure.  The setting, the backstory, and the hidden items can all be easily change so that the quest takes place underground, on another planet, or in some kind of fantasy world.  It could further be enhanced to include encounters with other characters, side tasks, and multiple locales.  The core data structure and overall logic, though, would stay largely the same.

This project challenges the student not only as a developer, but also as a player.  Even on a small 3x3 grid consisting of only 9 rooms, it is difficult to recognize the player's location despite having been the one to create the maze!  Students may find it helpful to draw a map as they wander through the maze, keeping track of where they have been and areas that remain to be explored.

Want to check out this project for yourself?  Click here.

Stay connected with news and updates!

Join our mailing list to receive the latest news and updates from our team.
Don't worry, your information will not be shared.

We hate SPAM. We will never sell your information, for any reason.

To learn more about how we can help you integrate STEM education at your campus or homeschool, contact us for a consultation. 

Schedule a Consultation