Spaces:
Running
Running
Add 3 files
Browse filesFiles changed (3)
- README.md+7-5
- index.html+877-19
- prompts.txtAdded
123452345678910111012---title: Pythonemoji: 💻colorFrom: graycolorTo: indigotitle: pythonemoji: 🐳colorFrom: bluecolorTo: yellowsdk: staticpinned: falsetags: - deepsite---
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-referenceCheck out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference12345678910111213141516171819123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877<!doctype html><html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width" /> <title>My static Space</title> <link rel="stylesheet" href="style.css" /> </head> <body> <div class="card"> <h1>Welcome to your static Space!</h1> <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p> <p> Also don't forget to check the <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>. </p> </div> </body></html><!DOCTYPE html><html lang="pt-br"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Python Adventure - Aprenda Python Jogando</title> <script src="https://cdn.tailwindcss.com"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <style> .code-editor { font-family: 'Courier New', monospace; background-color: #1e1e1e; color: #d4d4d4; } .typewriter { overflow: hidden; border-right: .15em solid #4ade80; white-space: nowrap; letter-spacing: .15em; animation: typing 3.5s steps(40, end), blink-caret .75s step-end infinite; } @keyframes typing { from { width: 0 } to { width: 100% } } @keyframes blink-caret { from, to { border-color: transparent } 50% { border-color: #4ade80 } } .progress-bar { transition: width 0.5s ease-in-out; } .shake { animation: shake 0.5s; } @keyframes shake { 0% { transform: translateX(0) } 25% { transform: translateX(-5px) } 50% { transform: translateX(5px) } 75% { transform: translateX(-5px) } 100% { transform: translateX(0) } } </style></head><body class="bg-gray-100 min-h-screen"> <div class="container mx-auto px-4 py-8"> <!-- Header --> <header class="flex justify-between items-center mb-8"> <div class="flex items-center"> <i class="fab fa-python text-4xl text-blue-600 mr-3"></i> <h1 class="text-3xl font-bold text-gray-800">Python Adventure</h1> </div> <div class="flex items-center space-x-4"> <div class="flex items-center"> <span class="mr-2 text-gray-700"><i class="fas fa-coins text-yellow-500"></i> <span id="points">0</span> XP</span> <div class="w-24 bg-gray-200 rounded-full h-2.5"> <div id="progress-bar" class="progress-bar bg-green-500 h-2.5 rounded-full" style="width: 0%"></div> </div> </div> <button id="sound-btn" class="p-2 rounded-full bg-gray-200 hover:bg-gray-300"> <i class="fas fa-volume-up text-gray-700"></i> </button> </div> </header>
<!-- Main Game Area --> <div class="grid grid-cols-1 lg:grid-cols-3 gap-8"> <!-- Left Panel - Lessons --> <div class="lg:col-span-2 bg-white rounded-xl shadow-lg overflow-hidden"> <div class="p-6"> <div id="lesson-container"> <!-- Initial Welcome Screen --> <div id="welcome-screen" class="text-center py-12"> <i class="fab fa-python text-8xl text-blue-600 mb-6"></i> <h2 class="text-4xl font-bold text-gray-800 mb-4">Bem-vindo ao Python Adventure!</h2> <p class="text-xl text-gray-600 mb-8">Aprenda Python de forma divertida e interativa. Complete lições, resolva desafios e ganhe XP!</p> <button id="start-btn" class="px-8 py-3 bg-blue-600 hover:bg-blue-700 text-white font-bold rounded-lg text-lg transition duration-300 transform hover:scale-105"> Começar a Aventura! </button> </div>
<!-- Lesson Content (dynamically loaded) --> <div id="lesson-content" class="hidden"> <h2 id="lesson-title" class="text-2xl font-bold text-gray-800 mb-4"></h2> <div id="lesson-text" class="text-gray-700 mb-6"></div> <!-- Code Example --> <div id="code-example" class="mb-6 hidden"> <div class="flex justify-between items-center bg-gray-800 text-white px-4 py-2 rounded-t-lg"> <span>Exemplo de Código</span> <button id="copy-code-btn" class="text-xs bg-gray-700 hover:bg-gray-600 px-2 py-1 rounded"> <i class="far fa-copy mr-1"></i> Copiar </button> </div> <pre id="code-block" class="code-editor p-4 rounded-b-lg overflow-x-auto"></pre> </div> <!-- Quiz Section --> <div id="quiz-section" class="hidden"> <div class="bg-blue-50 border-l-4 border-blue-500 p-4 mb-6"> <h3 class="font-bold text-blue-800 mb-2">Teste seu conhecimento</h3> <p id="quiz-question" class="text-blue-700"></p> </div> <div id="quiz-options" class="grid grid-cols-1 md:grid-cols-2 gap-3 mb-6"></div> <div id="quiz-feedback" class="hidden p-4 rounded-lg mb-6"></div> </div> <!-- Coding Challenge --> <div id="coding-challenge" class="hidden"> <div class="bg-purple-50 border-l-4 border-purple-500 p-4 mb-4"> <h3 class="font-bold text-purple-800 mb-2">Desafio de Programação</h3> <p id="challenge-text" class="text-purple-700"></p> </div> <div class="flex justify-between items-center bg-gray-800 text-white px-4 py-2 rounded-t-lg"> <span>Editor de Código</span> <div> <button id="run-code-btn" class="text-xs bg-green-600 hover:bg-green-700 px-2 py-1 rounded mr-2"> <i class="fas fa-play mr-1"></i> Executar </button> <button id="reset-code-btn" class="text-xs bg-gray-700 hover:bg-gray-600 px-2 py-1 rounded"> <i class="fas fa-redo mr-1"></i> Reiniciar </button> </div> </div> <textarea id="code-editor" class="code-editor w-full h-48 p-4 rounded-b-lg" spellcheck="false"></textarea> <div id="output-container" class="hidden mt-4"> <div class="bg-gray-800 text-white px-4 py-2 rounded-t-lg">Saída</div> <div id="code-output" class="code-editor p-4 rounded-b-lg min-h-16"></div> </div> <div id="challenge-feedback" class="hidden mt-4 p-4 rounded-lg"></div> </div> <!-- Navigation Buttons --> <div class="flex justify-between mt-8"> <button id="prev-btn" class="px-6 py-2 bg-gray-300 hover:bg-gray-400 text-gray-800 font-medium rounded-lg hidden"> <i class="fas fa-arrow-left mr-2"></i> Anterior </button> <button id="next-btn" class="px-6 py-2 bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-lg ml-auto"> Próximo <i class="fas fa-arrow-right ml-2"></i> </button> </div> </div> </div> </div> </div> <!-- Right Panel - Progress & Achievements --> <div class="bg-white rounded-xl shadow-lg overflow-hidden h-fit"> <div class="p-6"> <h2 class="text-xl font-bold text-gray-800 mb-4 flex items-center"> <i class="fas fa-map-marked-alt text-blue-500 mr-2"></i> Seu Progresso </h2> <!-- Chapter Progress --> <div class="mb-6"> <h3 class="font-semibold text-gray-700 mb-2">Capítulo 1: Fundamentos</h3> <div class="space-y-3"> <div id="lesson-1" class="flex items-center p-2 rounded-lg hover:bg-gray-50 cursor-pointer"> <div class="w-6 h-6 rounded-full bg-gray-300 mr-3 flex items-center justify-center"> <span class="text-xs text-gray-600">1</span> </div> <span class="text-gray-600">Introdução ao Python</span> </div> <div id="lesson-2" class="flex items-center p-2 rounded-lg hover:bg-gray-50 cursor-pointer"> <div class="w-6 h-6 rounded-full bg-gray-300 mr-3 flex items-center justify-center"> <span class="text-xs text-gray-600">2</span> </div> <span class="text-gray-600">Variáveis e Tipos</span> </div> <div id="lesson-3" class="flex items-center p-2 rounded-lg hover:bg-gray-50 cursor-pointer"> <div class="w-6 h-6 rounded-full bg-gray-300 mr-3 flex items-center justify-center"> <span class="text-xs text-gray-600">3</span> </div> <span class="text-gray-600">Operadores</span> </div> <div id="lesson-4" class="flex items-center p-2 rounded-lg hover:bg-gray-50 cursor-pointer"> <div class="w-6 h-6 rounded-full bg-gray-300 mr-3 flex items-center justify-center"> <span class="text-xs text-gray-600">4</span> </div> <span class="text-gray-600">Estruturas Condicionais</span> </div> <div id="lesson-5" class="flex items-center p-2 rounded-lg hover:bg-gray-50 cursor-pointer"> <div class="w-6 h-6 rounded-full bg-gray-300 mr-3 flex items-center justify-center"> <span class="text-xs text-gray-600">5</span> </div> <span class="text-gray-600">Loops</span> </div> </div> </div> <!-- Achievements --> <div> <h2 class="text-xl font-bold text-gray-800 mb-4 flex items-center"> <i class="fas fa-trophy text-yellow-500 mr-2"></i> Conquistas </h2> <div class="grid grid-cols-3 gap-3"> <div id="achievement-1" class="bg-gray-100 rounded-lg p-3 text-center opacity-50"> <i class="fas fa-star text-gray-400 text-2xl mb-1"></i> <p class="text-xs text-gray-500">Primeiros Passos</p> </div> <div id="achievement-2" class="bg-gray-100 rounded-lg p-3 text-center opacity-50"> <i class="fas fa-code text-gray-400 text-2xl mb-1"></i> <p class="text-xs text-gray-500">Primeiro Código</p> </div> <div id="achievement-3" class="bg-gray-100 rounded-lg p-3 text-center opacity-50"> <i class="fas fa-check-circle text-gray-400 text-2xl mb-1"></i> <p class="text-xs text-gray-500">Quiz Mestre</p> </div> </div> </div> </div> </div> </div> </div>
<script> // Game State const gameState = { currentLesson: 0, points: 0, completedLessons: [], soundEnabled: true, lessons: [ { title: "Introdução ao Python", content: "Python é uma linguagem de programação poderosa e fácil de aprender. É usada para desenvolvimento web, ciência de dados, automação e muito mais!<br><br>Python é conhecido por sua sintaxe limpa e legibilidade, o que o torna uma ótima escolha para iniciantes.", codeExample: `# Este é um comentário em Pythonprint("Olá, Mundo!") # Esta função imprime texto na tela`, quiz: { question: "Qual é a função usada para imprimir texto em Python?", options: [ { text: "echo()", correct: false }, { text: "print()", correct: true }, { text: "console.log()", correct: false }, { text: "output()", correct: false } ], feedback: "Correto! A função print() é usada para exibir texto no console em Python." }, challenge: { instruction: "Escreva um programa que imprima 'Python é divertido!' na tela.", solution: `print("Python é divertido!")`, test: (code) => { try { const output = []; const originalConsole = console.log; console.log = (...args) => output.push(args.join(' ')); eval(code); console.log = originalConsole; return output.includes("Python é divertido!"); } catch (e) { return false; } } } }, { title: "Variáveis e Tipos", content: "Variáveis são como caixas que armazenam dados. Em Python, você pode criar uma variável simplesmente atribuindo um valor a um nome.<br><br>Python tem vários tipos de dados básicos: inteiros (números inteiros), floats (números decimais), strings (texto) e booleanos (True/False).", codeExample: `# Criando variáveisnome = "Ana" # Stringidade = 25 # Inteiroaltura = 1.75 # Floatprogramadora = True # Booleano
print(nome, idade, altura, programadora)`, quiz: { question: "Qual destes é um tipo de dado válido em Python?", options: [ { text: "integer", correct: false }, { text: "number", correct: false }, { text: "string", correct: true }, { text: "character", correct: false } ], feedback: "Correto! 'string' é um tipo de dado em Python para representar texto." }, challenge: { instruction: "Crie variáveis para armazenar seu nome, idade e se você gosta de Python (True/False). Depois imprima essas variáveis.", solution: `nome = "SeuNome"idade = 20gosta_de_python = True
print(nome, idade, gosta_de_python)`, test: (code) => { try { const output = []; const originalConsole = console.log; console.log = (...args) => output.push(args.join(' ')); eval(code); console.log = originalConsole; return output.length > 0 && code.includes("=") && code.includes("print("); } catch (e) { return false; } } } }, { title: "Operadores", content: "Operadores são símbolos especiais que realizam operações em variáveis e valores.<br><br>Python tem operadores aritméticos (+, -, *, /), operadores de comparação (==, !=, >, <) e operadores lógicos (and, or, not).", codeExample: `# Operadores aritméticossoma = 5 + 3 # 8subtracao = 10 - 2 # 8multiplicacao = 4 * 2 # 8divisao = 16 / 2 # 8.0
# Operadores de comparaçãoigual = (5 == 5) # Truediferente = (5 != 3) # True
# Operadores lógicose_logico = (5 > 3) and (10 < 20) # Trueou_logico = (5 < 3) or (10 > 5) # Truenegacao = not (5 == 3) # True`, quiz: { question: "Qual operador é usado para verificar se dois valores são iguais?", options: [ { text: "=", correct: false }, { text: "==", correct: true }, { text: "===", correct: false }, { text: "equals", correct: false } ], feedback: "Correto! O operador == verifica igualdade entre dois valores." }, challenge: { instruction: "Calcule a área de um retângulo com largura 5 e altura 10. Armazene o resultado em uma variável e imprima.", solution: `largura = 5altura = 10area = largura * altura
print(area)`, test: (code) => { try { const output = []; const originalConsole = console.log; console.log = (...args) => output.push(args.join(' ')); eval(code); console.log = originalConsole; return output.includes("50"); } catch (e) { return false; } } } }, { title: "Estruturas Condicionais", content: "Estruturas condicionais permitem que seu programa tome decisões com base em condições.<br><br>Em Python, usamos if, elif e else para criar lógica condicional. A indentação (espaçamento no início da linha) é crucial em Python para definir blocos de código.", codeExample: `idade = 18
if idade < 12: print("Criança")elif idade < 18: print("Adolescente")else: print("Adulto")`, quiz: { question: "Qual palavra-chave é usada para adicionar uma condição alternativa em Python?", options: [ { text: "elseif", correct: false }, { text: "elif", correct: true }, { text: "otherwise", correct: false }, { text: "case", correct: false } ], feedback: "Correto! 'elif' é a abreviação de 'else if' em Python." }, challenge: { instruction: "Escreva um programa que verifica se um número (armazenado em uma variável) é positivo, negativo ou zero.", solution: `numero = 10
if numero > 0: print("Positivo")elif numero < 0: print("Negativo")else: print("Zero")`, test: (code) => { try { // Test with positive number let output = []; let modifiedCode = code.replace(/numero\s*=\s*\d+/g, 'numero = 5'); const originalConsole = console.log; console.log = (...args) => output.push(args.join(' ')); eval(modifiedCode); // Test with negative number modifiedCode = code.replace(/numero\s*=\s*\d+/g, 'numero = -3'); eval(modifiedCode); // Test with zero modifiedCode = code.replace(/numero\s*=\s*\d+/g, 'numero = 0'); eval(modifiedCode); console.log = originalConsole; return output.includes("Positivo") && output.includes("Negativo") && output.includes("Zero"); } catch (e) { return false; } } } }, { title: "Loops", content: "Loops permitem executar um bloco de código repetidamente. Python tem dois tipos principais de loops: for e while.<br><br>O loop for é usado para iterar sobre uma sequência (como uma lista ou string). O loop while repete enquanto uma condição for verdadeira.", codeExample: `# Loop forfor i in range(5): # Repete 5 vezes (0 a 4) print(i)
# Loop whilecontador = 0while contador < 5: print(contador) contador += 1 # Incrementa o contador`, quiz: { question: "Qual comando é usado para sair de um loop antes que ele termine?", options: [ { text: "stop", correct: false }, { text: "exit", correct: false }, { text: "break", correct: true }, { text: "return", correct: false } ], feedback: "Correto! O comando 'break' interrompe imediatamente a execução do loop." }, challenge: { instruction: "Use um loop for para imprimir os números de 1 a 10, mas pule o número 5 usando 'continue'.", solution: `for numero in range(1, 11): if numero == 5: continue print(numero)`, test: (code) => { try { const output = []; const originalConsole = console.log; console.log = (...args) => output.push(args.join(' ')); eval(code); console.log = originalConsole; const numbers = output.map(Number).filter(n => !isNaN(n)); return numbers.length === 9 && !numbers.includes(5) && numbers.includes(1) && numbers.includes(10); } catch (e) { return false; } } } } ] };
// DOM Elements const welcomeScreen = document.getElementById('welcome-screen'); const lessonContent = document.getElementById('lesson-content'); const lessonTitle = document.getElementById('lesson-title'); const lessonText = document.getElementById('lesson-text'); const codeExample = document.getElementById('code-example'); const codeBlock = document.getElementById('code-block'); const quizSection = document.getElementById('quiz-section'); const quizQuestion = document.getElementById('quiz-question'); const quizOptions = document.getElementById('quiz-options'); const quizFeedback = document.getElementById('quiz-feedback'); const codingChallenge = document.getElementById('coding-challenge'); const challengeText = document.getElementById('challenge-text'); const codeEditor = document.getElementById('code-editor'); const outputContainer = document.getElementById('output-container'); const codeOutput = document.getElementById('code-output'); const challengeFeedback = document.getElementById('challenge-feedback'); const nextBtn = document.getElementById('next-btn'); const prevBtn = document.getElementById('prev-btn'); const startBtn = document.getElementById('start-btn'); const pointsDisplay = document.getElementById('points'); const progressBar = document.getElementById('progress-bar'); const soundBtn = document.getElementById('sound-btn'); const copyCodeBtn = document.getElementById('copy-code-btn'); const runCodeBtn = document.getElementById('run-code-btn'); const resetCodeBtn = document.getElementById('reset-code-btn');
// Lesson navigation let currentStep = 0; // 0 = lesson, 1 = quiz, 2 = challenge
// Initialize the game function initGame() { startBtn.addEventListener('click', startGame); nextBtn.addEventListener('click', nextStep); prevBtn.addEventListener('click', prevStep); soundBtn.addEventListener('click', toggleSound); copyCodeBtn.addEventListener('click', copyCode); runCodeBtn.addEventListener('click', runCode); resetCodeBtn.addEventListener('click', resetCode); // Set up lesson navigation for (let i = 1; i <= 5; i++) { document.getElementById(`lesson-${i}`).addEventListener('click', () => { if (gameState.completedLessons.includes(i-1) || i === 1) { loadLesson(i-1); } }); } }
// Start the game function startGame() { welcomeScreen.classList.add('hidden'); lessonContent.classList.remove('hidden'); loadLesson(0); playSound('start'); }
// Load a lesson function loadLesson(lessonIndex) { gameState.currentLesson = lessonIndex; currentStep = 0; const lesson = gameState.lessons[lessonIndex]; // Update UI lessonTitle.textContent = lesson.title; lessonText.innerHTML = lesson.content; // Show code example if available if (lesson.codeExample) { codeBlock.textContent = lesson.codeExample; codeExample.classList.remove('hidden'); } else { codeExample.classList.add('hidden'); } // Hide quiz and challenge sections initially quizSection.classList.add('hidden'); codingChallenge.classList.add('hidden'); // Update navigation buttons prevBtn.classList.add('hidden'); nextBtn.textContent = 'Próximo'; // Update progress updateProgress(); // Highlight current lesson in sidebar document.querySelectorAll('[id^="lesson-"]').forEach(el => { el.classList.remove('bg-blue-50', 'border-l-4', 'border-blue-500'); }); document.getElementById(`lesson-${lessonIndex+1}`).classList.add('bg-blue-50', 'border-l-4', 'border-blue-500'); playSound('page'); }
// Next step in lesson function nextStep() { const lesson = gameState.lessons[gameState.currentLesson]; if (currentStep === 0) { // Show quiz currentStep = 1; quizSection.classList.remove('hidden'); quizQuestion.textContent = lesson.quiz.question; // Clear previous options quizOptions.innerHTML = ''; // Add new options lesson.quiz.options.forEach((option, index) => { const optionBtn = document.createElement('button'); optionBtn.className = 'p-3 bg-gray-100 hover:bg-gray-200 rounded-lg text-left'; optionBtn.textContent = option.text; optionBtn.addEventListener('click', () => checkAnswer(index)); quizOptions.appendChild(optionBtn); }); quizFeedback.classList.add('hidden'); prevBtn.classList.remove('hidden'); nextBtn.textContent = 'Próximo'; if (!gameState.completedLessons.includes(gameState.currentLesson)) { nextBtn.disabled = true; } } else if (currentStep === 1) { // Show coding challenge currentStep = 2; quizSection.classList.add('hidden'); codingChallenge.classList.remove('hidden'); challengeText.textContent = lesson.challenge.instruction; codeEditor.value = ''; outputContainer.classList.add('hidden'); challengeFeedback.classList.add('hidden'); prevBtn.classList.remove('hidden'); nextBtn.textContent = 'Concluir'; nextBtn.disabled = true; } else if (currentStep === 2) { // Complete lesson if (!gameState.completedLessons.includes(gameState.currentLesson)) { gameState.completedLessons.push(gameState.currentLesson); gameState.points += 50; updateProgress(); // Unlock next lesson if available if (gameState.currentLesson < gameState.lessons.length - 1) { document.getElementById(`lesson-${gameState.currentLesson + 2}`).classList.remove('cursor-not-allowed'); } // Check achievements checkAchievements(); } // Load next lesson or go back to menu if (gameState.currentLesson < gameState.lessons.length - 1) { loadLesson(gameState.currentLesson + 1); } else { // All lessons completed lessonContent.classList.add('hidden'); welcomeScreen.classList.remove('hidden'); welcomeScreen.innerHTML = ` <div class="text-center py-12"> <i class="fas fa-trophy text-8xl text-yellow-500 mb-6"></i> <h2 class="text-4xl font-bold text-gray-800 mb-4">Parabéns!</h2> <p class="text-xl text-gray-600 mb-8">Você completou todos os módulos básicos de Python!</p> <p class="text-lg text-gray-700 mb-8">Você ganhou ${gameState.points} XP!</p> <button id="restart-btn" class="px-8 py-3 bg-blue-600 hover:bg-blue-700 text-white font-bold rounded-lg text-lg transition duration-300 transform hover:scale-105"> Jogar Novamente </button> </div> `; document.getElementById('restart-btn').addEventListener('click', () => { location.reload(); }); playSound('complete'); } } }
// Previous step in lesson function prevStep() { if (currentStep === 1) { // Back to lesson currentStep = 0; quizSection.classList.add('hidden'); prevBtn.classList.add('hidden'); nextBtn.textContent = 'Próximo'; nextBtn.disabled = false; } else if (currentStep === 2) { // Back to quiz currentStep = 1; codingChallenge.classList.add('hidden'); quizSection.classList.remove('hidden'); nextBtn.textContent = 'Próximo'; nextBtn.disabled = !gameState.completedLessons.includes(gameState.currentLesson); } }
// Check quiz answer function checkAnswer(optionIndex) { const lesson = gameState.lessons[gameState.currentLesson]; const isCorrect = lesson.quiz.options[optionIndex].correct; // Disable all options const options = quizOptions.querySelectorAll('button'); options.forEach(btn => { btn.disabled = true; if (lesson.quiz.options[btn._index].correct) { btn.classList.add('bg-green-100', 'border', 'border-green-500'); } else if (btn._index === optionIndex && !isCorrect) { btn.classList.add('bg-red-100', 'border', 'border-red-500', 'shake'); } }); // Show feedback quizFeedback.classList.remove('hidden'); quizFeedback.textContent = isCorrect ? '✅ ' + lesson.quiz.feedback : '❌ Resposta incorreta. Tente novamente!'; quizFeedback.className = `p-4 rounded-lg mb-6 ${isCorrect ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800'}`; // Enable next button if correct if (isCorrect) { nextBtn.disabled = false; playSound('correct'); } else { playSound('wrong'); } }
// Run code in challenge function runCode() { const lesson = gameState.lessons[gameState.currentLesson]; const code = codeEditor.value; try { // Capture output const output = []; const originalConsole = console.log; console.log = (...args) => output.push(args.join(' ')); // Execute code eval(code); // Restore console console.log = originalConsole; // Display output codeOutput.textContent = output.join('\n'); outputContainer.classList.remove('hidden'); // Check if challenge is solved const isCorrect = lesson.challenge.test(code); if (isCorrect) { challengeFeedback.classList.remove('hidden'); challengeFeedback.textContent = '✅ Desafio concluído com sucesso!'; challengeFeedback.className = 'p-4 rounded-lg bg-green-100 text-green-800'; nextBtn.disabled = false; playSound('correct'); } else { challengeFeedback.classList.remove('hidden'); challengeFeedback.textContent = '❌ Ainda não está correto. Continue tentando!'; challengeFeedback.className = 'p-4 rounded-lg bg-red-100 text-red-800'; playSound('wrong'); } } catch (error) { codeOutput.textContent = `Erro: ${error.message}`; outputContainer.classList.remove('hidden'); challengeFeedback.classList.remove('hidden'); challengeFeedback.textContent = '❌ Seu código contém erros. Corrija e tente novamente.'; challengeFeedback.className = 'p-4 rounded-lg bg-red-100 text-red-800'; playSound('wrong'); } }
// Reset code editor function resetCode() { codeEditor.value = ''; outputContainer.classList.add('hidden'); challengeFeedback.classList.add('hidden'); playSound('page'); }
// Copy code example function copyCode() { const lesson = gameState.lessons[gameState.currentLesson]; navigator.clipboard.writeText(lesson.codeExample); // Show feedback const originalText = copyCodeBtn.innerHTML; copyCodeBtn.innerHTML = '<i class="fas fa-check mr-1"></i> Copiado!'; setTimeout(() => { copyCodeBtn.innerHTML = originalText; }, 2000); playSound('click'); }
// Toggle sound function toggleSound() { gameState.soundEnabled = !gameState.soundEnabled; soundBtn.innerHTML = gameState.soundEnabled ? '<i class="fas fa-volume-up text-gray-700"></i>' : '<i class="fas fa-volume-mute text-gray-700"></i>'; playSound('click'); }
// Play sound function playSound(type) { if (!gameState.soundEnabled) return; const sounds = { click: { freq: 800, duration: 0.1, type: 'sine' }, page: { freq: 500, duration: 0.2, type: 'sine' }, correct: { freq: 1046.5, duration: 0.3, type: 'square' }, wrong: { freq: 220, duration: 0.5, type: 'sawtooth' }, start: { freq: [523.25, 659.25, 783.99], duration: [0.2, 0.2, 0.3], type: 'sine' }, complete: { freq: [783.99, 659.25, 523.25], duration: [0.3, 0.3, 0.5], type: 'sine' } }; const sound = sounds[type]; const audioCtx = new (window.AudioContext || window.webkitAudioContext)(); if (Array.isArray(sound.freq)) { // Play sequence of tones sound.freq.forEach((freq, i) => { const oscillator = audioCtx.createOscillator(); const gainNode = audioCtx.createGain(); oscillator.type = sound.type; oscillator.frequency.value = freq; oscillator.connect(gainNode); gainNode.connect(audioCtx.destination); gainNode.gain.setValueAtTime(1, audioCtx.currentTime); gainNode.gain.exponentialRampToValueAtTime(0.01, audioCtx.currentTime + sound.duration[i]); oscillator.start(); oscillator.stop(audioCtx.currentTime + sound.duration[i]); }); } else { // Play single tone const oscillator = audioCtx.createOscillator(); const gainNode = audioCtx.createGain(); oscillator.type = sound.type; oscillator.frequency.value = sound.freq; oscillator.connect(gainNode); gainNode.connect(audioCtx.destination); gainNode.gain.setValueAtTime(1, audioCtx.currentTime); gainNode.gain.exponentialRampToValueAtTime(0.01, audioCtx.currentTime + sound.duration); oscillator.start(); oscillator.stop(audioCtx.currentTime + sound.duration); } }
// Update progress display function updateProgress() { pointsDisplay.textContent = gameState.points; const progress = (gameState.completedLessons.length / gameState.lessons.length) * 100; progressBar.style.width = `${progress}%`; }
// Check and unlock achievements function checkAchievements() { // First steps if (gameState.completedLessons.length === 1) { document.getElementById('achievement-1').classList.remove('opacity-50'); document.getElementById('achievement-1').classList.add('bg-yellow-100'); document.getElementById('achievement-1').querySelector('i').classList.remove('text-gray-400'); document.getElementById('achievement-1').querySelector('i').classList.add('text-yellow-500'); document.getElementById('achievement-1').querySelector('p').classList.remove('text-gray-500'); document.getElementById('achievement-1').querySelector('p').classList.add('text-yellow-700'); playSound('correct'); } // First code if (gameState.completedLessons.length >= 2) { document.getElementById('achievement-2').classList.remove('opacity-50'); document.getElementById('achievement-2').classList.add('bg-yellow-100'); document.getElementById('achievement-2').querySelector('i').classList.remove('text-gray-400'); document.getElementById('achievement-2').querySelector('i').classList.add('text-yellow-500'); document.getElementById('achievement-2').querySelector('p').classList.remove('text-gray-500'); document.getElementById('achievement-2').querySelector('p').classList.add('text-yellow-700'); } // Quiz master if (gameState.completedLessons.length === gameState.lessons.length) { document.getElementById('achievement-3').classList.remove('opacity-50'); document.getElementById('achievement-3').classList.add('bg-yellow-100'); document.getElementById('achievement-3').querySelector('i').classList.remove('text-gray-400'); document.getElementById('achievement-3').querySelector('i').classList.add('text-yellow-500'); document.getElementById('achievement-3').querySelector('p').classList.remove('text-gray-500'); document.getElementById('achievement-3').querySelector('p').classList.add('text-yellow-700'); } }
// Initialize quiz option indexes document.querySelectorAll('#quiz-options button').forEach((btn, index) => { btn._index = index; });
// Start the game initGame(); </script><p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Evandrocostasoares/python" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body></html>README.md+7-5
index.html+877-19
prompts.txtAdded