🎮ArcadeLab

Dragon Quest - Vocabulary & Reading

by LaserPilot97
953 lines23.2 KB
▶ Play
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dragon Quest - Vocabulary & Reading</title>

<style>
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 20px;
    font-family: Arial, sans-serif;
    background: linear-gradient(135deg, #101827, #263d61);
    color: white;
    text-align: center;
}

.container {
    max-width: 900px;
    margin: auto;
    background: #19263b;
    border: 2px solid #71b7ff;
    border-radius: 20px;
    padding: 25px;
}

h1 {
    color: #ffd166;
    font-size: clamp(28px, 5vw, 42px);
}

h2 {
    color: #71b7ff;
}

button {
    padding: 15px;
    margin: 8px 0;
    width: 100%;
    border: none;
    border-radius: 12px;
    background: #344967;
    color: white;
    font-size: 17px;
    font-weight: bold;
    cursor: pointer;
}

button:hover:not(:disabled) {
    filter: brightness(1.2);
}

button:focus-visible {
    outline: 3px solid white;
}

button:disabled {
    cursor: default;
    opacity: 0.9;
}

.menu-button {
    background: #ffd166;
    color: #101827;
    padding: 20px;
    font-size: 19px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 20px 0;
}

.stat {
    background: #344967;
    border-radius: 12px;
    padding: 12px 5px;
}

.stat strong {
    display: block;
    font-size: 22px;
    margin-top: 8px;
}

.panel {
    background: #22334d;
    padding: 20px;
    border-radius: 14px;
    margin: 15px 0;
}

.paragraph {
    text-align: left;
    line-height: 1.8;
    white-space: pre-line;
}

#word {
    color: #ffd166;
    font-size: clamp(27px, 5vw, 38px);
    overflow-wrap: anywhere;
}

.answers {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.correct {
    background: #16875c !important;
}

.wrong {
    background: #b52d49 !important;
}

#feedback {
    min-height: 45px;
    font-weight: bold;
    line-height: 1.5;
}

.primary {
    background: #ffd166;
    color: #101827;
}

.hidden {
    display: none !important;
}

input {
    padding: 12px;
    border-radius: 8px;
    border: none;
    width: 90%;
    max-width: 350px;
    font-size: 16px;
}

#leaderboard {
    margin-top: 25px;
    text-align: left;
}

#leaderboard h2 {
    text-align: center;
}

li {
    padding: 5px;
}

.small {
    color: #b9c5d9;
    font-size: 14px;
}

@media(max-width: 550px) {
    body {
        padding: 8px;
    }

    .container {
        padding: 14px;
    }

    .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .answers {
        grid-template-columns: 1fr;
    }
}
</style>
</head>

<body>

<div class="container">

<header>
    <h1>🐉 DRAGON QUEST 🐉</h1>
    <p>Choose your battle. Learn. Fight. Win!</p>
</header>

<!-- MAIN MENU -->

<section id="menu">

    <h2>⚔️ CHOOSE YOUR BATTLE</h2>

    <button class="menu-button" onclick="startParagraphs()">
        📖 FIGHT PARAGRAPHS
    </button>

    <button class="menu-button" onclick="startVocabulary(1)">
        📚 FIGHT VOCABULARY — LESSON 1
    </button>

    <button class="menu-button" onclick="startVocabulary(2)">
        📚 FIGHT VOCABULARY — LESSON 2
    </button>

    <button class="menu-button" onclick="startVocabulary(3)">
        📚 FIGHT VOCABULARY — LESSON 3
    </button>

    <div class="panel">
        <h2>🎮 BATTLE RULES</h2>
        <p>✅ Correct answer: +100 points</p>
        <p>🐉 Correct answer: Dragon loses 10 HP</p>
        <p>❌ Wrong answer: -50 points</p>
        <p>❤️ Wrong answer: Player loses 10 HP</p>
        <p>🏆 Defeat the dragon to win!</p>
    </div>

</section>

<!-- GAME SCREEN -->

