Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Wortjäger: Journey through the pages of the past</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <div class="container">
        <h1>Wortjäger: Journey through the pages of the past</h1>
        <div id="game-container">
            <div id="quiz-container">
                <!-- Контент мини-игр будет вставлен сюда -->
            </div>
            <div id="timer-container">
                Время: <span id="timer">100</span> секунд
            </div>
            <button id="next-button">Следующий вопрос</button>
        </div>
        <div id="result-container" style="display: none;">
            <h2>Игра окончена!</h2>
            <p id="result-text">Ваши очки: <span id="score">0</span></p>
            <button id="restart-button">Перезапустить игру</button>
        </div>
    </div>
    <script src="script.js"></script>
</body>
</html>
              
            
!

CSS

              
                body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.container {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    padding: 20px;
    text-align: center;
    width: 300px;
}

button {
    background-color: #007BFF;
    border: none;
    border-radius: 5px;
    color: #fff;
    cursor: pointer;
    margin: 5px;
    padding: 10px;
    width: 100%;
    font-size: 16px;
}

button:hover {
    background-color: #0056b3;
}

#timer-container {
    margin: 20px 0;
    font-size: 18px;
}

#quiz-container {
    margin-bottom: 20px;
}

#result-container {
    text-align: center;
}

              
            
!

JS

              
                let score = 0;
let timeLeft = 100; // Время в секундах
let timerInterval;
let gameStarted = false;
let currentQuestionIndex = 0;

const questions = [
    { word: 'Haus', translation: 'дом' },
    { word: 'Baum', translation: 'дерево' },
    { word: 'Auto', translation: 'машина' },
    { word: 'eins', translation: 'один' },
    { word: 'zwei', translation: 'два' },
    { word: 'vier', translation: 'четыре' },
    { word: 'sieben', translation: 'семь' },
    { word: 'fünf', translation: 'пять' },
    { word: 'drei', translation: 'три' },
    { word: 'sechs', translation: 'шесть' },
    { word: 'acht', translation: 'восемь' },
    { word: 'zehn', translation: 'десять' },
    { word: 'er, sie, es', translation: 'он, она, оно' },
    { word: 'ich', translation: 'я' },
    { word: 'wir', translation: 'мы' },
    { word: 'Sie', translation: 'Вы' },
    { word: 'du', translation: 'ты' },
    { word: 'ihr', translation: 'вы' },
    { word: 'Wann die Berliner Mauer gebaut wurde?', translation: 'Когда была построена Великая Берлинская стена?' },
    { word: 'Wann wurde Deutschland gegründet?', translation: 'Когда появилась Германия?' },
    { word: 'Wer war der erste Herrscher von Deutschland?', translation: 'Кто был первым правителем Германии?' },
    // Добавьте сюда больше вопросов
];

const timerElement = document.getElementById('timer');
const scoreElement = document.getElementById('score');
const nextButton = document.getElementById('next-button');
const resultContainer = document.getElementById('result-container');
const restartButton = document.getElementById('restart-button');
const gameContainer = document.getElementById('game-container');
const quizContainer = document.getElementById('quiz-container');

// Начать игру
function startGame() {
    score = 0;
    timeLeft = 100; // Начальное время
    currentQuestionIndex = 0; // Начать с первого вопроса
    updateScore();
    updateTimer();
    resultContainer.style.display = 'none';
    gameContainer.style.display = 'block';
    nextButton.style.display = 'inline-block';
    gameStarted = true;

    // Запуск таймера
    if (timerInterval) {
        clearInterval(timerInterval);
    }
    timerInterval = setInterval(updateTimer, 1000);

    // Загрузить первый вопрос
    loadNextQuestion();
}

// Обновить счет
function updateScore() {
    scoreElement.textContent = score;
}

// Обновить таймер
function updateTimer() {
    if (timeLeft <= 0) {
        clearInterval(timerInterval);
        endGame();
    } else {
        timerElement.textContent = timeLeft;
        timeLeft--;
    }
}

// Загрузить следующий вопрос
function loadNextQuestion() {
    if (currentQuestionIndex < questions.length) {
        const question = questions[currentQuestionIndex];
        quizContainer.innerHTML = `
            <p>Переведите слово: ${question.word}</p>
            <input type="text" id="answer" placeholder="Ваш ответ">
            <button id="submit-answer">Проверить</button>
        `;

        document.getElementById('submit-answer').addEventListener('click', checkAnswer);
    } else {
        endGame();
    }
}

// Проверить ответ
function checkAnswer() {
    const userAnswer = document.getElementById('answer').value.trim();
    const correctAnswer = questions[currentQuestionIndex].translation;

    if (userAnswer.toLowerCase() === correctAnswer.toLowerCase()) {
        score++;
        updateScore();
        currentQuestionIndex++;
        loadNextQuestion();
    } else {
        alert('Неверный ответ! Игра будет перезапущена.');
        restartGame();
    }
}

// Закончить игру
function endGame() {
    gameContainer.style.display = 'none';
    resultContainer.style.display = 'block';
    gameStarted = false;
}

// Перезапустить игру
function restartGame() {
    startGame();
}

// Обработчик кнопки "Следующий вопрос"
nextButton.addEventListener('click', function() {
    if (gameStarted) {
        loadNextQuestion();
    }
});

// Обработчик кнопки "Перезапустить игру"
restartButton.addEventListener('click', function() {
    restartGame();
});

// Инициализация игры при загрузке страницы
startGame();
              
            
!
999px

Console