diff --git a/Games/.DS_Store b/Games/.DS_Store index 2dd9e52478..3571fbeaf6 100644 Binary files a/Games/.DS_Store and b/Games/.DS_Store differ diff --git a/Games/FruitCutiingGame/.DS_Store b/Games/FruitCutiingGame/.DS_Store new file mode 100644 index 0000000000..44b1fb6b5f Binary files /dev/null and b/Games/FruitCutiingGame/.DS_Store differ diff --git a/Games/FruitCutiingGame/assets/apple.png b/Games/FruitCutiingGame/assets/apple.png new file mode 100644 index 0000000000..0a3d6b4bbe Binary files /dev/null and b/Games/FruitCutiingGame/assets/apple.png differ diff --git a/Games/FruitCutiingGame/assets/banana.png b/Games/FruitCutiingGame/assets/banana.png new file mode 100644 index 0000000000..1b9c921642 Binary files /dev/null and b/Games/FruitCutiingGame/assets/banana.png differ diff --git a/Games/FruitCutiingGame/assets/graphes.png b/Games/FruitCutiingGame/assets/graphes.png new file mode 100644 index 0000000000..efb3850a75 Binary files /dev/null and b/Games/FruitCutiingGame/assets/graphes.png differ diff --git a/Games/FruitCutiingGame/assets/knife.png b/Games/FruitCutiingGame/assets/knife.png new file mode 100644 index 0000000000..3688d72e54 Binary files /dev/null and b/Games/FruitCutiingGame/assets/knife.png differ diff --git a/Games/FruitCutiingGame/assets/mango.png b/Games/FruitCutiingGame/assets/mango.png new file mode 100644 index 0000000000..b0385aa127 Binary files /dev/null and b/Games/FruitCutiingGame/assets/mango.png differ diff --git a/Games/FruitCutiingGame/assets/orange.png b/Games/FruitCutiingGame/assets/orange.png new file mode 100644 index 0000000000..50d7ecf465 Binary files /dev/null and b/Games/FruitCutiingGame/assets/orange.png differ diff --git a/Games/FruitCutiingGame/assets/papaya.png b/Games/FruitCutiingGame/assets/papaya.png new file mode 100644 index 0000000000..e6857b0c0e Binary files /dev/null and b/Games/FruitCutiingGame/assets/papaya.png differ diff --git a/Games/FruitCutiingGame/assets/watermelon.png b/Games/FruitCutiingGame/assets/watermelon.png new file mode 100644 index 0000000000..19839b0282 Binary files /dev/null and b/Games/FruitCutiingGame/assets/watermelon.png differ diff --git a/Games/FruitCutiingGame/index.html b/Games/FruitCutiingGame/index.html new file mode 100644 index 0000000000..c935cbeb39 --- /dev/null +++ b/Games/FruitCutiingGame/index.html @@ -0,0 +1,30 @@ + + + + + + Fruit Cutting Game + + + +
+
+
0
+
+ + + + + +
Start Game
+
Play Again
+ + + + diff --git a/Games/FruitCutiingGame/music/background.mp3 b/Games/FruitCutiingGame/music/background.mp3 new file mode 100644 index 0000000000..9ea719dd18 Binary files /dev/null and b/Games/FruitCutiingGame/music/background.mp3 differ diff --git a/Games/FruitCutiingGame/music/cut.mp3 b/Games/FruitCutiingGame/music/cut.mp3 new file mode 100644 index 0000000000..80143b581c Binary files /dev/null and b/Games/FruitCutiingGame/music/cut.mp3 differ diff --git a/Games/FruitCutiingGame/script.js b/Games/FruitCutiingGame/script.js new file mode 100644 index 0000000000..d01f9c01c1 --- /dev/null +++ b/Games/FruitCutiingGame/script.js @@ -0,0 +1,120 @@ + +const fruits = [ + 'apple.png', + 'orange.png', + 'banana.png', + 'graphes.png', + 'papaya.png', + 'watermelon.png', + 'mango.png' + +]; + +let score = 0; +let gameTime = 0; +let gameRunning = false; +let gameInterval; + +function startGame() { + gameRunning = true; + document.querySelector('.start-button').style.display = 'none'; // Hide start button + const gameContainer = document.querySelector('.game-container'); + gameContainer.addEventListener('mousemove', moveKnife); + + function moveKnife(event) { + const knife = document.querySelector('.knife'); + knife.style.left = event.clientX - knife.offsetWidth / 2 + 'px'; + knife.style.top = event.clientY - knife.offsetHeight / 2 + 'px'; + } + + function createFruit() { + if (!gameRunning) return; + + const fruit = document.createElement('div'); + fruit.classList.add('fruit'); + const randomFruit = fruits[Math.floor(Math.random() * fruits.length)]; + fruit.style.backgroundImage = `url('${randomFruit}')`; + fruit.style.left = Math.random() * (window.innerWidth - 100) + 'px'; + fruit.style.top = '0px'; + gameContainer.appendChild(fruit); + + moveFruit(fruit); + } + + gameInterval = setInterval(createFruit, 1000); + setTimeout(endGame, 30000); + setInterval(updateGameTime, 1000); + + document.getElementById('backgroundMusic').play(); // Start background music +} + +function moveFruit(fruitElement) { + let position = 0; + const interval = setInterval(() => { + if (!gameRunning) { + clearInterval(interval); + return; + } + + position += 20; + fruitElement.style.top = position + 'px'; + + const knife = document.querySelector('.knife'); + if (knife && checkCollision(fruitElement, knife)) { + fruitElement.style.backgroundImage = 'none'; + fruitElement.style.backgroundColor = 'red'; + fruitElement.style.borderRadius = '50%'; // Make it a small circle + + score++; + document.getElementById('score').textContent = score; + playCutSound(); // Play sound effect + + setTimeout(() => { + fruitElement.remove(); + }, 100); + } + + if (position >= window.innerHeight) { + fruitElement.remove(); + } + }, 20); +} + +function playCutSound() { + const cutSound = document.getElementById('cutSound'); + cutSound.currentTime = 0; // Reset sound to start + cutSound.play(); +} + +function checkCollision(fruit, knife) { + const fruitRect = fruit.getBoundingClientRect(); + const knifeRect = knife.getBoundingClientRect(); + + return !( + fruitRect.right < knifeRect.left || + fruitRect.left > knifeRect.right || + fruitRect.bottom < knifeRect.top || + fruitRect.top > knifeRect.bottom + ); +} + +function updateGameTime() { + gameTime++; +} + +function endGame() { + gameRunning = false; + clearInterval(gameInterval); + document.getElementById('backgroundMusic').pause(); + document.querySelector('.play-again').style.display = 'block'; + alert(`Game Over! Your score: ${score} in ${gameTime} seconds.`); +} + +function startNewGame() { + score = 0; + gameTime = 0; + gameRunning = true; + document.getElementById('score').textContent = score; + document.querySelector('.play-again').style.display = 'none'; + startGame(); +} diff --git a/Games/FruitCutiingGame/styles.css b/Games/FruitCutiingGame/styles.css new file mode 100644 index 0000000000..43b19d0954 --- /dev/null +++ b/Games/FruitCutiingGame/styles.css @@ -0,0 +1,64 @@ +body { + margin: 10; + overflow: hidden; + font-family: Arial, sans-serif; + background: url('https://ideogram.ai/assets/progressive-image/balanced/response/gbfrHHRRSAeEt7Si6GCOuw'); +background-size: cover; +background-repeat: no-repeat; +} + +.game-container { + position: relative; + width: 100vw; + height: 100vh; + + +} + +.knife { + position: absolute; + width: 150px; + height: 150px; + background: url('knife.png') no-repeat center center; + background-size: contain; + pointer-events: none; +} + +#scoreboard { + position: absolute; + top: 10px; + left: 10px; + font-size: 24px; +} +.fruit { + width: 100px; + height: 100px; + background-size: cover; + position: absolute; + transition: background-color 0.3s ease-out; + border-radius: 50%; +} +.play-again { + position: fixed; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + padding: 10px 20px; + background-color: #551363; + color: white; + font-size: 18px; + cursor: pointer; + display: none; +} +.start-button { + position: fixed; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + padding: 20px 40px; + background-color: #0f296b; + color: white; + font-size: 24px; + cursor: pointer; + display: block; +} \ No newline at end of file