<section id="game" class="hidden">

    <button onclick="showMenu()">⬅ MAIN MENU</button>

    <h2 id="modeTitle">BATTLE</h2>

    <div class="stats">
        <div class="stat">
            ⭐ SCORE
            <strong id="score">0</strong>
        </div>

        <div class="stat">
            ❤️ PLAYER HP
            <strong id="playerHP">100</strong>
        </div>

        <div class="stat">
            🐉 DRAGON HP
            <strong id="dragonHP">100</strong>
        </div>

        <div class="stat">
            🎯 QUESTION
            <strong id="questionNumber">1</strong>
        </div>
    </div>

    <div id="readingPanel" class="panel hidden">
        <h2 id="passageTitle"></h2>
        <div id="passageText" class="paragraph"></div>
    </div>

    <div class="panel">
        <h2 id="word">Ready?</h2>
        <p id="question"></p>
        <div id="answers" class="answers"></div>
        <p id="feedback" aria-live="polite"></p>
        <button id="nextButton" class="primary hidden">
            NEXT QUESTION ➜
        </button>
    </div>

</section>

<!-- RESULTS SCREEN -->

<section id="results" class="hidden">

    <h2 id="resultTitle">🏆 BATTLE RESULTS</h2>
    <div class="panel">
        <h1 id="finalScore">0 POINTS</h1>
        <p id="resultText"></p>
    </div>

    <button class="menu-button" onclick="replayBattle()">
        🔄 PLAY THIS BATTLE AGAIN
    </button>

    <button class="menu-button" onclick="showMenu()">
        🏠 MAIN MENU
    </button>

    <div id="leaderboard" class="panel">
        <h2>🏆 LEADERBOARD</h2>
        <input id="playerName" maxlength="20"
               placeholder="Enter your player name">

        <button class="primary" onclick="saveScore()">
            SAVE SCORE
        </button>

        <ol id="scores"></ol>
    </div>

</section>

</div>

<script>

// ====================================
// VOCABULARY FROM LESSONS 1, 2 AND 3
// ====================================

const vocabulary = {

1: [
    ["alarm", "a warning signal or sudden feeling of fear"],
    ["anticipation", "a feeling of looking forward to something"],
    ["bewilderment", "a feeling of confusion"],
    ["cope", "to deal successfully with a difficult situation"],
    ["defiance", "open refusal to obey"],
    ["hostile", "unfriendly or threatening"],
    ["mortified", "extremely embarrassed"],
    ["pang", "a sudden sharp feeling of pain or sadness"],
    ["resent", "to feel angry about something unfair"],
    ["unique", "unlike anything or anyone else"]
],

2: [
    ["embroider", "to decorate cloth with patterns sewn with thread"],
    ["emphasize", "to give special importance to something"],
    ["emphatic", "strong and clear in expression"],
    ["employ", "to hire someone to work"],
    ["enable", "to make something possible"],
    ["encounter", "to meet or experience something"],
    ["endeavor", "to try hard to do something"],
    ["endorse", "to express support or approval"],
    ["engaging", "interesting and enjoyable"],
    ["envelop", "to cover or surround completely"]
],

3: [
    ["abide", "to tolerate or put up with something"],
    ["communal", "shared by a group of people"],
    ["dwell", "to live in a place"],
    ["edifice", "a large, impressive building"],
    ["kindred", "members of your family; relatives"],
    ["nurture", "to care for and help something develop"],
    ["reliance", "dependence on someone or something"],
    ["resident", "a person who lives in a particular place"],
    ["sentiment", "a feeling or opinion about something"],
    ["vicinity", "the area near a place"]
]

};

// ====================================
// READING PASSAGES
// ====================================

