KIRA LABS · FREE BEGINNER PROGRAMMING LESSON
Make a whole game.
From first file to final scene.
This is not a video about merely walking a character back and forth. You'll make The Firefly Trail: a complete story adventure with a beginning, two story routes, inventory, a river crossing, several endings, and a replay button, moving scenery, animated characters, and optional narration using the same preferred browser voice as Iris. Then you can write your own version.
1 See what you're going to build
Meet Wisp the fox. The fireflies have lost their way, and the mountain beacon has gone dark. Click glowing fireflies, watch Wisp move through different scenes, and choose how the story ends. Press Start adventure with Iris voice to hear the narration. Try playing it here:
This is the finished, working example—not a mockup. It uses only HTML, CSS and JavaScript, so it runs without installing a game engine.
2 Create your very first game file
- Make a new folder on your computer named
my-adventure-game. - Open Notepad on Windows, or a free code editor like Visual Studio Code.
- Create a new file called
index.html. In Windows Notepad, choose Save as type: All files so it does not becomeindex.html.txt. - Press Copy complete game code below, paste into the new file, and save it as UTF-8.
- Double-click
index.html. Your browser should open a complete, playable game. Try every ending, then use the replay button.
Loading the original source from this game…
3 Understand what each language does
HTML builds the page
HTML gives the game its title, story area, choice buttons and replay control. These are the pieces you see on screen.
<h2 id="title">Your story</h2>
<p id="story"></p>
<div id="choices"></div>CSS brings the world to life
CSS animates the fox, moving clouds, river, floating fireflies, different landscapes, buttons and responsive layout on phones.
.scene {
background: #132743;
border-radius: 24px;
padding: 20px;
}JavaScript remembers the adventure
Variables hold the current scene, your backpack and the ending you unlock.
let currentScene = "start";
let backpack = [];
let endingText = "";Functions make it interactive
Clicking a choice calls a function, updates your backpack and displays the next scene. The replay button resets those variables.
function choose(choice) {
if (choice.gift) {
backpack.push(choice.gift);
}
// Continue to the next scene...
}4 See the complete adventure structure
Every choice has a destination. The finished game contains a branching route, then a shared river crossing and summit, followed by alternate endings. That's a complete, repeatable game loop:
BEGINNING: The fireflies disappear
|
+-- Visit the lantern-maker --+
| |
+-- Search the forest -------+
|
Glasswater River crossing
|
Reach the mountain beacon
|
Choose how to restore light
|
DIFFERENT STORY ENDINGS
|
PLAY AGAIN
The scene start contains buttons that move you to village or forest. Both routes eventually lead to river, then hill. When the player makes the last choice, an if statement picks the right ending.
.world[data-scene="forest"], .world[data-scene="river"] and @keyframes control the animated backgrounds and movement. The showScene() function changes locations when you choose a path. narrateScene() reads the story using the same fixed English voice preference as Iris; the browser may choose a fallback if that voice isn't installed. Audio begins only after the player taps Start or makes a choice.
5 Write a new chapter yourself
Now change the game. Open your index.html and look for const scenes = {. A scene is an object with a title, narrative and choices. You can start by modifying the village story or add a new cave scene.
cave: {
chapter: 3,
speaker: "THE OLD OWL",
place: "A hidden crystal cave",
title: "The Owl's Secret",
story: "A wise owl offers you a moonstone.",
choices: [
{ text: "Accept the moonstone",
gift: "moonstone", next: "river" },
{ text: "Thank the owl and continue",
next: "river" }
]
},
Put that object inside scenes between other scene objects, separated by commas. Then update a forest choice so its next property is "cave". Save and refresh. You have created a new playable chapter!
You can also replace Wisp with a robot, move the story to another planet, add more scenes, add scores, change the CSS colors, or write your own endings. Try one change at a time and play the story again to test it.
6 Test, finish and share the game
- Play from the first scene to a final ending on both story routes.
- Check that every choice points to a real scene name, and each item can be collected.
- Try every final choice. Make sure replay returns to the beginning with an empty backpack.
- Check buttons and story text on both a desktop and a phone-sized window.
- Keep the original code file somewhere safe. When your game is ready, put its
index.htmlin a new folder under a website'sarcadedirectory and link to it from the arcade homepage.
Made by Kira Labs for curious beginners. You may copy and customize The Firefly Trail example code for your own projects; please keep third-party material you add properly licensed.