Computer Science Grade 8 20 min

Sharing and Playing: Presenting Interactive Stories

Students will share their interactive stories with classmates and provide feedback.

Tutorial Preview

1

Introduction & Learning Objectives

Learning Objectives Design a branching narrative with at least three distinct endings using a flowchart or diagram. Implement a main game loop in Python to repeatedly present story text and accept user input. Use a dictionary to manage the player's state, such as their inventory and location. Refactor a linear story into a function-based structure, where each function represents a different scene. Create simple 'win' and 'lose' conditions based on player choices and state. Package a Python script with clear instructions so another person can run and play the story. Ever wanted to build your own adventure game where your friends make the choices? 🎮 Let's turn your stories into real, playable games! In this lesson, you'll learn how to trans...
2

Key Concepts & Vocabulary

TermDefinitionExample Game LoopA central control structure in a game that continuously runs, handling user input, updating game elements, and displaying the results.A `while` loop that keeps running as long as the `game_is_over` variable is `False`. Inside the loop, it prints the story, asks for input, and updates variables. Game StateA collection of all the important variables and data that represent the current situation in the game, such as player health, inventory, or location.A dictionary like `player_state = {'health': 100, 'inventory': ['key', 'map'], 'location': 'dungeon'}`. Branching NarrativeA story that splits into different paths based on the player's decisions, leading to multiple possible storylines and endings...
3

Core Syntax & Patterns

The Main Game Loop Pattern while game_running: display_scene() get_user_input() update_game_state(user_input) Use a `while` loop as the engine of your game. Inside the loop, you show the current situation, ask the player for their choice, and then update the game's variables based on that choice. The loop continues until a condition (like `game_running = False`) stops it. State Management with Dictionaries game_state = { 'location': 'start', 'has_key': False } Use a Python dictionary to hold all the important information about the game's current state. This makes it easy to pass the state between functions and to check or change values like `game_state['location']` or `game_state['has_key']`. Conditi...

4 more steps in this tutorial

Sign up free to access the complete tutorial with worked examples and practice.

Sign Up Free to Continue

Sample Practice Questions

Easy
What is the main purpose of a game loop in an interactive story?
A.To continuously run the game, processing input and updating the state.
B.To define the story's ending.
C.To store the player's inventory.
D.To draw the initial graphics on the screen one time.
Easy
Which data structure is recommended in the tutorial for managing the player's state, like their location and inventory?
A.list
B.dictionary
C.string
D.An integer
Easy
What is a "branching narrative"?
A.story that splits into different paths based on the player's choices.
B.story that is always the same every time you play it.
C.story that is written using only `if` statements.
D.story that is organized into functions.

Want to practice and check your answers?

Sign up to access all questions with instant feedback, explanations, and progress tracking.

Start Practicing Free

More from Interactive Storytelling with Python: Introducing Game Development

Ready to find your learning gaps?

Take a free diagnostic test and get a personalized learning plan in minutes.