const passages = [
{
    title: "📖 PARAGRAPH 1: FINDING MY VOICE",

    text: `On Thursday morning, our class gathered to share stories we had written. I waited with anticipation because I had spent all week preparing mine.

When my teacher called my name, I opened my folder and froze in alarm. My story was missing. I searched through my papers in bewilderment. Someone laughed, and I gave him a hostile look. I felt mortified standing silently in front of everyone.

I began to resent the assignment. In defiance, I shut my folder and said, "I am not doing this." Immediately, I felt a pang of regret. I wanted to share my story, but I did not know how to cope with my embarrassment.

My teacher's reply was gentle but emphatic: "Your ideas matter. Tell us what you remember." I took a breath and began describing my main character. Soon, the familiar events came back to me, and my classmates leaned forward to listen.

That morning, I learned that I could encounter a problem without giving up. I had lost my pages, but I had found my voice.`,

    questions: [
        {
            q: "Why was the narrator excited?",
            a: [
                "The class was sharing stories",
                "School was canceled",
                "A dragon arrived",
                "The narrator was going home"
            ],
            correct: 0
        },
        {
            q: "What happened to the narrator's story?",
            a: [
                "It was too long",
                "It was missing",
                "The teacher took it home",
                "It was published"
            ],
            correct: 1
        },
        {
            q: "What does 'mortified' mean?",
            a: [
                "Very happy",
                "Very hungry",
                "Extremely embarrassed",
                "Very sleepy"
            ],
            correct: 2
        },
        {
            q: "How did the teacher help?",
            a: [
                "The teacher canceled school",
                "The teacher told the narrator to leave",
                "The teacher found a dragon",
                "The teacher encouraged the narrator to remember the story"
            ],
            correct: 3
        },
        {
            q: "What lesson did the narrator learn?",
            a: [
                "Never write stories",
                "Keep trying when problems happen",
                "Never speak to classmates",
                "Always skip class"
            ],
            correct: 1
        }
    ]
},

{
    title: "📖 PARAGRAPH 2: MY READING JOURNEY",

    text: `My name is Alex, and I have been a resident of Maple Town since I was born. My love of stories began long before I could read the words on a page.

When I was little, Grandma told me stories about our kindred, including cousins and great-grandparents I had never met. In our apartment building's communal garden, other families shared their stories too. Those evenings helped nurture my curiosity about people whose lives were different from mine.

At seven, I joined a children's reading group at a library in our vicinity. At first, I relied on others to read every page. Gradually, my reliance on adults decreased as I learned to use pictures and nearby words to understand the stories.

Today, I enjoy reading books from different cultures. Each writer offers a unique way of seeing the world. I have even started recording Grandma's memories in a notebook.

Grandma often says, "Stories bring people together." That is a sentiment I now share, because reading has helped me understand both my family and the wider world.`,

    questions: [
        {
            q: "Where has Alex lived since birth?",
            a: [
                "Maple Town",
                "Dragon Castle",
                "London",
                "The library"
            ],
            correct: 0
        },
        {
            q: "What does 'kindred' mean?",
            a: [
                "Teachers",
                "Relatives or family members",
                "Strangers",
                "Buildings"
            ],
            correct: 1
        },
        {
            q: "Where did Alex join a reading group?",
            a: [
                "At a stadium",
                "At a restaurant",
                "At a library",
                "At a hospital"
            ],
            correct: 2
        },
        {
            q: "How did Alex improve reading?",
            a: [
                "By avoiding books",
                "By memorizing every page",
                "By never reading alone",
                "By using pictures and nearby words"
            ],
            correct: 3
        },
        {
            q: "What is a main idea of the passage?",
            a: [
                "Reading helps people understand different lives and cultures",
                "Libraries are always closed",
                "Stories are not useful",
                "Families should stop telling stories"
            ],
            correct: 0
        }
    ]
},

{
    title: "📖 PARAGRAPH 3: KEEPING STORIES ALIVE",

    text: `Traditional stories pass from one generation to the next. They enable communities to share memories, values, and ideas about the world.

A tale may describe a cottage where ordinary families dwell or a magnificent edifice where a ruler lives. Its hero might be someone who cannot abide cruelty and decides to defend a neighbor. These characters and settings help listeners imagine another time and place.

Storytellers emphasize important lessons through repeated phrases and dramatic events. An engaging performance encourages listeners to remember the story and tell it again.

Some cultural festivals employ artists to bring traditional tales to life. Artists may embroider scenes on cloth or use lighting to envelop a stage in darkness during a mysterious scene. These details help audiences picture the action.

Communities endeavor to keep these traditions alive by recording and performing their tales. Many families endorse such efforts because folktales connect young people with the voices and experiences of earlier generations.`,

    questions: [
        {
            q: "What do traditional stories help communities share?",
            a: [
                "Only sports results",
                "Memories, values, and ideas",
                "Shopping lists",
                "Only recipes"
            ],
            correct: 1
        },
        {
            q: "What is an edifice?",
            a: [
                "A small animal",
                "A musical instrument",
                "A large, impressive building",
                "A type of food"
            ],
            correct: 2
        },
        {
            q: "Why do storytellers emphasize important lessons?",
            a: [
                "To help listeners remember them",
                "To make the story disappear",
                "To stop people listening",
                "To remove the characters"
            ],
            correct: 0
        },
        {
            q: "How can artists help bring stories to life?",
            a: [
                "By hiding every picture",
                "By refusing to perform",
                "By removing all characters",
                "By using cloth, art, and lighting"
            ],
            correct: 3
        },
        {
            q: "Why preserve traditional stories?",
            a: [
                "To forget the past",
                "To connect young people with earlier generations",
                "To stop festivals",
                "To prevent people from sharing"
            ],
            correct: 1
        }
    ]
}
];

