diff --git a/math_practice_1/button.png b/math_practice_1/button.png new file mode 100644 index 0000000..28e00d5 Binary files /dev/null and b/math_practice_1/button.png differ diff --git a/math_practice_1/main.js b/math_practice_1/main.js index 6f08d80..5737020 100644 --- a/math_practice_1/main.js +++ b/math_practice_1/main.js @@ -7,7 +7,7 @@ document.addEventListener('DOMContentLoaded', (event) => { let currentQuestion = {}; let score = 0; -let difficulty = 'easy'; // Default difficulty level +let difficulty = loadSettings().difficulty; // Load difficulty from settings // Initialize the game function initGame() { @@ -94,7 +94,7 @@ function createQuestion(difficulty) { // Check the user's answer function checkAnswer(selectedAnswer) { const feedbackElement = document.getElementById('feedback-message'); - if (selectedAnswer === currentQuestion.correctAnswer) { + if (selectedAnswer == currentQuestion.correctAnswer) { // Use == for type coercion score++; feedbackElement.innerText = 'Correct!'; } else { @@ -110,4 +110,18 @@ function checkAnswer(selectedAnswer) { // Get a random integer between min (inclusive) and max (inclusive) function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; +} + +// Load settings from local storage +function loadSettings() { + const settings = localStorage.getItem('gameSettings'); + if (settings) { + return JSON.parse(settings); + } else { + // Default settings + return { + difficulty: 'easy', + sound: true + }; + } } \ No newline at end of file diff --git a/math_practice_1/settings.html b/math_practice_1/settings.html index 6955fe7..b4addfc 100644 --- a/math_practice_1/settings.html +++ b/math_practice_1/settings.html @@ -3,10 +3,15 @@ - Game Settings + Settings + +

Settings

+
+ + +
+ + +
+ +
+
diff --git a/math_practice_1/styles.css b/math_practice_1/styles.css index 9ab4af3..6c3ce0a 100644 --- a/math_practice_1/styles.css +++ b/math_practice_1/styles.css @@ -105,4 +105,23 @@ body { .instructions button, .settings button { margin-top: 20px; +} + +/* Settings Form */ +#settings-form { + display: flex; + flex-direction: column; + align-items: flex-start; +} + +#settings-form label { + margin-bottom: 10px; +} + +#settings-form select, #settings-form input { + margin-bottom: 20px; +} + +#settings-form button { + align-self: center; } \ No newline at end of file