Elementari

Name Your Hero and Choose Your Path

Designed by:

Introduction

In this Hour of Code lesson, students will create an interactive fantasy story that stars the player as the hero. They’ll code a text box to ask the player for their name, choose a magical item, and set a character role based on that choice. Using text variables, click events, and template-based storytelling, students will design a short adventure that changes based on player input—building both creativity and coding skills.

Subjects:
Grades: 3-8
Estimated Time For Completion: 2 classes (each 45 minutes)

Objectives

Students will:

  • Understand how to create and use text variables to store player input.
  • Use template variables (e.g., {{name}} and {{role}}) to personalize story content.
  • Apply event-driven coding using blocks like <code class="events">On Click</code> and <code class="events">On Page Start</code> to change story outcomes.
  • Design an interactive experience that combines creative storytelling with basic coding logic.

Coding Concepts Covered

Function in Parallel User Input Field Text Variable

Student Instructions

1. What Is Your Hero Name? 📝 (15 mins)

Use the Create Text Variable block to make a new variable called name for the player’s name.

Ask the player to type their name in the text box, then save it in the name variable.

2. Set the Default Role 🧳 (10 mins)

Give the player a starting role before they choose anything. Use the Create Text Variables block to create and name a variable called role.

✏️ You’ll use this later in a sentence like:

"This is the beginning of {{name}}’s adventure as {{role}}."

3. Add the Magical Item 🌟 (10 mins)

Let the player choose a magical item to change their role.

4. Start the Adventure 🏰 (5 mins)

Curly brackets like {{name}} or {{role}} are special placeholders. They tell the computer:

👉 Put the value of this variable here.

Try it out: This is the beginning of {{name}}’s adventure as {{role}}.

5. Add More To Your Game 🎨 (10 mins)

💡 Ideas to try:

✍️ Continue the story: What happens next in your hero’s adventure?

🧭 Add buttons to let the player explore different paths using the Go To Page block.

🎵 Add background music with the Play Music block to match the mood.

🖼️ Include more images or backgrounds to bring your fantasy world to life.

Interactive Project Example for Students

Play through this lesson's example project created on Elementari. Use this example to guide and motivate your students.

Select Lessons or Create Your Own Lesson!