// ====================================
// GAME STATE
// ====================================

let mode = "";
let lesson = 1;
let questions = [];
let index = 0;
let score = 0;
let playerHP = 100;
let dragonHP = 100;
let locked = false;
let lastMode = "";
let lastLesson = 1;

let leaderboard = [];

const $ = id => document.getElementById(id);

// ====================================
// HELPER FUNCTIONS
// ====================================

function shuffle(array) {
    const result = [...array];

    for (let i = result.length - 1; i > 0; i--) {
        const j = Math.floor(Math.random() * (i + 1));

        [result[i], result[j]] =
        [result[j], result[i]];
    }

    return result;
}

function showMenu() {
    $("menu").classList.remove("hidden");
    $("game").classList.add("hidden");
    $("results").classList.add("hidden");
}

function startBattle() {
    index = 0;
    score = 0;
    playerHP = 100;
    dragonHP = 100;
    locked = false;

    $("menu").classList.add("hidden");
    $("game").classList.remove("hidden");
    $("results").classList.add("hidden");
    $("readingPanel").classList.add("hidden");

    $("nextButton").classList.add("hidden");

    renderQuestion();
}

// ====================================
// START PARAGRAPH MODE
// ====================================

function startParagraphs() {
    mode = "paragraph";
    lastMode = mode;

    questions = [];

    shuffle(passages).forEach(passage => {
        passage.questions.forEach(question => {
            questions.push({
                type: "paragraph",
                passage: passage,
                question: question
            });
        });
    });

    $("modeTitle").textContent =
        "📖 PARAGRAPH DRAGON BATTLE";

    startBattle();
}

// ====================================
// START VOCABULARY MODE
// ====================================

function startVocabulary(selectedLesson) {
    mode = "vocabulary";
    lesson = selectedLesson;

    lastMode = mode;
    lastLesson = lesson;

    questions = shuffle(
        vocabulary[lesson].map(item => ({
            type: "vocabulary",
            word: item[0],
            meaning: item[1]
        }))
    );

    $("modeTitle").textContent =
        "📚 VOCABULARY LESSON " + lesson;

    startBattle();
}

// ====================================
// RENDER QUESTION
// ====================================

function renderQuestion() {
    locked = false;

    if (index >= questions.length ||
        playerHP <= 0 ||
        dragonHP <= 0) {
        endBattle();
        return;
    }

    const item = questions[index];

    $("score").textContent = score;
    $("playerHP").textContent = playerHP;
    $("dragonHP").textContent = dragonHP;

    $("questionNumber").textContent =
        `${index + 1}/${questions.length}`;

    $("feedback").textContent = "";
    $("nextButton").classList.add("hidden");

    const answers = $("answers");
    answers.innerHTML = "";

    if (item.type === "vocabulary") {

        $("readingPanel").classList.add("hidden");

        $("word").textContent = item.word;

        $("question").textContent =
            "Choose the correct meaning of this word.";

        const wrongMeanings = shuffle(
            vocabulary[lesson]
                .filter(v => v[0] !== item.word)
                .map(v => v[1])
        ).slice(0, 3);

        const options = shuffle([
            item.meaning,
            ...wrongMeanings
        ]);

        options.forEach(option => {
            const button = document.createElement("button");

            button.textContent = option;

            button.addEventListener("click", () => {
                checkAnswer(
                    button,
                    option === item.meaning
                );
            });

            answers.appendChild(button);
        });

    } else {

        $("readingPanel").classList.remove("hidden");

        const passage = item.passage;
        const q = item.question;

        $("passageTitle").textContent =
            passage.title;

        $("passageText").textContent =
            passage.text;

        $("word").textContent =
            "📖 READING QUESTION";

        $("question").textContent = q.q;

        q.a.forEach((option, i) => {
            const button = document.createElement("button");

            button.textContent = option;

            button.addEventListener("click", () => {
                checkAnswer(
                    button,
                    i === q.correct
                );
            });

            answers.appendChild(button);
        });
    }
}

// ====================================
// CHECK ANSWER AND FIGHT
// ====================================

function checkAnswer(button, correct) {
    if (locked) return;

    locked = true;

    const buttons = [...$("answers").children];

    if (correct) {

        score += 100;
        dragonHP = Math.max(0, dragonHP - 10);

        button.classList.add("correct");

        $("feedback").textContent =
            "⚔️ CORRECT! +100 POINTS! 🐉 DRAGON -10 HP!";

        $("feedback").style.color = "#42d392";

    } else {

        score -= 50;
        playerHP = Math.max(0, playerHP - 10);

        button.classList.add("wrong");

        $("feedback").textContent =
            "❌ WRONG! -50 POINTS! ❤️ PLAYER -10 HP!";

        $("feedback").style.color = "#ff647c";
    }

    buttons.forEach(b => b.disabled = true);

    if (mode === "vocabulary") {
        const item = questions[index];

        buttons.forEach(b => {
            if (b.textContent === item.meaning) {
                b.classList.add("correct");
            }
        });
    } else {
        const item = questions[index];
        const correctAnswer =
            item.question.a[item.question.correct];

        buttons.forEach(b => {
            if (b.textContent === correctAnswer) {
                b.classList.add("correct");
            }
        });
    }

    $("score").textContent = score;
    $("playerHP").textContent = playerHP;
    $("dragonHP").textContent = dragonHP;

    $("nextButton").classList.remove("hidden");

    $("nextButton").textContent =
        (playerHP <= 0 ||
         dragonHP <= 0 ||
         index === questions.length - 1)
        ? "🏁 FINISH BATTLE"
        : "NEXT QUESTION ➜";
}

// ====================================
// NEXT QUESTION
// ====================================

$("nextButton").addEventListener("click", () => {
    if (!locked) return;

    index++;

    if (index >= questions.length ||
        playerHP <= 0 ||
        dragonHP <= 0) {
        endBattle();
    } else {
        renderQuestion();
    }
});

// ====================================
// END BATTLE
// ====================================

function endBattle() {
    $("game").classList.add("hidden");
    $("results").classList.remove("hidden");

    $("finalScore").textContent =
        score + " POINTS";

    if (dragonHP <= 0) {

        $("resultTitle").textContent =
            "🏆 YOU DEFEATED THE DRAGON!";

        $("resultText").textContent =
            "Amazing! You won the battle!";

    } else if (playerHP <= 0) {

        $("resultTitle").textContent =
            "🐉 THE DRAGON WON!";

        $("resultText").textContent =
            "Train again and come back stronger!";

    } else {

        $("resultTitle").textContent =
            "🎉 BATTLE COMPLETE!";

        $("resultText").textContent =
            "You finished all the questions!";
    }
}

// ====================================
// REPLAY
// ====================================

function replayBattle() {
    if (lastMode === "paragraph") {
        startParagraphs();
    } else {
        startVocabulary(lastLesson);
    }
}

// ====================================
// LEADERBOARD
// ====================================

function saveScore() {
    const name = $("playerName").value.trim();

    if (!name) {
        alert("Please enter your name!");
        return;
    }

    leaderboard.push({
        name: name,
        score: score
    });

    leaderboard.sort((a, b) => b.score - a.score);

    leaderboard = leaderboard.slice(0, 10);

    const list = $("scores");
    list.innerHTML = "";

    leaderboard.forEach((entry, i) => {
        const li = document.createElement("li");

        li.textContent =
            `${entry.name} — ${entry.score} points`;

        list.appendChild(li);
    });
}

showMenu();

</script>

</body>
</html>

Game Source: Dragon Quest - Vocabulary & Reading

Creator: LaserPilot97

Libraries: none

Complexity: complex (953 lines, 23.2 KB)

The full source code is displayed above on this page.

Remix Instructions

To remix this game, copy the source code above and modify it. Add a ARCADELAB header at the top with "remix_of: dragon-slayer-laserpilot97" to link back to the original. Then publish at arcadelab.ai/publish.