diff --git a/Games/Alien_Invasion/.DS_Store b/Games/Alien_Invasion/.DS_Store new file mode 100644 index 0000000000..74e30099e6 Binary files /dev/null and b/Games/Alien_Invasion/.DS_Store differ diff --git a/Games/Alien_Invasion/README..md b/Games/Alien_Invasion/README..md new file mode 100644 index 0000000000..17a09c4382 --- /dev/null +++ b/Games/Alien_Invasion/README..md @@ -0,0 +1,20 @@ +# AttackAlienInvaders Game App +A cool 2D alien planet exploration steampunk-themed game application with techniques of vanilla JavaScript, HTML5, CSS3 and HTML Canvas. From sprite animation to parallax backgrounds, the game App is completely built from scratch, with no frameworks or libraries, using HTML, CSS and plain vanilla JavaScript. The game contains richful premium art assets for characters, environments and props. + +### [Game Won Demo](https://github.com/KrystalZhang612/KrystalZhang-AttackAlienInvaders-Game-App/blob/main/testing-result-AttackAlienInvader-game-app/Won%20Game.mov): Most Wondrous! Well done explorer! +https://user-images.githubusercontent.com/72481348/198857930-95a5c040-1d47-4ca6-b5a6-15ac05e8e520.mov +### [Game Lost Demo](https://github.com/KrystalZhang612/KrystalZhang-AttackAlienInvaders-Game-App/blob/main/testing-result-AttackAlienInvader-game-app/Lost%20Game.mov): Blazed! Get my repair kit and try again! +https://user-images.githubusercontent.com/72481348/198857699-86d076d4-f746-435b-89ec-333ad1ba01b8.mov + +# Game Premiere Storyline +***Central Computer***:
+`These alien creatures have very similar physiology to the earth seahorses. Their bodies can easily cut through the thick atmosphere. They can move very fast.`
+***Explorer***:
+`Seahorses hives are being attacked by something. This one has been damaged. I wonder if you can hack into this creature’s central computer to control it for a while.`
+***Central Computer***:
+`It is surprisingly easy to override its circuits. Seems like these machines are not used by our technology. I’m getting a lot of new data.`
+***Central Computer***:
+`The atmosphere on this planet is thick enough to allow heavy silicon-based lifeforms to float but smoke is blocking most of the sunlight. Many creatures developed artificial lights and glowing appendages to see through the heavy clouds. The Seahorse sentinel has a basic attack that’s powerful against weak enemies, but if it absorbs energy from one of the overcharged creatures, it gets additional firepower for a short period of time and it instantly replenishes its ammo. Ammo also automatically recharges over time. It seems we just need to help it to get through these aggressive swarms in time so it can join its hive.` +- There is a stream of data about multiple different species. +- The alien creatures in the hood of their ecosystem have special movements, special abilities, and interact with the environments on other planets. + diff --git a/Games/Alien_Invasion/index.html b/Games/Alien_Invasion/index.html new file mode 100644 index 0000000000..760bb1af1b --- /dev/null +++ b/Games/Alien_Invasion/index.html @@ -0,0 +1,44 @@ + + + + + + + + AttackAlienInvader Game + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Games/Alien_Invasion/script.js b/Games/Alien_Invasion/script.js new file mode 100644 index 0000000000..5e50da0a0c --- /dev/null +++ b/Games/Alien_Invasion/script.js @@ -0,0 +1,543 @@ +window.addEventListener('load', function () { + //canvas setup + const canvas = document.getElementById('canvas1'); + const ctx = canvas.getContext('2d'); + canvas.width = 1000; + canvas.height = 500; + + class InputHandler { + constructor(game) { + this.game = game; + window.addEventListener('keydown', e => { + if (((e.key === 'ArrowUp') || + (e.key === 'ArrowDown') + ) && this.game.keys.indexOf(e.key) === - 1) { + this.game.keys.push(e.key); + } else if (e.key === ' ') { + this.game.player.shootTop(); + } else if (e.key === 'd') { + this.game.debug = !this.game.debug; + } + }); + window.addEventListener('keyup', e => { + if (this.game.keys.indexOf(e.key) > -1) { + this.game.keys.splice(this.game.keys.indexOf(e.key), 1); + } + }); + } + } + + class Projectile { + constructor(game, x, y) { + this.game = game; + this.x = x; + this.y = y; + this.width = 10; + this.height = 3; + this.speed = 3; + this.markedForDeletion = false; + this.image = document.getElementById('projectile'); + } + update() { + this.x += this.speed; + if (this.x > this.game.width * 0.8) this.markedForDeletion = true; + } + draw(context) { + context.drawImage(this.image, this.x, this.y); + } + } + + class Particle { + constructor(game, x, y) { + this.game = game; + this.x = x; + this.y = y; + this.image = document.getElementById('gears'); + this.frameX = Math.floor(Math.random() * 3); + this.frameY = Math.floor(Math.random() * 3); + this.spriteSize = 50; + this.sizeModifier = (Math.random() * 0.5 + 0.5).toFixed(1); + this.size = this.spriteSize * this.sizeModifier; + this.speedX = Math.random() * 6 - 3; + this.speedY = Math.random() * -15; + this.gravity = 0.5; + this.markedForDeletion = false; + this.angle = 0; + this.va = Math.random() * 0.2 - 0.1; + this.bounced = 0; + this.bottomBounceBoundary = Math.random() * 80 + 60; + } + update() { + this.angle += this.va; + this.speedY += this.gravity; + this.x -= this.speedX - this.game.speed; + this.y += this.speedY; + if (this.y > this.game.height + this.size || this.x < 0 - this.size) this.markedForDeletion = true; + if (this.y > this.game.height - this.bottomBounceBoundary && this.bounced < 5) { + this.bounced++; + this.speedY *= -0.7; + } + } + draw(context) { + context.save(); + context.translate(this.x, this.y); + context.rotate(this.angle); + context.drawImage(this.image, this.frameX * this.spriteSize, + this.frameY * this.spriteSize, this.spriteSize, this.spriteSize, this.size * -0.5, + this.size * -0.5, this.size, this.size); + context.restore(); + } + } + + class Player { + constructor(game) { + this.game = game; + this.width = 120; + this.height = 190; + this.x = 20; + this.y = 100; + this.frameX = 0; + this.frameY = 0; + this.maxFrame = 37; + this.speedY = 0; + this.maxSpeed = 3; + this.projectiles = []; + this.image = document.getElementById('player'); + this.powerUp = false; + this.powerUpTimer = 0; + this.powerUpLimit = 10000; + } + update(deltaTime) { + if (this.game.keys.includes('ArrowUp')) this.speedY = -this.maxSpeed; + else if (this.game.keys.includes('ArrowDown')) this.speedY = this.maxSpeed; + else this.speedY = 0; + this.y += this.speedY; + // vertical boundaries + if (this.y > this.game.height - this.height * 0.5) this.y = this.game.height - this.height * 0.5; + else if (this.y < -this.height * 0.5) this.y - this.height * 0.5; + //handle projectiles + this.projectiles.forEach(projectile => { + projectile.update(); + }); + this.projectiles = this.projectiles.filter(projectile => !projectile.markedForDeletion); + //sprite animation + if (this.frameX < this.maxFrame) { + this.frameX++; + } else { + this.frameX = 0; + } + // power up + if (this.powerUp) { + if (this.powerUpTimer > this.powerUpLimit) { + this.powerUpTimer = 0; + this.powerUp = false; + this.frameY = 0; + } else { + this.powerUpTimer += deltaTime; + this.frameY = 1; + this.game.ammo += 0.1; + } + } + } + draw(context) { + if (this.game.debug) context.strokeRect(this.x, this.y, this.width, this.height); + this.projectiles.forEach(projectile => { + projectile.draw(context); + }); + context.drawImage(this.image, this.frameX * this.width, this.frameY * this.height, this.width, this.height, this.x, this.y, this.width, this.height); + + } + shootTop() { + if (this.game.ammo > 0) { + this.projectiles.push(new Projectile(this.game, this.x + 80, this.y + 30)); + this.game.ammo--; + } + if (this.powerUp) this.shootBottom(); + } + shootBottom() { + if (this.game.ammo > 0) { + this.projectiles.push(new Projectile(this.game, this.x + 80, this.y + 175)); + } + } + + enterPowerUp() { + this.powerUpTimer = 0; + this.powerUp = true; + if (this.game.ammo < this.game.maxAmmo) this.game.ammo = this.game.maxAmmo; + } + } + class Enemy { + constructor(game) { + this.game = game; + this.x = this.game.width; + this.speedX = Math.random() * -1.5 - 0.5; + this.markedForDeletion = false; + this.frameX = 0; + this.frameY = 0; + this.maxFrame = 37; + } + update() { + this.x += this.speedX - this.game.speed; + if (this.x + this.width < 0) this.markedForDeletion = true; + // sprite animation + if (this.frameX < this.maxFrame) { + this.frameX++; + } else this.frameX = 0; + } + draw(context) { + if (this.game.debug) context.strokeRect(this.x, this.y, this.width, this.height); + context.drawImage(this.image, this.frameX * this.width, this.frameY * this.height, this.width, this.height, this.x, this.y, this.width, this.height); + if (this.game.debug) { + context.font = '20px Bangers'; + context.fillText(this.lives, this.x, this.y); + } + } + } + class Angler1 extends Enemy { + constructor(game) { + super(game); + this.width = 228; + this.height = 169; + this.y = Math.random() * (this.game.height * 0.95 - this.height); + this.image = document.getElementById('angler1'); + this.frameY = Math.floor(Math.random() * 3); + this.lives = 5; + this.score = this.lives; + } + + } + class Angler2 extends Enemy { + constructor(game) { + super(game); + this.width = 213; + this.height = 165; + this.y = Math.random() * (this.game.height * 0.95 - this.height); + this.image = document.getElementById('angler2'); + this.frameY = Math.floor(Math.random() * 2); + this.lives = 6; + this.score = this.lives; + } + + } + + class LuckyFish extends Enemy { + constructor(game) { + super(game); + this.width = 99; + this.height = 95; + this.y = Math.random() * (this.game.height * 0.95 - this.height); + this.image = document.getElementById('lucky'); + this.frameY = Math.floor(Math.random() * 2); + this.lives = 5; + this.score = 15; + this.type = 'lucky' + } + } + + class HiveWhale extends Enemy { + constructor(game) { + super(game); + this.width = 400; + this.height = 227; + this.y = Math.random() * (this.game.height * 0.95 - this.height); + this.image = document.getElementById('hivewhale'); + this.frameY = 0; + this.lives = 20; + this.score = this.lives; + this.type = 'hive'; + this.speedX = Math.random() * -1.2 - 0.2; + } + } + + class Drone extends Enemy { + constructor(game, x, y) { + super(game); + this.width = 115; + this.height = 95; + this.x = x; + this.y = y; + this.image = document.getElementById('drone'); + this.frameY = Math.floor(Math.random() * 2); + this.lives = 3; + this.score = this.lives; + this.type = 'drone'; + this.speedX = Math.random() * -4.2 - 0.5; + } + } + + + class Layer { + constructor(game, image, speedModifier) { + this.game = game; + this.image = image; + this.speedModifier = speedModifier; + this.width = 1768; + this.height = 500; + this.x = 0; + this.y = 0; + } + update() { + if (this.x <= -this.width) this.x = 0; + this.x -= this.game.speed * this.speedModifier; + } + draw(context) { + context.drawImage(this.image, this.x, this.y); + context.drawImage(this.image, this.x + this.width, this.y); + } + } + + class Background { + constructor(game) { + this.game = game; + this.image1 = document.getElementById('layer1'); + this.image2 = document.getElementById('layer2'); + this.image3 = document.getElementById('layer3'); + this.image4 = document.getElementById('layer4'); + this.layer1 = new Layer(this.game, this.image1, 0.2); + this.layer2 = new Layer(this.game, this.image2, 0.4); + this.layer3 = new Layer(this.game, this.image3, 1); + this.layer4 = new Layer(this.game, this.image4, 1.5); + this.layers = [this.layer1, this.layer2, this.layer3, this.layer4]; + } + update() { + this.layers.forEach(layer => layer.update()); + } + draw(context) { + this.layers.forEach(layer => layer.draw(context)); + } + + } + + class Explosion { + constructor(game, x, y) { + this.game = game; + this.frameX = 0; + this.spriteWidth = 200; + this.spriteHeight = 200; + this.width = this.spriteWidth; + this.height = this.spriteHeight; + this.x = x - this.width * 0.5; + this.y = y - this.height * 0.5; + this.fps = 30; + this.time = 0; + this.interval = 1000 / this.fps; + this.markedForDeletion = false; + this.maxFrame = 8; + } + update(deltaTime) { + this.x -= this.game.speed; + if (this.timer > this.interval) { + this.frameX++; + this.timer = 0; + } else { + this.timer += deltaTime; + } + if (this.frameX > this.maxFrame) this.markedForDeletion = true; + } + draw(context) { + context.drawImage(this.image, this.frameX * this.spriteWidth, 0, this.spriteWidth, + this.spriteHeight, this.x, this.y, this.width, this.height); + } + } + + class SmokeExplosion extends Explosion { + constructor(game, x, y) { + super(game, x, y); + this.image = document.getElementById('smokeExplosion'); + } + } + + class FireExplosion extends Explosion { + constructor(game, x, y) { + super(game, x, y); + this.image = document.getElementById('fireExplosion'); + } + } + + + class UI { + constructor(game) { + this.game = game; + this.fontSize = 25; + this.fontFamily = 'Bangers'; + this.color = 'yellow'; + } + draw(context) { + context.save(); + context.fillStyle = this.color; + context.shadowOffsetX = 2; + context.shadowOffsetY = 2; + context.shadowColor = 'black'; + context.font = this.fontSize + 'px' + this.fontFamily; + //score + context.font = '20px Bangers'; + context.fillText('Score: ' + this.game.score, 20, 40); + + //timer + const formattedTime = (this.game.gameTime * 0.001).toFixed(1); + context.font = '20px Bangers'; + context.fillText('Timer:' + formattedTime, 20, 100); + + //game over messages + if (this.game.gameOver) { + context.textAlign = 'center'; + let message1; + let message2; + if (this.game.score > this.game.winningScore) { + message1 = 'Most Wondrous!'; + message2 = 'Well Done explorer!'; + } else { + message1 = 'Blazes!'; + message2 = 'Get my repair kit and try again!'; + } + context.font = '50px Bangers'; + context.fillText(message1, this.game.width * 0.5, this.game.height * 0.5 - 20); + context.font = '25px Bangers'; + context.fillText(message2, this.game.width * 0.5, this.game.height * 0.5 + 20); + } + //ammo + if (this.game.player.powerUp) context.fillStyle = '#ffffbd'; + for (let i = 0; i < this.game.ammo; i++) { + context.fillRect(20 + 5 * i, 50, 3, 20); + } + context.restore(); + } + } + class Game { + constructor(width, height) { + this.width = width; + this.height = height; + this.background = new Background(this); + this.player = new Player(this); + this.input = new InputHandler(this); + this.ui = new UI(this); + this.keys = []; + this.enemies = []; + this.particles = []; + this.explosions = []; + this.enemyTimer = 0; + this.enemyInterval = 2000; + this.ammo = 20; + this.maxAmmo = 50; + this.ammoTimer = 0; + this.ammoInterval = 350; + this.gameOver = false; + this.score = 0; + this.winningScore = 80; + this.gameTime = 0; + this.timeLimit = 30000; + this.speed = 1; + this.debug = false; + + } + update(deltaTime) { + if (!this.gameOver) this.gameTime += deltaTime; + if (this.gameTime > this.timeLimit) this.gameOver = true; + this.background.update(); + this.background.layer4.update(); + this.player.update(deltaTime); + if (this.ammoTimer > this.ammoInterval) { + if (this.ammo < this.maxAmmo) this.ammo++; + this.ammoTimer = 0; + } else { + this.ammoTimer += deltaTime; + } + this.particles.forEach(particle => particle.update()); + this.particles = this.particles.filter(particle => !particle.markedForDeletion); + this.explosions.forEach(explosion => explosion.update(deltaTime)); + this.explosions = this.explosions.filter(explosion => !explosion.markedForDeletion); + this.enemies.forEach(enemy => { + enemy.update(); + if (this.checkCollision(this.player, enemy)) { + enemy.markedForDeletion = true; + this.addExplosion(enemy); + for (let i = 0; i < enemy.score; i++) { + this.particles.push(new Particle(this, enemy.x + enemy.width * 0.5, enemy.y + enemy.height * 0.5)); + } + if (enemy.type === 'lucky') this.player.enterPowerUp(); + else if (!this.gameOver) this.score--; + } + this.player.projectiles.forEach(projectile => { + if (this.checkCollision(projectile, enemy)) { + enemy.lives--; + projectile.markedForDeletion = true; + this.particles.push(new Particle(this, enemy.x + enemy.width * 0.5, enemy.y + enemy.height * 0.5)); + if (enemy.lives <= 0) { + for (let i = 0; i < enemy.score; i++) { + this.particles.push(new Particle(this, enemy.x + enemy.width * 0.5, enemy.y + enemy.height * 0.5)); + } + enemy.markedForDeletion = true; + this.addExplosion(enemy); + if (enemy.type === 'hive') { + for (let i = 0; i < 5; i++) { + this.enemies.push(new Drone(this, enemy.x + Math.random() * enemy.width, + enemy.y + Math.random() * enemy.height + 0.5)); + } + } + if (!this.gameOver) this.score += enemy.score; + /*if (this.score > this.winningScore) this.gameOver = true;*/ + } + } + }); + }); + this.enemies = this.enemies.filter(enemy => !enemy.markedForDeletion); + if (this.enemyTimer > this.enemyInterval && !this.gameOver) { + this.addEnemy(); + this.enemyTimer = 0; + } else { + this.enemyTimer += deltaTime; + } + } + draw(context) { + this.background.draw(context); + this.ui.draw(context); + this.player.draw(context); + this.particles.forEach(particle => particle.draw(context)); + this.enemies.forEach(enemy => { + enemy.draw(context); + }); + this.explosions.forEach(explosion => { + explosion.draw(context); + }); + this.background.layer4.draw(context); + } + addEnemy() { + const randomize = Math.random(); + if (randomize < 0.3) this.enemies.push(new Angler1(this)); + else if (randomize < 0.6) this.enemies.push(new Angler2(this)); + else if (randomize < 0.7) this.enemies.push(new HiveWhale(this)); + else this.enemies.push(new LuckyFish(this)); + } + addExplosion(enemy) { + const randomize = Math.random(); + if (randomize < 0.5) { + this.explosions.push(new SmokeExplosion(this, enemy.x + enemy.width * 0.5, enemy.y + enemy.height * 0.5)); + } + else { + this.explosions.push(new FireExplosion(this, enemy.x + enemy.width * 0.5, enemy.y + enemy.height * 0.5)); + } + } + checkCollision(rect1, rect2) { + return (rect1.x < rect2.x + rect2.width && + rect1.x + rect1.width > rect2.x && + rect1.y < rect2.y + rect2.height && + rect1.height + rect1.y > rect2.y) + } + + } + + const game = new Game(canvas.width, canvas.height); + let lastTime = 0; + //animation loop + function animate(timeStamp) { + const deltaTime = timeStamp - lastTime; + console.log(deltaTime); + lastTime = timeStamp; + ctx.clearRect(0, 0, canvas.width, canvas.height); + game.draw(ctx); + game.update(deltaTime); + requestAnimationFrame(animate); + } + animate(0); +}); + diff --git a/Games/Alien_Invasion/style.css b/Games/Alien_Invasion/style.css new file mode 100644 index 0000000000..268a5f3b93 --- /dev/null +++ b/Games/Alien_Invasion/style.css @@ -0,0 +1,34 @@ +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +#canvas1 { + border: 5px solid black; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + background: #4d79bc; + max-width: 100%; + max-height: 100%; + font-family: 'Bangers', cursive; +} + +#layer1, +#layer2, +#layer3, +#layer4, +#player, +#angler1, +#angler2, +#lucky, +#projectile, +#gears, +#hivewhale, +#drone, +#smokeExplosion, +#fireExplosion { + display: none; +} \ No newline at end of file diff --git a/Games/Car_Racing_Game/README.md b/Games/Car_Racing_Game/README.md new file mode 100644 index 0000000000..8843bf7fd4 --- /dev/null +++ b/Games/Car_Racing_Game/README.md @@ -0,0 +1,74 @@ +# **Car Racing Game** +--- + +
+ +## **Description 📃** + +Car Racing Game is an exhilarating 2D racing game where players control a red car and compete against a computer-controlled green car. The game features multiple levels with increasing difficulty, realistic collision detection, and smooth controls. + + +## **Functionalities 🎮** + +- **Player and Computer Cars**: Control the red car and race against the green computer car. +- **Levels and Progression**: Complete levels by reaching the finish line before the computer car. Each level offers more challenges and obstacles. +- **Collision Detection**: Realistic collision detection with track borders and other cars. +- **Speed Control**: Adjust the speed of your car using the arrow keys. +- **Direction Control**: Rotate your car left or right to navigate through the track. +- **Game Over and Reset**: The game ends if the player fails to beat the computer car. Reset the game to try again. + +
+ +## **How to Play? 🕹️** + +1. **Start the Game**: Launch the game to begin. + +### Controls: + +- Use the **left** and **right arrow keys** to rotate the car. +- Use the **up arrow key** to accelerate forward. +- Use the **down arrow key** to slow down or reverse. + +2. **Navigate the Track**: Avoid collisions with track borders and other cars. +3. **Complete Levels**: Reach the finish line before the computer car to advance to the next level. +4. **Game Over**: If the computer car reaches the finish line first, it's game over. Reset the game to try again. + +
+ +## **Installation and Running the Game 🚀** +### Prerequisites + +- Python 3.x +- Pygame library + +### Steps + +1. **Clone the repository**: + ```sh + git clone https://github.com/shellyverma/game.git + ``` + +2. **Navigate to the game directory**: + ```sh + cd game + ``` + +3. **Install the dependencies** (assuming you have Python and pip installed): + ```sh + pip install pygame + ``` + +4. **Run the game**: + ```sh + python main.py + ``` + +
+ +## **Screenshots 📸** + + +![Game Screenshot](https://github.com/shellyverma/game/blob/ea66450ffb4afb9fb849ea685e39a131d5da8849/Screenshot%20.png?raw=true) + +--- + diff --git a/Games/Car_Racing_Game/__pycache__/utils.cpython-312.pyc b/Games/Car_Racing_Game/__pycache__/utils.cpython-312.pyc new file mode 100644 index 0000000000..c9a648cf14 Binary files /dev/null and b/Games/Car_Racing_Game/__pycache__/utils.cpython-312.pyc differ diff --git a/Games/Car_Racing_Game/git b/Games/Car_Racing_Game/git new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Games/Car_Racing_Game/imgs/finish.png b/Games/Car_Racing_Game/imgs/finish.png new file mode 100644 index 0000000000..9f78c56d0c Binary files /dev/null and b/Games/Car_Racing_Game/imgs/finish.png differ diff --git a/Games/Car_Racing_Game/imgs/grass.png b/Games/Car_Racing_Game/imgs/grass.png new file mode 100644 index 0000000000..dbacd680f0 Binary files /dev/null and b/Games/Car_Racing_Game/imgs/grass.png differ diff --git a/Games/Car_Racing_Game/imgs/green-car.png b/Games/Car_Racing_Game/imgs/green-car.png new file mode 100644 index 0000000000..053ec9949c Binary files /dev/null and b/Games/Car_Racing_Game/imgs/green-car.png differ diff --git a/Games/Car_Racing_Game/imgs/red-car.png b/Games/Car_Racing_Game/imgs/red-car.png new file mode 100644 index 0000000000..49441823ca Binary files /dev/null and b/Games/Car_Racing_Game/imgs/red-car.png differ diff --git a/Games/Car_Racing_Game/imgs/track-border.png b/Games/Car_Racing_Game/imgs/track-border.png new file mode 100644 index 0000000000..a5d9a46a57 Binary files /dev/null and b/Games/Car_Racing_Game/imgs/track-border.png differ diff --git a/Games/Car_Racing_Game/imgs/track.png b/Games/Car_Racing_Game/imgs/track.png new file mode 100644 index 0000000000..bd6954dace Binary files /dev/null and b/Games/Car_Racing_Game/imgs/track.png differ diff --git a/Games/Car_Racing_Game/main.py b/Games/Car_Racing_Game/main.py new file mode 100644 index 0000000000..756c470b6b --- /dev/null +++ b/Games/Car_Racing_Game/main.py @@ -0,0 +1,328 @@ +import pygame +import time +import math +from utils import scale_image, blit_rotate_center, blit_text_center +import os + +# Initialize Pygame font module +pygame.font.init() + +# Set the base directory to the GameZone/Games/Car_Racing_Game directory +base_dir = os.path.join(os.getcwd(), "Games", "Car_Racing_Game") +imgs_dir = os.path.join(base_dir, "imgs") + +# Debug prints to ensure directories are correct +print("Base directory:", base_dir) +print("Images directory:", imgs_dir) +if os.path.exists(imgs_dir): + print("Files in imgs directory:", os.listdir(imgs_dir)) +else: + print("imgs directory not found") + +# Attempt to load the images with error handling +try: + GRASS = scale_image(pygame.image.load(os.path.join(imgs_dir, "grass.png")), 2.5) + print("grass.png loaded successfully") +except FileNotFoundError as e: + print("Error loading grass.png:", e) + +try: + TRACK = scale_image(pygame.image.load(os.path.join(imgs_dir, "track.png")), 0.9) + print("track.png loaded successfully") +except FileNotFoundError as e: + print("Error loading track.png:", e) + +try: + TRACK_BORDER = scale_image(pygame.image.load(os.path.join(imgs_dir, "track-border.png")), 0.9) + TRACK_BORDER_MASK = pygame.mask.from_surface(TRACK_BORDER) + print("track-border.png loaded successfully") +except FileNotFoundError as e: + print("Error loading track-border.png:", e) + +try: + FINISH = pygame.image.load(os.path.join(imgs_dir, "finish.png")) + FINISH_MASK = pygame.mask.from_surface(FINISH) + FINISH_POSITION = (130, 250) + print("finish.png loaded successfully") +except FileNotFoundError as e: + print("Error loading finish.png:", e) + +try: + RED_CAR = scale_image(pygame.image.load(os.path.join(imgs_dir, "red-car.png")), 0.55) + print("red-car.png loaded successfully") +except FileNotFoundError as e: + print("Error loading red-car.png:", e) + +try: + GREEN_CAR = scale_image(pygame.image.load(os.path.join(imgs_dir, "green-car.png")), 0.55) + print("green-car.png loaded successfully") +except FileNotFoundError as e: + print("Error loading green-car.png:", e) + +# Ensure TRACK is loaded before setting up the game window +if 'TRACK' in locals(): + # Set up the game window dimensions + WIDTH, HEIGHT = TRACK.get_width(), TRACK.get_height() + WIN = pygame.display.set_mode((WIDTH, HEIGHT)) + pygame.display.set_caption("Racing Game!") + + # Set up the main font for text display + MAIN_FONT = pygame.font.SysFont("comicsans", 44) + + # Game settings + FPS = 60 + PATH = [(175, 119), (110, 70), (56, 133), (70, 481), (318, 731), (404, 680), (418, 521), (507, 475), (600, 551), (613, 715), (736, 713), + (734, 399), (611, 357), (409, 343), (433, 257), (697, 258), (738, 123), (581, 71), (303, 78), (275, 377), (176, 388), (178, 260)] + + # Class to manage game information such as levels and time + class GameInfo: + LEVELS = 10 + + def __init__(self, level=1): + self.level = level + self.started = False + self.level_start_time = 0 + + def next_level(self): + self.level += 1 + self.started = False + + def reset(self): + self.level = 1 + self.started = False + self.level_start_time = 0 + + def game_finished(self): + return self.level > self.LEVELS + + def start_level(self): + self.started = True + self.level_start_time = time.time() + + def get_level_time(self): + if not self.started: + return 0 + return round(time.time() - self.level_start_time) + + # Abstract car class with common functionalities for player and computer cars + class AbstractCar: + def __init__(self, max_vel, rotation_vel): + self.img = self.IMG + self.max_vel = max_vel + self.vel = 0 + self.rotation_vel = rotation_vel + self.angle = 0 + self.x, self.y = self.START_POS + self.acceleration = 0.1 + + def rotate(self, left=False, right=False): + if left: + self.angle += self.rotation_vel + elif right: + self.angle -= self.rotation_vel + + def draw(self, win): + blit_rotate_center(win, self.img, (self.x, self.y), self.angle) + + def move_forward(self): + self.vel = min(self.vel + self.acceleration, self.max_vel) + self.move() + + def move_backward(self): + self.vel = max(self.vel - self.acceleration, -self.max_vel/2) + self.move() + + def move(self): + radians = math.radians(self.angle) + vertical = math.cos(radians) * self.vel + horizontal = math.sin(radians) * self.vel + + self.y -= vertical + self.x -= horizontal + + def collide(self, mask, x=0, y=0): + car_mask = pygame.mask.from_surface(self.img) + offset = (int(self.x - x), int(self.y - y)) + poi = mask.overlap(car_mask, offset) + return poi + + def reset(self): + self.x, self.y = self.START_POS + self.angle = 0 + self.vel = 0 + + # Player car class with specific functionalities + class PlayerCar(AbstractCar): + IMG = RED_CAR + START_POS = (180, 200) + + def reduce_speed(self): + self.vel = max(self.vel - self.acceleration / 2, 0) + self.move() + + def bounce(self): + self.vel = -self.vel + self.move() + + # Computer car class with AI functionalities + class ComputerCar(AbstractCar): + IMG = GREEN_CAR + START_POS = (150, 200) + + def __init__(self, max_vel, rotation_vel, path=[]): + super().__init__(max_vel, rotation_vel) + self.path = path + self.current_point = 0 + self.vel = max_vel + + def draw_points(self, win): + for point in self.path: + pygame.draw.circle(win, (255, 0, 0), point, 5) + + def draw(self, win): + super().draw(win) + # self.draw_points(win) + + def calculate_angle(self): + target_x, target_y = self.path[self.current_point] + x_diff = target_x - self.x + y_diff = target_y - self.y + + if y_diff == 0: + desired_radian_angle = math.pi / 2 + else: + desired_radian_angle = math.atan(x_diff / y_diff) + + if target_y > self.y: + desired_radian_angle += math.pi + + difference_in_angle = self.angle - math.degrees(desired_radian_angle) + if difference_in_angle >= 180: + difference_in_angle -= 360 + + if difference_in_angle > 0: + self.angle -= min(self.rotation_vel, abs(difference_in_angle)) + else: + self.angle += min(self.rotation_vel, abs(difference_in_angle)) + + def update_path_point(self): + target = self.path[self.current_point] + rect = pygame.Rect( + self.x, self.y, self.img.get_width(), self.img.get_height()) + if rect.collidepoint(*target): + self.current_point += 1 + + def move(self): + if self.current_point >= len(self.path): + return + + self.calculate_angle() + self.update_path_point() + super().move() + + def next_level(self, level): + self.reset() + self.vel = self.max_vel + (level - 1) * 0.2 + self.current_point = 0 + + # Function to draw the game elements on the screen + def draw(win, images, player_car, computer_car, game_info): + for img, pos in images: + win.blit(img, pos) + + level_text = MAIN_FONT.render( + f"Level {game_info.level}", 1, (255, 255, 255)) + win.blit(level_text, (10, HEIGHT - level_text.get_height() - 70)) + + time_text = MAIN_FONT.render( + f"Time: {game_info.get_level_time()}s", 1, (255, 255, 255)) + win.blit(time_text, (10, HEIGHT - time_text.get_height() - 40)) + + vel_text = MAIN_FONT.render( + f"Vel: {round(player_car.vel, 1)}px/s", 1, (255, 255, 255)) + win.blit(vel_text, (10, HEIGHT - vel_text.get_height() - 10)) + + player_car.draw(win) + computer_car.draw(win) + pygame.display.update() + + # Function to handle player car movement + def move_player(player_car): + keys = pygame.key.get_pressed() + moved = False + + if keys[pygame.K_LEFT]: + player_car.rotate(left=True) + if keys[pygame.K_RIGHT]: + player_car.rotate(right=True) + if keys[pygame.K_UP]: + moved = True + player_car.move_forward() + if keys[pygame.K_DOWN]: + moved = True + player_car.move_backward() + + if not moved: + player_car.reduce_speed() + + # Main game loop + run = True + clock = pygame.time.Clock() + images = [(GRASS, (0, 0)), (TRACK, (0, 0)), + (FINISH, FINISH_POSITION), (TRACK_BORDER, (0, 0))] + player_car = PlayerCar(4, 4) + computer_car = ComputerCar(2, 4, PATH) + game_info = GameInfo() + + while run: + clock.tick(FPS) + + draw(WIN, images, player_car, computer_car, game_info) + + # Wait for the player to start the level + while not game_info.started: + blit_text_center( + WIN, MAIN_FONT, f"Press any key to start level {game_info.level}!") + pygame.display.update() + for event in pygame.event.get(): + if event.type == pygame.QUIT: + run = False + break + if event.type == pygame.KEYDOWN: + game_info.start_level() + + for event in pygame.event.get(): + if event.type == pygame.QUIT: + run = False + break + + move_player(player_car) + computer_car.move() + + # Check for collisions with the track border + if player_car.collide(TRACK_BORDER_MASK) != None: + player_car.bounce() + + # Check for collisions with the finish line + finish_poi_collide = player_car.collide( + FINISH_MASK, *FINISH_POSITION) + if finish_poi_collide != None: + if finish_poi_collide[1] == 0: + player_car.bounce() + else: + game_info.next_level() + player_car.reset() + computer_car.next_level(game_info.level) + + # Check if the game is finished + if game_info.game_finished(): + blit_text_center(WIN, MAIN_FONT, "You won the game!") + pygame.display.update() + pygame.time.wait(5000) + game_info.reset() + player_car.reset() + computer_car.reset() + + pygame.quit() +else: + print("TRACK not loaded. Exiting.") diff --git a/Games/Car_Racing_Game/utils.py b/Games/Car_Racing_Game/utils.py new file mode 100644 index 0000000000..e3aa50d2f2 --- /dev/null +++ b/Games/Car_Racing_Game/utils.py @@ -0,0 +1,50 @@ +import pygame + +def scale_image(img, factor): + """ + Scale an image by a given factor. + + Parameters: + img (pygame.Surface): The image to be scaled. + factor (float): The scaling factor. + + Returns: + pygame.Surface: The scaled image. + """ + size = round(img.get_width() * factor), round(img.get_height() * factor) + return pygame.transform.scale(img, size) + +def blit_rotate_center(win, image, top_left, angle): + """ + Draw an image rotated around its center. + + Parameters: + win (pygame.Surface): The surface to draw the image on. + image (pygame.Surface): The image to be rotated and drawn. + top_left (tuple): The top-left coordinates of the image. + angle (float): The angle to rotate the image. + """ + # Rotate the image by the specified angle + rotated_image = pygame.transform.rotate(image, angle) + # Get the new rectangle of the rotated image, centered on the original image's center + new_rect = rotated_image.get_rect(center=image.get_rect(topleft=top_left).center) + # Draw the rotated image on the window + win.blit(rotated_image, new_rect.topleft) + +def blit_text_center(win, font, text): + """ + Draw text centered on the window. + + Parameters: + win (pygame.Surface): The surface to draw the text on. + font (pygame.font.Font): The font used to render the text. + text (str): The text to be rendered and drawn. + """ + # Render the text with the specified font + render = font.render(text, 1, (200, 200, 200)) + # Calculate the position to center the text on the window + position = (win.get_width() / 2 - render.get_width() / 2, + win.get_height() / 2 - render.get_height() / 2) + # Draw the text on the window + win.blit(render, position) + diff --git a/Games/Carrom/carrom.html b/Games/Carrom/carrom.html index 91ee9e1e85..3b1fb382aa 100644 --- a/Games/Carrom/carrom.html +++ b/Games/Carrom/carrom.html @@ -14,7 +14,7 @@
-
+

Player 1

Score : 0

@@ -28,12 +28,13 @@

Player 1

Your browser does not support the HTML5 canvas tag. Your browser does not support the HTML5 canvas tag.
-
+

Player 2

Score : 0

-

Mouse Positions :

+

Mouse Positions :

+
+ + + diff --git a/Games/Catch_The_Falling_Object/script.js b/Games/Catch_The_Falling_Object/script.js new file mode 100644 index 0000000000..fa3530c4c7 --- /dev/null +++ b/Games/Catch_The_Falling_Object/script.js @@ -0,0 +1,113 @@ +const basket = document.getElementById('basket'); +const gameContainer = document.getElementById('game-container'); +const scoreDisplay = document.getElementById('score'); +const livesContainer = document.getElementById('lives'); +const gameOverDisplay = document.getElementById('game-over'); +const finalScoreDisplay = document.getElementById('final-score'); + +let score = 0; +let lives = 5; +let fallingObjectInterval; +let gameOver = false; + +document.addEventListener('mousemove', (event) => { + if (!gameOver) { + let containerRect = gameContainer.getBoundingClientRect(); + let basketWidth = basket.offsetWidth; + let x = event.clientX - containerRect.left - basketWidth / 2; + if (x < 0) x = 0; + if (x > containerRect.width - basketWidth) x = containerRect.width - basketWidth; + basket.style.left = x + 'px'; + } +}); + +function createFallingObject() { + if (gameOver) return; + + const fallingObject = document.createElement('div'); + fallingObject.classList.add('falling-object'); + fallingObject.style.left = Math.random() * (gameContainer.offsetWidth - 30) + 'px'; + gameContainer.appendChild(fallingObject); + + let fallingInterval = setInterval(() => { + if (gameOver) { + clearInterval(fallingInterval); + return; + } + + let top = parseInt(fallingObject.style.top || 0); + if (top > gameContainer.offsetHeight - 40) { + clearInterval(fallingInterval); + fallingObject.remove(); + loseLife(); + } else { + fallingObject.style.top = top + 5 + 'px'; + if (isCaught(fallingObject)) { + clearInterval(fallingInterval); + fallingObject.remove(); + score++; + scoreDisplay.innerText = 'Score: ' + score; + } + } + }, 20); +} + +function isCaught(fallingObject) { + let objectRect = fallingObject.getBoundingClientRect(); + let basketRect = basket.getBoundingClientRect(); + return ( + objectRect.right >= basketRect.left && + objectRect.left <= basketRect.right && + objectRect.bottom >= basketRect.top && + objectRect.top <= basketRect.bottom + ); +} + +function loseLife() { + if (lives > 0) { + lives--; + updateLivesDisplay(); + } + if (lives <= 0) { + endGame(); + } +} + +function updateLivesDisplay() { + livesContainer.innerText = 'Lives: '; + for (let i = 1; i <= 5; i++) { + const heart = document.createElement('span'); + heart.classList.add('heart'); + if (i > lives) { + heart.style.color = 'transparent'; + } + heart.innerText = '❤'; + livesContainer.appendChild(heart); + } +} + +function endGame() { + gameOver = true; + clearInterval(fallingObjectInterval); + finalScoreDisplay.innerText = 'Final Score: ' + score; // Display total score + gameOverDisplay.innerHTML = 'Game Over
' + finalScoreDisplay.innerHTML + '
'; // Update game over display with total score and restart button + gameOverDisplay.style.display = 'block'; +} + +function startGame() { + gameOver = false; + score = 0; + lives = 5; + scoreDisplay.innerText = 'Score: ' + score; + updateLivesDisplay(); + gameOverDisplay.style.display = 'none'; + + // Remove existing falling objects + document.querySelectorAll('.falling-object').forEach(obj => obj.remove()); + + // Start creating falling objects again + fallingObjectInterval = setInterval(createFallingObject, 1000); +} + +// Initialize the game +startGame(); diff --git a/Games/Catch_The_Falling_Object/style.css b/Games/Catch_The_Falling_Object/style.css new file mode 100644 index 0000000000..c373a1d2a6 --- /dev/null +++ b/Games/Catch_The_Falling_Object/style.css @@ -0,0 +1,80 @@ +body { + margin: 0; + padding: 0; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + background-image: linear-gradient(#e4f37a, #8ded9a); + color: white; + font-family: Arial, sans-serif; +} + +.game-container { + position: relative; + width: 700px; + height: 800px; + background-color: #2e2c2c81; + border: 2px solid #3333339f; + overflow: hidden; +} + +.basket { + position: absolute; + bottom: 10px; + width: 100px; + height: 30px; + background-color: #33f209; + border-radius: 10px; +} + +.falling-object { + position: absolute; + width: 30px; + height: 30px; + background-color: #fff704; + border-radius: 50%; +} + +.score, +.lives { + position: absolute; + top: 40px; + font-size: 24px; +} + +.heart { + font-size: 24px; + color: rgb(136, 3, 3); + margin-right: 5px; +} + +.score { + left: 10px; +} + +.lives { + right: 10px; +} + +.game-over { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + background-color: rgba(0, 0, 0, 0.699); + color: rgb(206, 241, 241); + padding: 25px; + border-radius: 20px; + text-align: center; + display: none; +} + +button { + border-radius: 7px; + font-size: medium; + border: 2px solid black; + background-color: #cbe7ff; + margin: 7px 7px; + padding: 4px 22px; +} diff --git a/Games/Color_Swap/README.md b/Games/Color_Swap/README.md new file mode 100644 index 0000000000..5e2c2618cf --- /dev/null +++ b/Games/Color_Swap/README.md @@ -0,0 +1,48 @@ +# **Game_Name** +Color Swap + +--- + +
+ +## **Description 📃** +"Color Swap" is a simple yet addictive browser-based game developed using HTML, CSS, and JavaScript. The game revolves around the player controlling a character or object that must pass through obstacles matching its color. The color of the character changes randomly, requiring quick reflexes and strategic thinking. + +## **Functionalities 🎮** + +Simple Controls: + +- The player controls the character using the arrow keys or touch gestures on mobile devices. +0 The character moves left, right, up, or down to navigate through a series of color-coded obstacles. + +Color Matching: + +- The character changes color periodically or when passing through special zones. +- Players must guide the character through obstacles that match its current color to score points. + +Increasing Difficulty: + +- As the game progresses, the speed and frequency of color changes increase. +- More complex patterns and additional obstacles are introduced to challenge the player. + +
+ +## **How to play? 🕹️** + +- Start the Game: Click the "Start" button to begin the game. + +- Control the Character: Use the arrow keys on your keyboard to move the character around the screen. + +- Match Colors: Guide the character to collide with obstacles of the same color to score points. + +- Avoid Mismatches: Avoid obstacles of different colors, as colliding with them will end the game. + +- Score Points: Each successful color match earns you points. Your score is displayed on the screen. + +- Game Over: The game ends if you hit an obstacle of a different color. A popup will display your final score, and the game will restart automatically after a few seconds. + +## **Screenshots 📸** + +![image](https://github.com/aditya-bhaumik/GameZone/assets/92214013/f4ed96f6-57e9-4d02-86dd-e086c32b6838) + + diff --git a/Games/Color_Swap/index.html b/Games/Color_Swap/index.html new file mode 100644 index 0000000000..3d78f88730 --- /dev/null +++ b/Games/Color_Swap/index.html @@ -0,0 +1,22 @@ + + + + + + Color Swap + + + +
+ +
Score: 0
+
Game Over! You scored points!
+
+ + + + + + + + diff --git a/Games/Color_Swap/script.js b/Games/Color_Swap/script.js new file mode 100644 index 0000000000..cdfb02b194 --- /dev/null +++ b/Games/Color_Swap/script.js @@ -0,0 +1,140 @@ +const canvas = document.getElementById('gameCanvas'); +const ctx = canvas.getContext('2d'); +const scoreDisplay = document.getElementById('score'); +const gameOverMessage = document.getElementById('gameOverMessage'); +const finalScore = document.getElementById('finalScore'); +const startButton = document.getElementById('startButton'); + +const canvasWidth = canvas.width; +const canvasHeight = canvas.height; +const characterSize = 20; +const obstacleWidth = 60; +const obstacleHeight = 20; +const colors = ['red', 'blue', 'green', 'yellow']; + +let characterX = canvasWidth / 2 - characterSize / 2; +let characterY = canvasHeight - characterSize - 10; +let characterColor = colors[Math.floor(Math.random() * colors.length)]; +let obstacles = []; +let score = 0; +let gameInterval, obstacleInterval; +let gameActive = false; + +document.addEventListener('keydown', moveCharacter); + +function moveCharacter(event) { + if (!gameActive) return; + + switch (event.key) { + case 'ArrowLeft': + characterX -= 20; + if (characterX < 0) characterX = 0; + break; + case 'ArrowRight': + characterX += 20; + if (characterX > canvasWidth - characterSize) characterX = canvasWidth - characterSize; + break; + case 'ArrowUp': + characterY -= 20; + if (characterY < 0) characterY = 0; + break; + case 'ArrowDown': + characterY += 20; + if (characterY > canvasHeight - characterSize) characterY = canvasHeight - characterSize; + break; + } +} + +function createObstacle() { + const x = Math.random() * (canvasWidth - obstacleWidth); + const y = -obstacleHeight; + const color = colors[Math.floor(Math.random() * colors.length)]; + obstacles.push({ x, y, color }); +} + +function updateGame() { + if (!gameActive) return; + + ctx.clearRect(0, 0, canvasWidth, canvasHeight); + + // Draw character + ctx.fillStyle = characterColor; + ctx.fillRect(characterX, characterY, characterSize, characterSize); + + // Draw and move obstacles + for (let i = 0; i < obstacles.length; i++) { + const obstacle = obstacles[i]; + obstacle.y += 2; + + if (obstacle.y > canvasHeight) { + obstacles.splice(i, 1); + i--; + continue; + } + + ctx.fillStyle = obstacle.color; + ctx.fillRect(obstacle.x, obstacle.y, obstacleWidth, obstacleHeight); + + // Check collision + if ( + characterX < obstacle.x + obstacleWidth && + characterX + characterSize > obstacle.x && + characterY < obstacle.y + obstacleHeight && + characterY + characterSize > obstacle.y + ) { + if (characterColor === obstacle.color) { + score++; + scoreDisplay.innerText = `Score: ${score}`; + obstacles.splice(i, 1); + i--; + } else { + gameOver(); + return; + } + } + } + + // Change character color randomly + if (Math.random() < 0.01) { + characterColor = colors[Math.floor(Math.random() * colors.length)]; + } +} + +function startGame() { + score = 0; + characterX = canvasWidth / 2 - characterSize / 2; + characterY = canvasHeight - characterSize - 10; + characterColor = colors[Math.floor(Math.random() * colors.length)]; + obstacles = []; + scoreDisplay.innerText = `Score: ${score}`; + gameActive = true; + gameOverMessage.style.display = 'none'; + + clearInterval(gameInterval); + clearInterval(obstacleInterval); + + gameInterval = setInterval(updateGame, 20); + obstacleInterval = setInterval(createObstacle, 1000); +} + +function gameOver() { + gameActive = false; + clearInterval(gameInterval); + clearInterval(obstacleInterval); + + finalScore.innerText = score; + gameOverMessage.style.display = 'block'; + + setTimeout(() => { + gameOverMessage.style.display = 'none'; + startGame(); + }, 3000); +} + +startButton.addEventListener('click', () => { + startButton.style.display = 'none'; + startGame(); +}); + + + diff --git a/Games/Color_Swap/styles.css b/Games/Color_Swap/styles.css new file mode 100644 index 0000000000..a50538b5bf --- /dev/null +++ b/Games/Color_Swap/styles.css @@ -0,0 +1,76 @@ +body { + margin: 0; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + height: 100vh; + background-color: #000; + font-family: 'Arial', sans-serif; + color: #0f0; +} + +#gameContainer { + position: relative; + width: 400px; + height: 600px; + border: 2px solid #0f0; + border-radius: 15px; + background-color: #111; + box-shadow: 0px 0px 20px #0f0; + display: flex; + justify-content: center; + align-items: center; +} + +#gameCanvas { + display: block; + border-radius: 15px 15px 0 0; + background-color: #222; + box-shadow: inset 0px 0px 10px #0f0; +} + +#score { + position: absolute; + top: 10px; + left: 10px; + font-size: 20px; + color: #0f0; + text-shadow: 0px 0px 5px #0f0; +} + +#startButton { + margin-top: 20px; + padding: 10px 20px; + background-color: #111; + color: #0f0; + border: 2px solid #0f0; + border-radius: 5px; + cursor: pointer; + font-size: 16px; + box-shadow: 0px 0px 10px #0f0; +} + +#startButton:hover { + background-color: #0f0; + color: #111; + box-shadow: 0px 0px 20px #0f0; +} + +#gameOverMessage { + display: none; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + padding: 20px; + background-color: #111; + color: #0f0; + border: 2px solid #0f0; + border-radius: 10px; + font-size: 20px; + text-align: center; + box-shadow: 0px 0px 20px #0f0; + z-index: 10; +} + diff --git a/Games/Cosmic_Blast/README.md b/Games/Cosmic_Blast/README.md index 37a6fe6967..3d36767354 100644 --- a/Games/Cosmic_Blast/README.md +++ b/Games/Cosmic_Blast/README.md @@ -34,4 +34,4 @@ Cosmic Blast is an exciting and fast-paced arcade game where the fate of Earth l ---- \ No newline at end of file +--- diff --git a/Games/Cosmic_Blast/index.html b/Games/Cosmic_Blast/index.html index e0bc125f36..5da5ec0438 100644 --- a/Games/Cosmic_Blast/index.html +++ b/Games/Cosmic_Blast/index.html @@ -46,6 +46,6 @@

Earth has been destroyed by the asteroids

- + \ No newline at end of file diff --git a/Games/Cosmic_Blast/script.js b/Games/Cosmic_Blast/script.js index f995a772a0..2b7bf14fe8 100644 --- a/Games/Cosmic_Blast/script.js +++ b/Games/Cosmic_Blast/script.js @@ -12,7 +12,7 @@ document.addEventListener("DOMContentLoaded", function() { const finalScore = document.getElementById("final-score"); var explosionSound = new Audio(); - explosionSound.src = "./assets/explode.mp3"; + explosionSound.src = "assets/explode.mp3"; explosionSound.preload = "auto"; let health = 100; @@ -75,7 +75,7 @@ document.addEventListener("DOMContentLoaded", function() { const asteroid = document.createElement("div"); asteroid.className = "asteroid"; const size = Math.floor(Math.random() * 3) + 1; // Random size between 1 and 3 - asteroid.style.backgroundImage = `url('/assets/asteroid-${size}.png')`; // Use different asteroid images + asteroid.style.backgroundImage = `url('assets/asteroid-${size}.png')`; // Use different asteroid images asteroid.setAttribute("size", size); // Store size as an attribute // Set initial position and angle @@ -169,6 +169,6 @@ document.addEventListener("DOMContentLoaded", function() { if (health <= 0) { endGame(); } - earth.style.backgroundImage = "url('/assets/earth.png')"; + earth.style.backgroundImage = "url('assets/earth.png')"; } }); \ No newline at end of file diff --git a/Games/Cosmic_Blast/style.css b/Games/Cosmic_Blast/style.css index 645b0791eb..34d46882cb 100644 --- a/Games/Cosmic_Blast/style.css +++ b/Games/Cosmic_Blast/style.css @@ -1,7 +1,7 @@ body{ margin: 0; font-family: Arial, sans-serif; - background-image: url("/assets/background.jpg"); + background-image: url("assets/background.jpg"); color: #ffffff; } @@ -84,7 +84,7 @@ body{ position: relative; width: 100vw; height: 100vh; - background-image: url("/assets/background.jpg"); + background-image: url("assets/background.jpg"); cursor: url('https://raw.githubusercontent.com/coob113/fancy-cursors/master/target1.png') 64 64, auto !important; } @@ -145,7 +145,7 @@ body{ left: 50%; width: 100%; height: 100%; - background-image: url("./assets/background.jpg"); + background-image: url("assets/background.jpg"); z-index: 10; /* Ensure it's above other elements */ } @@ -154,7 +154,7 @@ body{ top: 50%; left: 50%; transform: translate(-50%, -50%); - background-image: url("./assets/ba ckground.jpg"); + background-image: url("assets/background.jpg"); padding: 20px; border-radius: 5px; text-align: center; diff --git a/Games/Cross_The_River_Game/README.md b/Games/Cross_The_River_Game/README.md new file mode 100644 index 0000000000..27744e9534 --- /dev/null +++ b/Games/Cross_The_River_Game/README.md @@ -0,0 +1,17 @@ +

Cross_the_river_game

+ +## **Description 📃* +

The farmer is the only one who can pilot the boat. The boat only carries two at a time. The goat can never be left alone with the cabbage, or it will devour it. The wolf also cannot be left alone with the goat, or it will eat it too. Can you cross them all?

+ +## **How to play? 🕹️** +

Click on the farmer, wolf, goat or cabbage to enter or leave the boat. Click the boat to cross the river - it'll only do it if the farmer is inside. +

  • The boat can only carry the farmer and one other item at a time.
  • +
  • The farmer cannot leave the wolf alone with the goat.
  • +
  • The farmer cannot leave the goat alone with the cabbage.
  • + + +# Screenshots - +

    Beginning of the Game


    + Screenshot 2024-06-16 at 11 52 36 AM + Screenshot 2024-06-16 at 11 52 45 AM + Screenshot 2024-06-16 at 11 53 16 AM \ No newline at end of file diff --git a/Games/Cross_The_River_Game/css/main.css b/Games/Cross_The_River_Game/css/main.css new file mode 100644 index 0000000000..81dfa7fc8a --- /dev/null +++ b/Games/Cross_The_River_Game/css/main.css @@ -0,0 +1,8 @@ +html, body{ + margin: 0; + padding: 0; + } + canvas{ + display: block; + image-rendering: auto; + } \ No newline at end of file diff --git a/Games/Cross_The_River_Game/favicon.png b/Games/Cross_The_River_Game/favicon.png new file mode 100644 index 0000000000..5b4ddabae5 Binary files /dev/null and b/Games/Cross_The_River_Game/favicon.png differ diff --git a/Games/Cross_The_River_Game/img/boat.png b/Games/Cross_The_River_Game/img/boat.png new file mode 100644 index 0000000000..993cc55b15 Binary files /dev/null and b/Games/Cross_The_River_Game/img/boat.png differ diff --git a/Games/Cross_The_River_Game/img/cabbage.png b/Games/Cross_The_River_Game/img/cabbage.png new file mode 100644 index 0000000000..8ab22e3e36 Binary files /dev/null and b/Games/Cross_The_River_Game/img/cabbage.png differ diff --git a/Games/Cross_The_River_Game/img/farmer.png b/Games/Cross_The_River_Game/img/farmer.png new file mode 100644 index 0000000000..3ffaf58f15 Binary files /dev/null and b/Games/Cross_The_River_Game/img/farmer.png differ diff --git a/Games/Cross_The_River_Game/img/goat.png b/Games/Cross_The_River_Game/img/goat.png new file mode 100644 index 0000000000..b6e0a52367 Binary files /dev/null and b/Games/Cross_The_River_Game/img/goat.png differ diff --git a/Games/Cross_The_River_Game/img/wolf.png b/Games/Cross_The_River_Game/img/wolf.png new file mode 100644 index 0000000000..94e2d1f0dd Binary files /dev/null and b/Games/Cross_The_River_Game/img/wolf.png differ diff --git a/Games/Cross_The_River_Game/index.html b/Games/Cross_The_River_Game/index.html new file mode 100644 index 0000000000..b7f41feae6 --- /dev/null +++ b/Games/Cross_The_River_Game/index.html @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + Cross the River + + + + + + + + + + + + + \ No newline at end of file diff --git a/Games/Cross_The_River_Game/js/Boat.js b/Games/Cross_The_River_Game/js/Boat.js new file mode 100644 index 0000000000..d4f1b0b8fb --- /dev/null +++ b/Games/Cross_The_River_Game/js/Boat.js @@ -0,0 +1,59 @@ +class Boat { + constructor(img){ + this.pos = { + x: ((w4+w4/2) + this.side * w4) - 20, + y: h4-20, + } + this.passengers = []; + this.w = Math.max(w,h) * 0.2; + this.h = this.w<<1; + this.side = 0; + this.img = img; + } + + show(){ + this.pos.x = ((this.side+1) * w4) + (w4/4) - (this.w/4); + this.pos.y = (h - this.h)/2 + (this.h * 0.1); + /* + c.fillStyle = 'red'; + c.fillRect(this.pos.x, this.pos.y, this.w, this.h); + */ + c.drawImage(this.img,this.pos.x,this.pos.y,this.w,this.h); + } + + addPassenger(p){ + if( this.passengers.length < 2 && this.passengers.indexOf(p) == -1){ + p.side += this.side == 0 ? 1 : -1 ; + this.passengers.push( p ); + return true; + } + return false; + } + + removePassanger(p){ + let index = this.passengers.indexOf(p); + if(index >= 0){ + p.side += this.side == 0 ? -1 : 1; + this.passengers.splice(index, 1); + } + } + + action(){ + if( this.passengers.length > 0 ){ + let p = false; + for(let i = 0; i < this.passengers.length; i++){ + if( this.passengers[i].pilot ){ + p = true; + break; + } + } + if(p){ + this.side = ( this.side + 1 ) % 2; + for(let i = 0; i < this.passengers.length; i++){ + this.passengers[i].side = this.side+1; + } + } + } + } + +} \ No newline at end of file diff --git a/Games/Cross_The_River_Game/js/Passenger.js b/Games/Cross_The_River_Game/js/Passenger.js new file mode 100644 index 0000000000..53af3fe368 --- /dev/null +++ b/Games/Cross_The_River_Game/js/Passenger.js @@ -0,0 +1,42 @@ +class Passenger { + constructor(img, x, y, name, index = 0, pilot = false){ + this.pos = { + x: x, + y: y + }; + this.index = index; + let s = Math.max(w,h) * 0.1; + this.w = s; + this.h = s; + this.side = 0; + this.pilot = pilot; + this.name = name; + this.img = img; + } + + show(){ + this.pos.x = this.side * w4 + w4/4; + this.pos.y = this.index * this.h + (h-this.w*4)/2; + /* + c.fillStyle = 'black'; + c.fillRect(this.pos.x,this.pos.y,this.w,this.h); + */ + c.drawImage(this.img,this.pos.x,this.pos.y,this.w,this.h); + } + + action(){ + if( boat.side == 0 ){ + if( this.side == 0 ){ + boat.addPassenger(this); + }else{ + boat.removePassanger( this ); + } + }else{ + if( this.side == 2){ + boat.removePassanger( this ); + }else if( this.side == 3 ){ + boat.addPassenger( this ); + } + } + } +} \ No newline at end of file diff --git a/Games/Cross_The_River_Game/js/aux.js b/Games/Cross_The_River_Game/js/aux.js new file mode 100644 index 0000000000..df35ec0e6d --- /dev/null +++ b/Games/Cross_The_River_Game/js/aux.js @@ -0,0 +1,22 @@ +if('serviceWorker' in navigator) { + navigator.serviceWorker + .register('/bridge/sw.js', {scope: './'}) + .then(response => response) + .catch(reason => reason); + } + + let deferredPrompt; + const addBtn = document.createElement('button'); + + window.addEventListener('beforeinstallprompt', (e) => { + e.preventDefault(); + deferredPrompt = e; + addBtn.style.display = 'block'; + addBtn.addEventListener('click', (e) => { + addBtn.style.display = 'none'; + deferredPrompt.prompt(); + deferredPrompt.userChoice.then((choiceResult) => { + deferredPrompt = null; + }); + }); + }); \ No newline at end of file diff --git a/Games/Cross_The_River_Game/js/main.js b/Games/Cross_The_River_Game/js/main.js new file mode 100644 index 0000000000..cab51161ff --- /dev/null +++ b/Games/Cross_The_River_Game/js/main.js @@ -0,0 +1,165 @@ +alert("Select the objects in boat with farmer and press the boat to cross the game"); +let background, canvas, c, w, h, w2, h2, elements, boat, farmer, wolf, goat, cabbage, moves, textures, solution; + +function init(){ + let old = document.querySelector('canvas'); + if(old) + old.remove(); + + moves = 0; + solution = [1,3,0,3,0,4,0,4,3,0,3,2,0,2,0,3,0,3,1]; + + canvas = document.createElement('canvas'); + canvas.width = w = innerWidth; + canvas.height = h = innerHeight; + w4 = w/4; + h4 = h/4; + canvas.addEventListener('click', getElement ); + + c = canvas.getContext('2d'); + + document.body.appendChild(canvas); + + c.shadowColor = 'rgba(0,0,0,0.5)'; + c.shadowBlur = 50; + + background = c.createLinearGradient(0,0,w,0); + background.addColorStop(0,'green'); + background.addColorStop(0.2,'green'); + background.addColorStop(0.27,'#654321'); + background.addColorStop(0.3,'blue'); + background.addColorStop(0.5,'#00BFFF'); + background.addColorStop(0.7,'blue'); + background.addColorStop(0.73,'#654321'); + background.addColorStop(0.8,'green'); + background.addColorStop(1,'green'); + c.fillStyle = background; + + elements = []; + + farmer = new Passenger(textures['img/farmer.png'],w2,h2,'farmer',0,true); + + wolf = new Passenger(textures['img/wolf.png'],w2,h2,'wolf',1); + + goat = new Passenger(textures['img/goat.png'],w2,h2,'goat',2); + + cabbage = new Passenger(textures['img/cabbage.png'],w2,h2,'cabbage',3); + + boat = new Boat(textures['img/boat.png']); + + elements.push( boat ); + elements.push( farmer ); + elements.push( wolf ); + elements.push( goat ); + elements.push( cabbage ); + + /* hack to quick implement a solution's button */ + let solve = { + pos: { + x: w-150, + y: h-50 + }, + h: 30, + w: 130, + + show: function(){ + c.fillStyle = 'gray'; + c.fillRect(this.pos.x, this.pos.y, this.w, this.h); + c.fillStyle = 'black'; + c.font = '1.2rem Arial'; + let text = 'Solution'; + let m = c.measureText(text); + c.fillText(text, this.pos.x+m.width/2, this.pos.y+20); + }, + + action: function(){ + init(); + canvas.removeEventListener('click', getElement); + solveMe(); + } + }; + + elements.push( solve ); + + draw(); +} + +function solveMe(){ + if( solution.length > 0 ){ + elements[ solution.shift() ].action(); + draw(); + setTimeout( solveMe, 1000 ); + } +} + +function draw(){ + c.fillStyle = background; + c.fillRect(0,0,w,h); + for(let i = 0; i < elements.length; i++){ + elements[i].show(); + } + check(); +} + +function check(){ + if( farmer.side == 2 && (wolf.side == 0 && goat.side == 0) || + farmer.side == 1 && (wolf.side == 3 && goat.side == 3) || + farmer.side == 2 && (goat.side == 0 && cabbage.side == 0) || + farmer.side == 1 && (goat.side == 3 && cabbage.side == 3 ) + ){ + gameOver('You Lose'); + } + if( farmer.side == 3 && wolf.side == 3 && goat.side == 3 && cabbage.side == 3){ + gameOver('You Win'); + } +} + +let getElement = function(e){ + let x = e.offsetX, y = e.offsetY; + let found = null; + for(let i = 0; i < elements.length; i++){ + let e = elements[i]; + if( x > e.pos.x && x < e.pos.x + e.w && + y > e.pos.y && y < e.pos.y + e.h ){ + found = e; + } + } + if(found){ + found.action(); + } + draw(); + moves+=1; +} + +function gameOver(result){ + canvas.removeEventListener('click', getElement); + setTimeout( function(){ + canvas.addEventListener('click', function(){ + init(); + }); + }, 1500); + c.fillStyle = "black"; + c.font = "3rem Arial"; + c.fillText(result, (w-c.measureText(result).width)/2, 100); +} + +function loadImages(){ + let total = 0; + imgSrc = ['img/farmer.png','img/wolf.png','img/goat.png','img/cabbage.png','img/boat.png']; + textures = {}; + for(name of imgSrc){ + textures[name] = new Image(); + textures[name].src = name; + textures[name].onload = function(){ + total++; + if( total == imgSrc.length ) + init(); + } + } +} + +loadImages(); + +window.onresize = function(){ + init(); +}; \ No newline at end of file diff --git a/Games/Cross_The_River_Game/screenshot.png b/Games/Cross_The_River_Game/screenshot.png new file mode 100644 index 0000000000..4215ff780b Binary files /dev/null and b/Games/Cross_The_River_Game/screenshot.png differ diff --git a/Games/Cross_The_River_Game/sw.js b/Games/Cross_The_River_Game/sw.js new file mode 100644 index 0000000000..5fdd30db3a --- /dev/null +++ b/Games/Cross_The_River_Game/sw.js @@ -0,0 +1,65 @@ +const filesToCache = [ + './', + './index.html', + './js/main.js', + './js/aux.js', + './js/Passenger.js', + './js/Boat.js', + './css/main.css', + './favicon.png', + './manifest.json', + './img/boat.png', + './img/goat.png', + './img/cabbage.png', + './img/farmer.png', + './img/wolf.png' +]; + +const staticCacheName = 'bridge-v1.5'; + +self.addEventListener('install', event => { +event.waitUntil( +caches.open(staticCacheName) +.then(cache => { + return cache.addAll(filesToCache); +}) +); +}); + +self.addEventListener('fetch', event => { +event.respondWith( +caches.match(event.request) +.then(response => { + if (response) { + return response; + } + + return fetch(event.request) + + .then(response => { + return caches.open(staticCacheName).then(cache => { + cache.put(event.request.url, response.clone()); + return response; + }); + }); + +}).catch(error => {}) +); +}); + +self.addEventListener('activate', event => { + +const cacheWhitelist = [staticCacheName]; + +event.waitUntil( +caches.keys().then(cacheNames => { + return Promise.all( + cacheNames.map(cacheName => { + if (cacheWhitelist.indexOf(cacheName) === -1) { + return caches.delete(cacheName); + } + }) + ); +}) +); +}); \ No newline at end of file diff --git a/Games/Dot_Dash/README.md b/Games/Dot_Dash/README.md new file mode 100644 index 0000000000..60cafb6234 --- /dev/null +++ b/Games/Dot_Dash/README.md @@ -0,0 +1,37 @@ +# **Game_Name** +Dot Dash + +--- + +
    + +## **Description 📃** +"Dot Dash" is an exciting and fast-paced clicking game designed to test your reflexes and agility. In this game, dots appear randomly on the screen, and your goal is to click on as many dots as possible within one minute. As you score more points, the game becomes increasingly challenging with faster dot appearances. + +## **Functionalities 🎮** + + +- Random Dot Generation: Dots appear at random positions within the game area. +- Progressive Difficulty: The speed of dot appearances increases as the player’s score increases. +- Score Tracking: The game keeps track of the player’s score, displayed in real-time. +- Timer: A countdown timer that starts from 60 seconds, displayed on the screen. +- Game Over Screen: Displays the final score and a countdown to restart the game after time runs out. +- Responsive Design: Optimized for both desktop and mobile play. +
    + +## **How to play? 🕹️** + +-Start the Game: Click the "Start Game" button to begin. +- Catch the Dots: Click on the dots that appear randomly on the screen to score points. +- Watch the Timer: Keep an eye on the timer; you have 60 seconds to catch as many dots as possible. +- Increase Your Score: Each dot clicked increases your score, and the dots will start appearing more quickly as your score increases. +- Game Over: When the timer reaches zero, the game will display your final score and automatically reload after a few seconds for another round. + +## **Screenshots 📸** + +![image](https://github.com/aditya-bhaumik/GameZone/assets/92214013/fab5ab32-2043-41ab-b805-f76aa2fd68dc) +![image](https://github.com/aditya-bhaumik/GameZone/assets/92214013/7f613e5c-8fc7-4515-8bc1-19d66b704be6) + + + +
    diff --git a/Games/Dot_Dash/assets/images/Dot_Dash.png b/Games/Dot_Dash/assets/images/Dot_Dash.png new file mode 100644 index 0000000000..1d09883db4 Binary files /dev/null and b/Games/Dot_Dash/assets/images/Dot_Dash.png differ diff --git a/Games/Dot_Dash/assets/images/README.md b/Games/Dot_Dash/assets/images/README.md new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/Games/Dot_Dash/assets/images/README.md @@ -0,0 +1 @@ + diff --git a/Games/Dot_Dash/index.html b/Games/Dot_Dash/index.html new file mode 100644 index 0000000000..734aec69ca --- /dev/null +++ b/Games/Dot_Dash/index.html @@ -0,0 +1,34 @@ + + + + + + Dot Dash + + + +
    +
    +
    Score: 0
    +
    Time Left: 30s
    +
    +
    + +
    + + + + + + + + + + + + + + + + + diff --git a/Games/Dot_Dash/script.js b/Games/Dot_Dash/script.js new file mode 100644 index 0000000000..faaceb8b74 --- /dev/null +++ b/Games/Dot_Dash/script.js @@ -0,0 +1,94 @@ +let score = 0; +let timeLeft = 30; // Game duration of 1 minute +let gameInterval; +let dotInterval; +let dotSpeed = 1000; // Start with a moderate speed for dot spawn (in milliseconds) + +const scoreElement = document.getElementById('score'); +const timeElement = document.getElementById('time'); +const gameArea = document.getElementById('gameArea'); +const startButton = document.getElementById('startButton'); +const gameContainer = document.querySelector('.game-container'); + +startButton.addEventListener('click', startGame); + +function startGame() { + score = 0; + timeLeft = 30; // Reset timer to 1 minute + dotSpeed = 1000; // Reset speed to moderate initial value + scoreElement.textContent = score; + timeElement.textContent = timeLeft; + startButton.disabled = true; + gameArea.innerHTML = ''; // Clear any dots before starting + gameInterval = setInterval(updateTimer, 1000); + spawnDot(); +} + +function updateTimer() { + timeLeft--; + timeElement.textContent = timeLeft; + if (timeLeft === 0) { + clearInterval(gameInterval); + clearTimeout(dotInterval); + startButton.disabled = false; + showGameOverMessage(); + } +} + +function spawnDot() { + if (timeLeft <= 0) return; // Prevent spawning new dots if time is up + + const dot = document.createElement('div'); + dot.classList.add('dot'); + dot.style.top = `${Math.random() * 90}%`; + dot.style.left = `${Math.random() * 90}%`; + dot.addEventListener('click', () => { + score++; + scoreElement.textContent = score; + dot.remove(); + adjustDotSpeed(); + spawnDot(); + }); + gameArea.appendChild(dot); + + dotInterval = setTimeout(() => { + if (dot.parentNode && timeLeft > 0) { + dot.remove(); + spawnDot(); + } + }, dotSpeed); +} + +function adjustDotSpeed() { + // Increase the speed of dot spawning as the score increases + if (score % 5 === 0 && dotSpeed > 500) { + dotSpeed -= 100; // Increase speed by reducing interval time + } +} + +function showGameOverMessage() { + gameArea.innerHTML = ''; // Clear any remaining dots + const gameOverMessage = document.createElement('div'); + gameOverMessage.classList.add('game-over-message'); + gameOverMessage.innerHTML = ` +

    Game Over!

    +

    You caught ${score} dots.

    +

    Reloading in 5 seconds...

    + `; + gameContainer.appendChild(gameOverMessage); + + let reloadTimeLeft = 5; + const reloadTimerElement = document.getElementById('reload-timer'); + const reloadInterval = setInterval(() => { + reloadTimeLeft--; + reloadTimerElement.textContent = reloadTimeLeft; + if (reloadTimeLeft === 0) { + clearInterval(reloadInterval); + location.reload(); + } + }, 1000); +} + + + + diff --git a/Games/Dot_Dash/styles.css b/Games/Dot_Dash/styles.css new file mode 100644 index 0000000000..1af3da4e82 --- /dev/null +++ b/Games/Dot_Dash/styles.css @@ -0,0 +1,88 @@ +body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + margin: 0; + background: linear-gradient(45deg, #00b4db, #0083b0); +} + +.game-container { + text-align: center; + background: #ffffff; + border-radius: 10px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + overflow: hidden; + width: 90%; + max-width: 600px; + position: relative; +} + +.header { + background: #0083b0; + color: white; + padding: 20px; + display: flex; + justify-content: space-between; +} + +.score-board, .timer { + font-size: 1.5em; +} + +.game-area { + position: relative; + height: 400px; + background: linear-gradient(135deg, #00c6ff, #0072ff); + border-top: 1px solid #ddd; +} + +.dot { + width: 20px; + height: 20px; + background: #ff5722; + border-radius: 50%; + position: absolute; + cursor: pointer; +} + +.start-button { + background: #00b4db; + color: white; + border: none; + padding: 15px 30px; + font-size: 1.2em; + cursor: pointer; + margin: 20px; + border-radius: 5px; +} + +.start-button:hover { + background: #0083b0; +} + +.game-over-message { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + background: rgba(0, 0, 0, 0.8); + color: white; + padding: 30px; + border-radius: 10px; + text-align: center; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); +} + +@media (max-width: 600px) { + .header { + flex-direction: column; + align-items: center; + } + .game-area { + height: 300px; + } +} + + diff --git a/Games/Drawing_app/Drawing_app.png b/Games/Drawing_app/Drawing_app.png new file mode 100644 index 0000000000..cc37fbdc0c Binary files /dev/null and b/Games/Drawing_app/Drawing_app.png differ diff --git a/Games/Drawing_app/Readme.md b/Games/Drawing_app/Readme.md new file mode 100644 index 0000000000..a13c5d6471 --- /dev/null +++ b/Games/Drawing_app/Readme.md @@ -0,0 +1,51 @@ +# 🎨 Drawing App + +## Overview + +This is a simple and interactive drawing application built with HTML, CSS, and JavaScript. It allows users to draw shapes, use a brush tool, erase drawings, and save their creations as an image. The application offers a variety of features to make the drawing experience enjoyable and easy to use. + +## ✨ Features + +- **🔳 Shapes**: Draw rectangles, circles, and triangles. +- **🖌️ Brush**: Freehand drawing with customizable brush size. +- **🧽 Eraser**: Erase parts of your drawing. +- **🎨 Colors**: Choose from a variety of colors or use the color picker to select a custom color. +- **✔️ Fill Color**: Option to fill shapes with color. +- **🧹 Clear Canvas**: Clear the entire canvas with a single click. +- **💾 Save Image**: Save your drawing as an image file. + +## 🚀 How to Use + +### 1. Drawing Shapes + +- **Select a Shape**: Choose from Rectangle, Circle, or Triangle in the "Shapes" section. +- **Fill Color**: Check the "Fill color" option if you want the shapes to be filled with color. + +### 2. Using the Brush + +- **Select the Brush Tool**: Click on the "Brush" option in the "Options" section. +- **Adjust Brush Size**: Use the slider to adjust the brush size. + +### 3. Using the Eraser + +- **Select the Eraser Tool**: Click on the "Eraser" option in the "Options" section. + +### 4. Changing Colors + +- **Select a Color**: Click on one of the color options in the "Colors" section. +- **Custom Color**: Use the color picker to select a custom color. + +### 5. Clearing the Canvas + +- **Clear Canvas**: Click on the "Clear Canvas" button to erase everything on the canvas. + +### 6. Saving Your Drawing + +- **Save as Image**: Click on the "Save As Image" button to download your drawing as a JPG file. + +## 📸 Screenshot +![image](Drawing_app.png) + +## 🎨 Conclusion + +Enjoy creating your own drawings with this simple yet powerful drawing application. Feel free to explore different shapes, colors, and tools to make your artwork unique. If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request. Happy drawing! 😊 \ No newline at end of file diff --git a/Games/Drawing_app/icons/brush.svg b/Games/Drawing_app/icons/brush.svg new file mode 100644 index 0000000000..9e06c55c77 --- /dev/null +++ b/Games/Drawing_app/icons/brush.svg @@ -0,0 +1,3 @@ + + + diff --git a/Games/Drawing_app/icons/circle.svg b/Games/Drawing_app/icons/circle.svg new file mode 100644 index 0000000000..8b8206f0f4 --- /dev/null +++ b/Games/Drawing_app/icons/circle.svg @@ -0,0 +1,3 @@ + + + diff --git a/Games/Drawing_app/icons/eraser.svg b/Games/Drawing_app/icons/eraser.svg new file mode 100644 index 0000000000..f1498c572f --- /dev/null +++ b/Games/Drawing_app/icons/eraser.svg @@ -0,0 +1,3 @@ + + + diff --git a/Games/Drawing_app/icons/rectangle.svg b/Games/Drawing_app/icons/rectangle.svg new file mode 100644 index 0000000000..4506e74767 --- /dev/null +++ b/Games/Drawing_app/icons/rectangle.svg @@ -0,0 +1,3 @@ + + + diff --git a/Games/Drawing_app/icons/triangle.svg b/Games/Drawing_app/icons/triangle.svg new file mode 100644 index 0000000000..a7570f92d4 --- /dev/null +++ b/Games/Drawing_app/icons/triangle.svg @@ -0,0 +1,3 @@ + + + diff --git a/Games/Drawing_app/index.html b/Games/Drawing_app/index.html new file mode 100644 index 0000000000..5f2e6a1988 --- /dev/null +++ b/Games/Drawing_app/index.html @@ -0,0 +1,73 @@ + + + + + Drawing App JavaScript + + + + + +
    +
    +
    + +
      +
    • + + Rectangle +
    • +
    • + + Circle +
    • +
    • + + Triangle +
    • +
    • + + +
    • +
    +
    +
    + +
      +
    • + + Brush +
    • +
    • + + Eraser +
    • +
    • + +
    • +
    +
    +
    + +
      +
    • +
    • +
    • +
    • +
    • + +
    • +
    +
    +
    + + +
    +
    +
    + +
    +
    + + + \ No newline at end of file diff --git a/Games/Drawing_app/script.js b/Games/Drawing_app/script.js new file mode 100644 index 0000000000..cfcba0734a --- /dev/null +++ b/Games/Drawing_app/script.js @@ -0,0 +1,117 @@ +const paintCanvas = document.querySelector("canvas"), +toolButtons = document.querySelectorAll(".tool"), +fillCheckbox = document.querySelector("#fill-color"), +brushSizeSlider = document.querySelector("#size-slider"), +colorOptions = document.querySelectorAll(".colors .option"), +colorInput = document.querySelector("#color-picker"), +clearButton = document.querySelector(".clear-canvas"), +saveButton = document.querySelector(".save-img"), +context = paintCanvas.getContext("2d"); + +let lastMouseX, lastMouseY, canvasSnapshot, +isPainting = false, +activeTool = "brush", +brushSize = 5, +activeColor = "#000"; + +const initializeCanvasBackground = () => { + context.fillStyle = "#fff"; + context.fillRect(0, 0, paintCanvas.width, paintCanvas.height); + context.fillStyle = activeColor; +} + +window.addEventListener("load", () => { + paintCanvas.width = paintCanvas.offsetWidth; + paintCanvas.height = paintCanvas.offsetHeight; + initializeCanvasBackground(); +}); + +const drawRectangle = (event) => { + if(!fillCheckbox.checked) { + return context.strokeRect(event.offsetX, event.offsetY, lastMouseX - event.offsetX, lastMouseY - event.offsetY); + } + context.fillRect(event.offsetX, event.offsetY, lastMouseX - event.offsetX, lastMouseY - event.offsetY); +} + +const drawCircleShape = (event) => { + context.beginPath(); + let radius = Math.sqrt(Math.pow((lastMouseX - event.offsetX), 2) + Math.pow((lastMouseY - event.offsetY), 2)); + context.arc(lastMouseX, lastMouseY, radius, 0, 2 * Math.PI); + fillCheckbox.checked ? context.fill() : context.stroke(); +} + +const drawTriangleShape = (event) => { + context.beginPath(); + context.moveTo(lastMouseX, lastMouseY); + context.lineTo(event.offsetX, event.offsetY); + context.lineTo(lastMouseX * 2 - event.offsetX, event.offsetY); + context.closePath(); + fillCheckbox.checked ? context.fill() : context.stroke(); +} + +const beginDrawing = (event) => { + isPainting = true; + lastMouseX = event.offsetX; + lastMouseY = event.offsetY; + context.beginPath(); + context.lineWidth = brushSize; + context.strokeStyle = activeColor; + context.fillStyle = activeColor; + canvasSnapshot = context.getImageData(0, 0, paintCanvas.width, paintCanvas.height); +} + +const executeDrawing = (event) => { + if(!isPainting) return; + context.putImageData(canvasSnapshot, 0, 0); + + if(activeTool === "brush" || activeTool === "eraser") { + context.strokeStyle = activeTool === "eraser" ? "#fff" : activeColor; + context.lineTo(event.offsetX, event.offsetY); + context.stroke(); + } else if(activeTool === "rectangle"){ + drawRectangle(event); + } else if(activeTool === "circle"){ + drawCircleShape(event); + } else { + drawTriangleShape(event); + } +} + +toolButtons.forEach(button => { + button.addEventListener("click", () => { + document.querySelector(".options .active").classList.remove("active"); + button.classList.add("active"); + activeTool = button.id; + }); +}); + +brushSizeSlider.addEventListener("change", () => brushSize = brushSizeSlider.value); + +colorOptions.forEach(button => { + button.addEventListener("click", () => { + document.querySelector(".options .selected").classList.remove("selected"); + button.classList.add("selected"); + activeColor = window.getComputedStyle(button).getPropertyValue("background-color"); + }); +}); + +colorInput.addEventListener("change", () => { + colorInput.parentElement.style.background = colorInput.value; + colorInput.parentElement.click(); +}); + +clearButton.addEventListener("click", () => { + context.clearRect(0, 0, paintCanvas.width, paintCanvas.height); + initializeCanvasBackground(); +}); + +saveButton.addEventListener("click", () => { + const link = document.createElement("a"); + link.download = `${Date.now()}.jpg`; + link.href = paintCanvas.toDataURL(); + link.click(); +}); + +paintCanvas.addEventListener("mousedown", beginDrawing); +paintCanvas.addEventListener("mousemove", executeDrawing); +paintCanvas.addEventListener("mouseup", () => isPainting = false); diff --git a/Games/Drawing_app/style.css b/Games/Drawing_app/style.css new file mode 100644 index 0000000000..c4018860e1 --- /dev/null +++ b/Games/Drawing_app/style.css @@ -0,0 +1,146 @@ + +@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap'); +*{ + margin: 0; + padding: 0; + box-sizing: border-box; + font-family: 'Poppins', sans-serif; +} +body{ + display: flex; + align-items: center; + justify-content: center; + min-height: 100vh; + background: #4A98F7; +} +.container{ + display: flex; + width: 100%; + gap: 10px; + padding: 10px; + max-width: 1050px; +} +section{ + background: #fff; + border-radius: 7px; +} +.tools-board{ + width: 210px; + padding: 15px 22px 0; +} +.tools-board .row{ + margin-bottom: 20px; +} +.row .options{ + list-style: none; + margin: 10px 0 0 5px; +} +.row .options .option{ + display: flex; + cursor: pointer; + align-items: center; + margin-bottom: 10px; +} +.option:is(:hover, .active) img{ + filter: invert(17%) sepia(90%) saturate(3000%) hue-rotate(900deg) brightness(100%) contrast(100%); +} +.option :where(span, label){ + color: #5A6168; + cursor: pointer; + padding-left: 10px; +} +.option:is(:hover, .active) :where(span, label){ + color: #4A98F7; +} +.option #fill-color{ + cursor: pointer; + height: 14px; + width: 14px; +} +#fill-color:checked ~ label{ + color: #4A98F7; +} +.option #size-slider{ + width: 100%; + height: 5px; + margin-top: 10px; +} +.colors .options{ + display: flex; + justify-content: space-between; +} +.colors .option{ + height: 20px; + width: 20px; + border-radius: 50%; + margin-top: 3px; + position: relative; +} +.colors .option:nth-child(1){ + background-color: #fff; + border: 1px solid #bfbfbf; +} +.colors .option:nth-child(2){ + background-color: #000; +} +.colors .option:nth-child(3){ + background-color: #E02020; +} +.colors .option:nth-child(4){ + background-color: #6DD400; +} +.colors .option:nth-child(5){ + background-color: #4A98F7; +} +.colors .option.selected::before{ + position: absolute; + content: ""; + top: 50%; + left: 50%; + height: 12px; + width: 12px; + background: inherit; + border-radius: inherit; + border: 2px solid #fff; + transform: translate(-50%, -50%); +} +.colors .option:first-child.selected::before{ + border-color: #ccc; +} +.option #color-picker{ + opacity: 0; + cursor: pointer; +} +.buttons button{ + width: 100%; + color: #fff; + border: none; + outline: none; + padding: 11px 0; + font-size: 0.9rem; + margin-bottom: 13px; + background: none; + border-radius: 4px; + cursor: pointer; +} +.buttons .clear-canvas{ + color: #6C757D; + border: 1px solid #6C757D; + transition: all 0.3s ease; +} +.clear-canvas:hover{ + color: #fff; + background: #6C757D; +} +.buttons .save-img{ + background: #4A98F7; + border: 1px solid #4A98F7; +} +.drawing-board{ + flex: 1; + overflow: hidden; +} +.drawing-board canvas{ + width: 100%; + height: 100%; +} \ No newline at end of file diff --git a/Games/Fidget_Spinner_Game/README.md b/Games/Fidget_Spinner_Game/README.md new file mode 100644 index 0000000000..7f6afc0085 --- /dev/null +++ b/Games/Fidget_Spinner_Game/README.md @@ -0,0 +1,37 @@ +# Fidget Spinner + +A fidget spinner made in JavaScript. + +## Description 📃 + + Fidget Spinner is an interactive online simulation of a physical fidget spinner. This digital version allows users to experience the satisfying and stress-relieving sensation of spinning a fidget spinner directly from their browser. + +## Functionalities 🎮 + +- **Interactive Spinning**: Users can spin the fidget spinner by dragging the mouse across the screen. +- **Speed Display**: The current speed of the spinner is displayed, giving users real-time feedback. +- **Custom Speed Setting**: Users can set a custom speed for the fidget spinner, allowing for a personalized experience. +- **Automatic Spin**: For those who prefer not to drag their mouse, a button is available to automatically spin the fidget spinner. + +## How to Play? 🕹️ + +1. **Drag to Spin**: Click and drag the mouse across the spinner to make it spin. The faster you drag, the faster the spinner will rotate. +2. **View Speed**: Watch the speedometer to see how fast the spinner is going. +3. **Set Custom Speed**: Use the input box to set a custom speed for the spinner. +4. **Automatic Spin**: Click the "Spin" button to make the spinner spin without dragging. + +## Screenshots 📸 + +![Fidget Spinner](assets/images/Fidget.png) + + + +## Updates + +- **Speed Display**: Added for real-time feedback. +- **Custom Speed Setting**: Introduced a feature to set custom speed. +- **Automatic Spin**: Added a "Spin" button for automatic spinning. + + + +Enjoy the virtual spinning experience and have fun! diff --git a/Games/Fidget_Spinner_Game/assets/images/Fidget.png b/Games/Fidget_Spinner_Game/assets/images/Fidget.png new file mode 100644 index 0000000000..1f825166d8 Binary files /dev/null and b/Games/Fidget_Spinner_Game/assets/images/Fidget.png differ diff --git a/Games/Fidget_Spinner_Game/index.html b/Games/Fidget_Spinner_Game/index.html new file mode 100644 index 0000000000..3fbad5c860 --- /dev/null +++ b/Games/Fidget_Spinner_Game/index.html @@ -0,0 +1,26 @@ + + + + + Fidget Spinner + + + + + + + + + +Current Speed :
    +
    + --------------------
    +  
    + For Lazy People + + + + + + \ No newline at end of file diff --git a/Games/Fidget_Spinner_Game/index.js b/Games/Fidget_Spinner_Game/index.js new file mode 100644 index 0000000000..9542ea1904 --- /dev/null +++ b/Games/Fidget_Spinner_Game/index.js @@ -0,0 +1,103 @@ +'use strict'; + +var canvas = document.getElementById('canvas'); +var ctx = canvas.getContext('2d'); +var step = 2 * Math.PI / 360; +var radius = 120; + +var dragStart = false; +var angle = 0; +var speed = 7; +document.getElementById("svalue").innerHTML = speed; +ctx.strokeStyle = '#FA8072'; +ctx.lineWidth = radius / 5.5; + +function spin() { + speed = document.getElementById("svalue").innerHTML; +} + +function verifyorder() { + speed = document.getElementById('value').value; + document.getElementById("svalue").innerHTML = speed; +} + + + +canvas.addEventListener('mousedown', function (_ref) { + var clientX = _ref.clientX; + var clientY = _ref.clientY; + + dragStart = { clientX: clientX, clientY: clientY }; +}); +canvas.addEventListener('touchstart', function (_ref2) { + var originalEvent = _ref2.originalEvent; + + dragStart = { + clientX: originalEvent.touches[0].pageX, + clientY: originalEvent.touches[0].pageY + }; +}); +canvas.addEventListener('mousemove', function (_ref3) { + var clientX = _ref3.clientX; + var clientY = _ref3.clientY; + return dragStart && function () { + updateSpeed(dragStart, { clientX: clientX, clientY: clientY }); + dragStart = { clientX: clientX, clientY: clientY }; + }(); +}); +canvas.addEventListener('touchmove', function (_ref4) { + var originalEvent = _ref4.originalEvent; + return dragStart && function () { + updateSpeed(dragStart, { + clientX: originalEvent.touches[0].pageX, + clientY: originalEvent.touches[0].pageY + }); + dragStart = { + clientX: originalEvent.touches[0].pageX, + clientY: originalEvent.touches[0].pageY + }; + }(); +}); +window.addEventListener('mouseup', function () { + dragStart = false; +}); +window.addEventListener('touchend', function () { + dragStart = false; +}); + +function updateSpeed(startPos, endPos) { + speed = (Math.atan2(startPos.clientX - (canvas.offsetLeft + canvas.width / 2), startPos.clientY - (canvas.offsetTop + canvas.height / 2)) - Math.atan2(endPos.clientX - (canvas.offsetLeft + canvas.width / 2), endPos.clientY - (canvas.offsetTop + canvas.height / 2))) * radius; +} + +function render() { + ctx.clearRect(0, 0, canvas.width, canvas.height); + + angle += step * speed; + speed = Math.max(speed - 0.08, Math.min(speed + 0.08, 0)); + + for (var i = 0; i < 3; i++) { + var x = canvas.width / 2 + radius * Math.sin(angle + i * (120 * step)); + var y = canvas.height / 2 - radius * Math.cos(angle + i * (120 * step)); + ctx.beginPath(); + ctx.moveTo(canvas.width / 2, canvas.height / 2); + ctx.lineTo(x, y); + ctx.stroke(); + ctx.closePath(); + + ctx.beginPath(); + ctx.arc(x, y, radius / 2.5, 0, 2 * Math.PI); + ctx.stroke(); + ctx.fill(); + ctx.closePath(); + } + + ctx.beginPath(); + ctx.arc(canvas.width / 2, canvas.height / 2, radius / 2.5, 0, 2 * Math.PI); + ctx.stroke(); + ctx.fill(); + ctx.closePath(); + + window.requestAnimationFrame(render); +} + +render(); \ No newline at end of file diff --git a/Games/Fidget_Spinner_Game/styles.css b/Games/Fidget_Spinner_Game/styles.css new file mode 100644 index 0000000000..09d85eaf10 --- /dev/null +++ b/Games/Fidget_Spinner_Game/styles.css @@ -0,0 +1,14 @@ +body { + margin: 0; + background: #000; + } + + canvas { + display: block; + margin: 0 auto; + } + corner{ + position: absolute; + top: 5px; + right: 10px; + } \ No newline at end of file diff --git a/Games/Ganesh QR Maker/QR CODE Generator.png b/Games/Ganesh QR Maker/QR CODE Generator.png new file mode 100644 index 0000000000..f48474a799 Binary files /dev/null and b/Games/Ganesh QR Maker/QR CODE Generator.png differ diff --git a/Games/Ganesh QR Maker/README.md b/Games/Ganesh QR Maker/README.md new file mode 100644 index 0000000000..9dd9b305cd --- /dev/null +++ b/Games/Ganesh QR Maker/README.md @@ -0,0 +1,19 @@ +# QR Code Generator + +## About The Project + +A simple web application which will generate a QR Code. + +## Tech Stacks Used + + +![HTML](https://img.shields.io/badge/html5%20-%23E34F26.svg?&style=for-the-badge&logo=html5&logoColor=white) +![CSS](https://img.shields.io/badge/css3%20-%231572B6.svg?&style=for-the-badge&logo=css3&logoColor=white) +![JS](https://img.shields.io/badge/javascript%20-%23323330.svg?&style=for-the-badge&logo=javascript&logoColor=%23F7DF1E) + +## API Used + +Visit Website: https://goqr.me/api/ + +## Screenshot +![alt text]() diff --git a/Games/Ganesh QR Maker/index.html b/Games/Ganesh QR Maker/index.html new file mode 100644 index 0000000000..5e543ecd2a --- /dev/null +++ b/Games/Ganesh QR Maker/index.html @@ -0,0 +1,23 @@ + + + + + + + + + QR Code Generator + + + +

    GANESH QR MAKER

    +
    + + qrcode +

    Made with ♥ by Ganesh

    +
    +
    Successfully Generated!!!
    + + + + diff --git a/Games/Ganesh QR Maker/script.js b/Games/Ganesh QR Maker/script.js new file mode 100644 index 0000000000..b7a63489ea --- /dev/null +++ b/Games/Ganesh QR Maker/script.js @@ -0,0 +1,21 @@ +const btn = document.querySelector('.btn'); +const code = document.querySelector('.code'); +const input = document.querySelector('.input'); +const toast = document.querySelector('#toast'); + +btn.addEventListener('click', generate); + +function generate() { + const data = input.value; + const URL = `https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=${data}`; + code.src = URL; + + toastDiv(); +} + +function toastDiv() { + toast.className = "show"; + setTimeout(function() { + toast.className = toast.className.replace("show", ""); + }, 2000) +} diff --git a/Games/Ganesh QR Maker/style.css b/Games/Ganesh QR Maker/style.css new file mode 100644 index 0000000000..b1c174d733 --- /dev/null +++ b/Games/Ganesh QR Maker/style.css @@ -0,0 +1,94 @@ +* { + margin: 0; + padding: 0; + box-sizing: border-box; + } + + body { + width: 100%; + height: 100vh; + background: linear-gradient(to right top, #ff0f7b, #f89b29); + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + } + + h1 { + font-size: 55px; + text-shadow: 0 1px 0 #ccc, 0 2px 0 #c9c9c9, 0 3px 0 #bbb, 0 4px 0 #b9b9b9, + 0 5px 0 #aaa, 0 6px 1px rgba(0, 0, 0, 0.1), 0 0 5px rgba(0, 0, 0, 0.1), + 0 1px 3px rgba(0, 0, 0, 0.3), 0 3px 5px rgba(0, 0, 0, 0.2), + 0 5px 10px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.2), + 0 20px 20px rgba(0, 0, 0, 0.15); + } + + .main { + width: 25%; + height: 70%; + padding: 50px 15px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + background: #fff; + box-shadow: 0 10px 25px -10px rgba(0, 0, 0, 0.5); + border-radius: 5px; + margin-top: 25px; + margin-bottom: 40px; + } + + .main .input { + width: 90%; + padding: 8px 25px; + border: 3px solid #9e9e9e; + outline: none; + margin: 15px 0; + } + .main .input:focus { + border: 3px solid #f89b29; + } + .btn, + .input { + font-size: 1.1rem; + border-radius: 5px; + } + .main .btn { + width: 90%; + padding: 12px 0; + outline: none; + border: none; + border-radius: 5px; + background: #f89b29; + color: #fff; + transition: 0.3s; + } + .main .code { + margin: 10px 0; + } + + .main .btn:hover { + box-shadow: 0 10px 25px -10px #f89b29; + } + + #toast { + position: absolute; + bottom: 0; + border-radius: 5px; + padding: 10px 50px; + background: #07f49e; + opacity: 0; + visibility: hidden; + box-shadow: 0 10px 25px -10px #07f49e; + transition: 0.3s; + + font-size: 20px; + } + + #toast.show { + visibility: visible; + opacity: 1; + bottom: 50px; + } + + \ No newline at end of file diff --git a/Games/Go-fish-master/.gitignore b/Games/Go-fish-master/.gitignore new file mode 100644 index 0000000000..d5cc28426a --- /dev/null +++ b/Games/Go-fish-master/.gitignore @@ -0,0 +1 @@ +audio diff --git a/Games/Go-fish-master/README.md b/Games/Go-fish-master/README.md new file mode 100644 index 0000000000..d8115bec54 --- /dev/null +++ b/Games/Go-fish-master/README.md @@ -0,0 +1,27 @@ +# Go Fish +--------- + +An emulator for the card game 'Go Fish'. Choose how many opponents you want to play against and see who is better! + + +## Rules: + +- Each player starts with 7 cards (2/3 players) or 5 cards (4 or more players). +- Play begins with you, then each of your opponents from left to right. +- During their turn, each player 'goes fishing' by selecting a value of a card in their hand and another player, in the game this is done by clicking a card and an opponent, then clicking 'Take Turn'. If the selected player has any cards of that value the 'fisher' has made a 'catch'. The selected player must give the 'fisher' all their cards of that value. If the selected player has no cards of that value, the selector has not made a 'catch' and must 'Go Fish!' and draws a new card from the deck. +- If, during their turn, a player ends up with all 4 cards then they have collected a full set. The player then must immediately declare this and play their set face up, in front of them. +- If during play a player ends up with no cards in their hand they must draw a card from the deck, rather than 'going fishing' for cards from other people. +- The winner is the player with the most sets at the end. +- Once all 13 sets have been completed, play ends. + + +## Tools +- **HTML** +- **CSS** +- **JavaScript** +- **JQuery** +- **Atom Development Environment** +- **SourceTree Source Control** + +## Screenshot +![image](../../assets/images/Go-fish-master.png) \ No newline at end of file diff --git a/Games/Go-fish-master/css/master.css b/Games/Go-fish-master/css/master.css new file mode 100644 index 0000000000..515e4be716 --- /dev/null +++ b/Games/Go-fish-master/css/master.css @@ -0,0 +1,105 @@ +/* *{ + border: 1px solid red; +} */ + + + +body { + font-family: "Open Sans", "Trebuchet MS", Helvetica, sans-serif; + margin: 0px; + background-color: green; + color: white; + border: 5px solid gold; +} + +a { + text-decoration: none; + color: white; +} + +a:visited { + color: white; +} + +a:active { + color: red; +} + +a:hover { + color: gold; +} + +button { + height: 30px; + width: 100px; + border-radius: 10%; + background-color: ivory; + border-color: ivory; + border-style: outset; + border-width: 5px; +} + +button:active { + border-style: inset; +} + +button:focus { + outline: none; +} + +ul { + text-align: left; + padding-left: 5%; + padding-right: 5%; +} + +.center { + /* display: block; */ + text-align: center; +} + +.tracker { + padding-left: 5px; + padding-right: 5px; + width: 200px; + margin: 5px; + border: 5px ridge black; + /* justify-content: space-around; */ +} + +.card { + width: 100px; + /* height: 200px; */ + border: 1px solid black; + justify-content: space-around; +} + +.card:hover { + position: relative; + top: -10px; +} + +.title { + margin-top: 40%; +} + +#cardContainer { + /* display: flex; */ + flex-wrap: nowrap; + border: 3px solid gold; + border-bottom: 0px; +} + +#opponentContainer { + display: flex; + flex-direction: row; + justify-content: space-around; +} + +.search { + display: flex; + flex-direction: row; + justify-content: space-around; + padding-left: 25%; + padding-right: 25%; +} diff --git a/Games/Go-fish-master/images/cardsjpg/10C.jpg b/Games/Go-fish-master/images/cardsjpg/10C.jpg new file mode 100644 index 0000000000..9a4580351d Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/10C.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/10D.jpg b/Games/Go-fish-master/images/cardsjpg/10D.jpg new file mode 100644 index 0000000000..69d2a61b8c Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/10D.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/10H.jpg b/Games/Go-fish-master/images/cardsjpg/10H.jpg new file mode 100644 index 0000000000..da4b4acbeb Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/10H.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/10S.jpg b/Games/Go-fish-master/images/cardsjpg/10S.jpg new file mode 100644 index 0000000000..7d61f5b075 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/10S.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/2C.jpg b/Games/Go-fish-master/images/cardsjpg/2C.jpg new file mode 100644 index 0000000000..c59aa5e3d9 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/2C.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/2D.jpg b/Games/Go-fish-master/images/cardsjpg/2D.jpg new file mode 100644 index 0000000000..ed3bdcfb2b Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/2D.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/2H.jpg b/Games/Go-fish-master/images/cardsjpg/2H.jpg new file mode 100644 index 0000000000..000cced39a Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/2H.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/2S.jpg b/Games/Go-fish-master/images/cardsjpg/2S.jpg new file mode 100644 index 0000000000..9652423dcb Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/2S.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/3C.jpg b/Games/Go-fish-master/images/cardsjpg/3C.jpg new file mode 100644 index 0000000000..018ef280a2 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/3C.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/3D.jpg b/Games/Go-fish-master/images/cardsjpg/3D.jpg new file mode 100644 index 0000000000..f50631b55b Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/3D.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/3H.jpg b/Games/Go-fish-master/images/cardsjpg/3H.jpg new file mode 100644 index 0000000000..fe91f05cdc Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/3H.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/3S.jpg b/Games/Go-fish-master/images/cardsjpg/3S.jpg new file mode 100644 index 0000000000..bce70b050f Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/3S.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/4C.jpg b/Games/Go-fish-master/images/cardsjpg/4C.jpg new file mode 100644 index 0000000000..fb9f4df527 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/4C.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/4D.jpg b/Games/Go-fish-master/images/cardsjpg/4D.jpg new file mode 100644 index 0000000000..ece8296879 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/4D.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/4H.jpg b/Games/Go-fish-master/images/cardsjpg/4H.jpg new file mode 100644 index 0000000000..8f1b5a193d Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/4H.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/4S.jpg b/Games/Go-fish-master/images/cardsjpg/4S.jpg new file mode 100644 index 0000000000..9c4c817b05 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/4S.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/5C.jpg b/Games/Go-fish-master/images/cardsjpg/5C.jpg new file mode 100644 index 0000000000..72fb8db48e Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/5C.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/5D.jpg b/Games/Go-fish-master/images/cardsjpg/5D.jpg new file mode 100644 index 0000000000..ebba5f22b9 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/5D.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/5H.jpg b/Games/Go-fish-master/images/cardsjpg/5H.jpg new file mode 100644 index 0000000000..7a125ada67 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/5H.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/5S.jpg b/Games/Go-fish-master/images/cardsjpg/5S.jpg new file mode 100644 index 0000000000..87897a23d9 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/5S.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/6C.jpg b/Games/Go-fish-master/images/cardsjpg/6C.jpg new file mode 100644 index 0000000000..8578b4b639 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/6C.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/6D.jpg b/Games/Go-fish-master/images/cardsjpg/6D.jpg new file mode 100644 index 0000000000..fd6ebc9c21 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/6D.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/6H.jpg b/Games/Go-fish-master/images/cardsjpg/6H.jpg new file mode 100644 index 0000000000..87c0e89d9b Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/6H.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/6S.jpg b/Games/Go-fish-master/images/cardsjpg/6S.jpg new file mode 100644 index 0000000000..33ac347eee Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/6S.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/7C.jpg b/Games/Go-fish-master/images/cardsjpg/7C.jpg new file mode 100644 index 0000000000..bb4777d815 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/7C.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/7D.jpg b/Games/Go-fish-master/images/cardsjpg/7D.jpg new file mode 100644 index 0000000000..9e271363c4 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/7D.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/7H.jpg b/Games/Go-fish-master/images/cardsjpg/7H.jpg new file mode 100644 index 0000000000..beb036895a Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/7H.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/7S.jpg b/Games/Go-fish-master/images/cardsjpg/7S.jpg new file mode 100644 index 0000000000..957bbf7fd0 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/7S.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/8C.jpg b/Games/Go-fish-master/images/cardsjpg/8C.jpg new file mode 100644 index 0000000000..41a7a6b46f Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/8C.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/8D.jpg b/Games/Go-fish-master/images/cardsjpg/8D.jpg new file mode 100644 index 0000000000..b9401f73b8 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/8D.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/8H.jpg b/Games/Go-fish-master/images/cardsjpg/8H.jpg new file mode 100644 index 0000000000..02e5040050 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/8H.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/8S.jpg b/Games/Go-fish-master/images/cardsjpg/8S.jpg new file mode 100644 index 0000000000..28ade6226e Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/8S.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/9C.jpg b/Games/Go-fish-master/images/cardsjpg/9C.jpg new file mode 100644 index 0000000000..865cbc6b74 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/9C.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/9D.jpg b/Games/Go-fish-master/images/cardsjpg/9D.jpg new file mode 100644 index 0000000000..85a17c4efb Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/9D.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/9H.jpg b/Games/Go-fish-master/images/cardsjpg/9H.jpg new file mode 100644 index 0000000000..f1e177f7fc Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/9H.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/9S.jpg b/Games/Go-fish-master/images/cardsjpg/9S.jpg new file mode 100644 index 0000000000..f5590fddbd Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/9S.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/AC.jpg b/Games/Go-fish-master/images/cardsjpg/AC.jpg new file mode 100644 index 0000000000..24750aacea Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/AC.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/AD.jpg b/Games/Go-fish-master/images/cardsjpg/AD.jpg new file mode 100644 index 0000000000..5a1b0e9a4c Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/AD.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/AH.jpg b/Games/Go-fish-master/images/cardsjpg/AH.jpg new file mode 100644 index 0000000000..ffd1372ce4 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/AH.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/AS.jpg b/Games/Go-fish-master/images/cardsjpg/AS.jpg new file mode 100644 index 0000000000..ff4ff48c24 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/AS.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/JC.jpg b/Games/Go-fish-master/images/cardsjpg/JC.jpg new file mode 100644 index 0000000000..19e16133a8 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/JC.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/JD.jpg b/Games/Go-fish-master/images/cardsjpg/JD.jpg new file mode 100644 index 0000000000..d6ae10a12a Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/JD.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/JH.jpg b/Games/Go-fish-master/images/cardsjpg/JH.jpg new file mode 100644 index 0000000000..6fabafed00 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/JH.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/JS.jpg b/Games/Go-fish-master/images/cardsjpg/JS.jpg new file mode 100644 index 0000000000..070a1a00ce Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/JS.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/KC.jpg b/Games/Go-fish-master/images/cardsjpg/KC.jpg new file mode 100644 index 0000000000..004a0a8a03 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/KC.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/KD.jpg b/Games/Go-fish-master/images/cardsjpg/KD.jpg new file mode 100644 index 0000000000..94138fd6dc Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/KD.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/KH.jpg b/Games/Go-fish-master/images/cardsjpg/KH.jpg new file mode 100644 index 0000000000..62073ac8d4 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/KH.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/KS.jpg b/Games/Go-fish-master/images/cardsjpg/KS.jpg new file mode 100644 index 0000000000..d3e9da74a3 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/KS.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/QC.jpg b/Games/Go-fish-master/images/cardsjpg/QC.jpg new file mode 100644 index 0000000000..0ad7d4d277 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/QC.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/QD.jpg b/Games/Go-fish-master/images/cardsjpg/QD.jpg new file mode 100644 index 0000000000..f385eab72e Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/QD.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/QH.jpg b/Games/Go-fish-master/images/cardsjpg/QH.jpg new file mode 100644 index 0000000000..3080de265e Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/QH.jpg differ diff --git a/Games/Go-fish-master/images/cardsjpg/QS.jpg b/Games/Go-fish-master/images/cardsjpg/QS.jpg new file mode 100644 index 0000000000..9c8501e755 Binary files /dev/null and b/Games/Go-fish-master/images/cardsjpg/QS.jpg differ diff --git a/Games/Go-fish-master/index.html b/Games/Go-fish-master/index.html new file mode 100644 index 0000000000..4198f51a95 --- /dev/null +++ b/Games/Go-fish-master/index.html @@ -0,0 +1,19 @@ + + + + + Go Fish + + + +
    +

    Let's Play Go Fish!

    + Play + Instructions +
    +
    + + +
    + + diff --git a/Games/Go-fish-master/js/scripts.js b/Games/Go-fish-master/js/scripts.js new file mode 100644 index 0000000000..7c657a0fcf --- /dev/null +++ b/Games/Go-fish-master/js/scripts.js @@ -0,0 +1,687 @@ +var gameActive = false; +var dealer; +var searchValue = "x"; +var searchPlayer = "x"; + +$(document).ready(function () { + $("#startButton").click(buttonPress); + $("#continue").click(moveOn); + $("#cardContainer").on("click", ".card", function () { + cardPress(this); + }); + $("#opponentContainer").on("click", ".opponent", function() { + opponentPress(this); + }); +}); + +function buttonPress() { + // var element = document.getElementById("sven"); + // var playDeck = new Deck(); + if(!gameActive) { + dealer = new Dealer(requestPlayers()); + sounds = new Sounds(); + gameActive = true; + alert("Hands dealt, ready to play.\n Click to begin."); + } +} + +function moveOn() { + if(gameActive) { + playGame(searchValue, searchPlayer); + } +} + +function cardPress(press) { + var value = $(press).attr('value'); + searchValue = value; + + switch (value) { + case "11": + value = "Jack"; + break; + case "12": + value = "Queen"; + break; + case "13": + value = "King"; + break; + case "1": + value = "Ace"; + break; + default: + } + + $("#searchValue").html(value); +} + +function opponentPress(press) { + var value = $(press).attr('number'); + searchPlayer = value; + $("#searchPlayer").html("Opponent: " + searchPlayer); +} + +function resetSearchValues() { + $("#searchValue").html(""); + $("#searchPlayer").html(""); + searchValue = "x"; + searchPlayer = "x"; +} + +// Gameplay cycle runs here after setup +function playGame(playerInputValue, playerInputOpponent) { + if(playerInputValue === "x" || playerInputOpponent === "x") { + $("playerInfo").html("Select opponent and card value to fish!"); + return; + } + + // For each player: + for (var i = 0; i < dealer.players.length; i++) { + var playerTakingTurn = dealer.players[i]; + + var canTakeTurn = playerTakingTurn.takeTurn(); + + // Overrides autoplay with human interraction + if (canTakeTurn === 2) { + if(playerTakingTurn.getHand() > 1) { + // If player cannot draw a card because deck is empty + if(!dealer.dealCard(playerTakingTurn)) { + // Skip player, there is nothing else they can do + $("#playerInfo").html("Deck is empty. Please continue to end.") + $("#continue").html("Continue"); + continue; + } + } + + // Switch value to int (collected as string from image) + var valueToSearch = parseInt(playerInputValue); + var opponentToSearch = dealer.players[playerInputOpponent]; + instigateCall(valueToSearch, opponentToSearch, playerTakingTurn); + resetSearchValues(); + + if(playerTakingTurn.getHand() > 1) { + $("#continue").html("Draw Card"); + } + continue; + } + + // If the player has no cards, draw a card + if(canTakeTurn === 0) { + // If player cannot draw a card because deck is empty + if(!dealer.dealCard(playerTakingTurn)) { + // Skip player, there is nothing else they can do + continue; + } + // Else pick a card and player to fish + } else { + // An array containing: + // [0] = direct reference to a card + // [1] = index of a player + var cardAndPlayerInt = playerTakingTurn.callCardAndPlayer(dealer.players.length); + + // Card value + var cardToFind = cardAndPlayerInt[0].value; + + // Direct reference to a player (from index) + var playerToFish = dealer.players[cardAndPlayerInt[1]]; + + instigateCall(cardToFind, playerToFish, playerTakingTurn); + } + } + + if(!dealer.checkWinCondition()) { + var winnersArray = []; + var winValue = 0; + for (var i = 0; i < dealer.players.length; i++) { + if(dealer.players[i].getNumSets() > winValue) { + winValue = dealer.players[i].getNumSets(); + winnersArray = []; + winnersArray.push(i); + } + else if (dealer.players[i].getNumSets() === winValue) { + winnersArray.push(i); + } + } + + $("#cardContainer").empty(); + for (var i = 0; i < winnersArray.length; i++) { + if(dealer.players[winnersArray[i]].id > 1) { + $("#cardContainer").append("

    OPPONENT " + (dealer.players[winnersArray[i]].id - 1) + " WINS!

    "); + } else { + $("#cardContainer").append("

    YOU WIN!

    "); + } + } + gameActive = false; + } +} + +function instigateCall(cardToFind, playerToFish, playerTakingTurn) { + // Array of index values point to search matches + var matchingValueIndicies = dealer.findCardInPlayer(cardToFind, playerToFish); + + // If no matches + if(matchingValueIndicies.length < 1) { + // If player cannot draw a card because deck is empty + if(!dealer.dealCard(playerTakingTurn)) { + // Skip player, there is nothing else they can do + } + // continue; + } + + // Cards to pass to fishing player + var cardsToPass = playerToFish.removeCards(matchingValueIndicies); + for (var j = 0; j < cardsToPass.length; j++) { + playerTakingTurn.addCard(cardsToPass[j]); + } + + switch (cardToFind) { + case 11: + cardToFind = "Jack"; + break; + case 12: + cardToFind = "Queen"; + break; + case 13: + cardToFind = "King"; + break; + case 1: + cardToFind = "Ace"; + break; + default: + } + + var num = playerToFish.id; + if(!playerTakingTurn.human) { + if(num === 1) { + num = "YOU" + } else { + num = "Opponent " + (playerToFish.id - 1); + } + + if(matchingValueIndicies < 1) { + $(".actionExplain").eq((playerTakingTurn.id - 2)).html("Hunted " + cardToFind + " from " + num + ".
    GO FISH!"); + } else { + $(".actionExplain").eq(playerTakingTurn.id - 2).html("Hunted " + cardToFind + " from " + num + ".
    Gained " + matchingValueIndicies.length + " cards!"); + } + + } else { + num = "Opponent " + (playerToFish.id - 1); + if(matchingValueIndicies < 1) { + $("#playerInfo").html("Hunted " + cardToFind + " from " + num + ". GO FISH!"); + } else { + $("#playerInfo").html("Hunted " + cardToFind + " from " + num + ". Gained " + matchingValueIndicies.length + " cards!"); + } + } +} + +// Get number of players +function requestPlayers() { + do { + var players = prompt("Choose a number of players, between 2 and 7!"); + players = parseInt(players); + } while (players === NaN || players < 2 || players > 7); + return players; +} + +// Manages cards +class Deck { + constructor() { + this.deck = []; + this.initialise(); + this.printDeck(); + } + + // Build and shuffle standard deck of 52 cards + initialise() { + const SUITS_QUANTITY = 4; + const SUIT_SIZE = 13; + + var suits = [4,3,2,1]; + + // Build a sorted deck in suits descending order - S,H,C,D + for(var i = 0; i < SUITS_QUANTITY; i++) { + for(var j = 0; j < SUIT_SIZE; j++) { + + /* + Objects are passed by reference in JS, therefore duplicating the global variable 'card' and editing it edits ALL deriviatives of card. + Thus creating a deck of cards that are ALL THE SAME! + Therefore variable must be instantiated each time. + CAN YOU TELL I SPENT A LONG TIME WORKING THIS OUT?!? + */ + + // Template for each card + var card = {suit: 0, value: 0, image: ""}; + + card.suit = suits[i]; + card.value = (j+1); + // Apply reference to corresponding card image: + // ../images/cardsjpg/card.image.jpg + var imageRef = ""; + switch (card.value) { + case 11: + imageRef += "J"; + break; + case 12: + imageRef += "Q"; + break; + case 13: + imageRef += "K"; + break; + case 1: + imageRef += "A"; + break; + default: + imageRef += String(card.value); + } + + switch (card.suit) { + case 4: + imageRef += "S"; + break; + case 3: + imageRef += "H"; + break; + case 2: + imageRef += "C"; + break; + case 1: + imageRef += "D"; + break; + default: + imageRef += "HELP I DON'T HAVE A SUIT!" + } + card.image = "../images/cardsjpg/" + imageRef + ".jpg"; + this.deck.push(card); + } + } + this.shuffleDeck(); + } + + // Could randomly grab a single card from the deck rather than suffle + // BUT a shuffled deck allows for reusable code in other card games + shuffleDeck() { + + // Shuffles using the Fisher-Yates method, an 'in-place, O(n) algorithm' + var m = this.deck.length, t, i; + + // While there remain elements to shuffle… + while (m) { + + // Pick a remaining element… + i = Math.floor(Math.random() * m--); + + // And swap it with the current element. + t = this.deck[m]; + this.deck[m] = this.deck[i]; + this.deck[i] = t; + } + } + + printDeck() { + $("#deckSize").html(this.deck.length); + } + + getCard() { + var drawnCard = this.deck.pop(); + this.printDeck() + return drawnCard; + } +} + +// Manages interractions between deck and players +class Dealer { + constructor(players) { + // Number of players + this.playerCount = players; + // Array of players + this.players = []; + + // Can't play by yourself + this.MIN_PLAYERS = 2; + // Number of players necessary for 5 cards rather than 7 to be dealt + this.DEAL_THRESHOLD = 4 + // Max 7 players for now (technically 10 can play) + this.MAX_PLAYERS = 7; + + // The deck for this game + this.playDeck = new Deck(); + + this.createPlayers(); + this.dealHands(); + } + + // Create necessary number of player objects + createPlayers () { + // Create player class for each player + $("#opponentContainer").empty(); + for (var i = 0; i < this.playerCount; i++) { + var newPlayer = new Player(); + newPlayer.id = i+1; + if (i === 0) { + newPlayer.setHuman(); + } else { + var opponentNumber = i; + $("#opponentContainer").append("
    \n\n
    Sets:
    \n

    0

    \n
    ==========
    \n
    "); + } + this.players.push(newPlayer); + } + this.playerNum = this.players.length; + } + + // Deal hand of correct size to each player + dealHands () { + var toDeal = 0; + if (this.playerCount >= this.MIN_PLAYERS && this.playerCount < this.DEAL_THRESHOLD) { + toDeal = 7; + } + else if (this.playerCount >= this.DEAL_THRESHOLD && this.playerCount <= this.MAX_PLAYERS) { + toDeal = 5; + } + else { + throw "invalidPlayerNumberException"; + } + + for (var i = 0; i < toDeal; i++) { + for (var j = 0; j < this.players.length; j++) { + this.dealCard(this.players[j]); + } + } + // + // for (var i = 0; i < this.players.length; i++) { + // console.log(this.players[i].getHand()); + // } + } + + // Send a single card from the deck to a player + dealCard (player) { + if(this.playDeck.deck.length < 1) { + return false + } else { + player.addCard(this.getCardFromDeck()); + } + return true; + } + + // TAKE a card value and a player + // RETURN array of matching cards + findCardInPlayer(card, opponent) { + var cardsOfMatchingValue = []; + // For each card in oppenent's hand + for (var i = 0; i < opponent.hand.length; i++) { + // If card value matches value searched for + if(opponent.hand[i].value === card) { + // Add index to cardsOfMatchingValue + cardsOfMatchingValue.push(i); + } + } + return cardsOfMatchingValue; + } + + // Returns a card from the deck + getCardFromDeck() { + return this.playDeck.getCard(); + } + + // Checks if all sets are down + // If true + // Player with most sets wins + checkWinCondition () { + var totalSets = 0; + for (var i = 0; i < this.players.length; i++) { + totalSets += this.players[i].getNumSets(); + } + + if(totalSets === 13) { + return false; + } + return true; + } + + // Returns length of players array + getPlayersLength() { + return this.players.length; + } +} + +// The players +class Player { + constructor () { + // Player id (index 1) + this.id = 0; + // Array of cards in hand + this.hand = []; + // Is this player controlled by a human? + this.human = false; + // An array of the sets a player has + this.sets = []; + // Human controller + this.humanController; + } + + // Add card to hand + addCard (card) { + this.hand.push(card); + this.sortHand(); + this.checkHand(); + } + + // Returns player hand + getHand () { + return this.hand; + } + + setHuman () { + this.human = true; + this.humanController = new Human(this); + } + + // TAKES array of index values for cards to remove + // Removes cards from hand by interating from end to beginning + // This avoids incorrect references after splice + // RETURN the removed cards + removeCards (indexArray) { + var removedCards = []; + for (var i = (indexArray.length - 1); i >= 0; i--) { + + // Capture card in singlecard variable + var singleCard = this.hand[indexArray[i]]; + + // Delete card from array + this.hand.splice(indexArray[i], 1); + + // Push singleCard to removedCards array + removedCards.push(singleCard); + } + + if(this.human) { + this.humanController.populateCardContainer(this.getHand()); + } + + // Checks hand again to ensure there are cards still in hand + this.checkHand(); + return removedCards; + } + + // If hand empty, get card ELSE call a card + takeTurn () { + if(this.human) { + if(this.hand.length < 1) { + return 0; + } else { + return 2; + } + + } else { + if(this.hand.length < 1) { + return 0; + } else { + return 1; + } + } + } + + // Takes: total number of players from Dealer + // Returns: + // A card to find + // An integer value for the player to 'fish' from + callCardAndPlayer (playerTot) { + // Randomly generated values for the player and card value being fished + do { + var rand1 = Math.floor(Math.random() * this.hand.length); + var rand2 = Math.floor(Math.random() * playerTot); + } while (rand2 === this.id-1); + + return [this.hand[rand1], rand2]; + } + + // Organise hand S,H,C,D, value ascending + sortHand () { + this.hand.sort(function (a,b) {return a.value - b.value}); + + if(this.human) { + this.humanController.populateCardContainer(this.getHand()); + } + } + + // Checks this player's hand for any sets + checkHand() { + var currentValue = 0; + var valueCount = 1; + if(this.hand.length < 1 && this.human) { + this.humanController.emptyHand(); + return; + } else if(this.human) { + this.humanController.fullHand(); + } + + // Checks for sets of 4 + for (var i = 0; i < this.hand.length; i++) { + if (this.hand[i].value !== currentValue) { + currentValue = this.hand[i].value; + valueCount = 1; + } else { + valueCount++; + } + + // If 4 matching values are FOUND + // Removes the latest value, and the 3 preceding + // This works because the deck is always sorted + if(valueCount === 4) { + var set = this.hand[i].value; + this.playSet(set); + + // Remove set from hand + this.removeCards([i-3, i-2, i-1, i]); + } + } + } + + // TAKES a complete set + playSet(set) { + this.sets.push(set); + this.updateSetsUI(); + } + + updateSetsUI() { + var setsString = ""; + if(this.human) { + for (var i = 0; i < this.sets.length; i++) { + var toAdd = " |" + this.sets[i] + "s| "; + + switch (this.sets[i]) { + case 11: + toAdd = " |Jacks| "; + break; + case 12: + toAdd = " |Queens| "; + break; + case 13: + toAdd = " |Kings| "; + break; + case 1: + toAdd = " |Aces| "; + break; + default: + } + setsString += toAdd; + } + $('#humanSets').html(setsString); + } else { + for (var i = 0; i < this.sets.length; i++) { + var toAdd = " |" + this.sets[i] + "s| "; + + switch (this.sets[i]) { + case 11: + toAdd = " |Jacks| "; + break; + case 12: + toAdd = " |Queens| "; + break; + case 13: + toAdd = " |Kings| "; + break; + case 1: + toAdd = " |Aces| "; + break; + default: + } + setsString += toAdd; + } + $('#opponentContainer').children("[number=" + (this.id-1) + "]").eq(0).children(".opponentSets").eq(0).html(setsString); + } + } + + getNumSets() { + return this.sets.length; + } + + getSets() { + return this.sets; + } +} + +// Human +class Human { + constructor() { + this.cardContainer; + } + + setCardContainer() { + this.cardContainer = $("#cardContainer"); + } + + populateCardContainer(hand) { + this.clearBoard(); + var cardCount = 0; + for (var i = 0; i < hand.length; i++) { + cardCount++; + this.addCardToContainer(hand[i]); + } + } + + clearBoard() { + var cardContainer = $("#cardContainer").empty(); + } + + addCardToContainer(card) { + $("#cardContainer").append("\"A"); + } + + emptyHand() { + $("#continue").html("Draw Card"); + searchValue = "drawCard"; + searchPlayer = "drawCard"; + } + + fullHand() { + $("#continue").html("Take Turn"); + searchValue = "x"; + searchPlayer = "x"; + } +} + +// Global SFX +class Sounds { + constructor() { + + } +} diff --git a/Games/Go-fish-master/pages/ins.html b/Games/Go-fish-master/pages/ins.html new file mode 100644 index 0000000000..fd6cddab67 --- /dev/null +++ b/Games/Go-fish-master/pages/ins.html @@ -0,0 +1,30 @@ + + + + + Go Fish + + + +
    +

    Let's Play Go Fish!

    + Back +

    The aim of the game is to collect the most 'tricks' or 'sets'.

    +

    To begin, press 'Start Game' and enter the number of players (including yoruself) that you want to play.

    +
    +
      +
    • Each player starts with 7 cards (2/3 players) or 5 cards (4 or more players).
    • +
    • Play runs clockwise, starting with the player to the dealer's left.
    • +
    • During their turn, each player 'goes fishing' by selecting a value of a card in their hand and another player, in the game this is done by clicking a card and an opponent, then clicking 'Take Turn'. If the selected player has any cards of that value the 'fisher' has made a 'catch'. The selected player must give the 'fisher' all their cards of that value. If the selected player has no cards of that value, the selector has not made a 'catch' and must 'Go Fish!' and draws a new card from the deck.
    • +
    • If, during their turn, a player ends up with all 4 cards then they have collected a full set. The player then must immediately declare this and play their set face up, in front of them.
    • +
    • If during play a player ends up with no cards in their hand they must draw a card from the deck, rather than 'going fishing' for cards from other people.
    • +
    • The winner is the player with the most sets at the end.
    • +
    • Once all 13 sets have been completed, play ends.
    • +
    +
    +
    + + +
    + + diff --git a/Games/Go-fish-master/pages/main.html b/Games/Go-fish-master/pages/main.html new file mode 100644 index 0000000000..8afc026a27 --- /dev/null +++ b/Games/Go-fish-master/pages/main.html @@ -0,0 +1,64 @@ + + + + + Go Fish + + + +
    +

    Go Fish!

    + +

    Here is where you will see a breakdown of your last turn

    + + +
    + +
    +

    Your Opponents

    +
    + +
    +
    + +
    +

    Your Cards

    +
    + A card + A card + A card + A card + A card + A card + A card + A card +
    +
    + +
    + + +
    + + diff --git a/Games/Gobblet/README.md b/Games/Gobblet/README.md new file mode 100644 index 0000000000..7f05f5dfd7 --- /dev/null +++ b/Games/Gobblet/README.md @@ -0,0 +1,42 @@ +# Gobblet + +## Description 📃 +Gobblet is a strategic board game where players take +turns placing their pieces on a 5x5 grid. Each player has 3 pieces +of each four different sizes (that makes 12 pieces total), and the objective +is to align five pieces of their color in a row either horizontally, +vertically, or diagonally. Pieces can be placed on top of smaller pieces, +and if a larger piece is moved, the smaller piece underneath it becomes +visible again. + +## Functionalities 🎮 +- **Piece Placement**: Players can select a piece and place it on the board. Pieces can only be placed on empty cells or on top of smaller pieces. +- **Piece Movement**: Players can move their pieces already on the board to another cell. +- **Stacking**: Pieces can stack on top of each other. If the top piece is moved, the piece underneath becomes visible again. +- **Win Condition**: The game checks for a winning condition when five pieces of the same player align in a row. +- **Score Keeping**: The game keeps track of the score, awarding points for each win. +- **Restart Game**: Players can restart the game while keeping the current score. +- **Reset Score**: Players can reset the scores to zero. + +## How to play? 🕹️ +1. **Select a Piece**: Click on one of your available pieces to select it. +2. **Place or Move a Piece**: Click on an empty cell or on top of a smaller piece on the board to place the selected piece. You can also move pieces already on the board. +3. **Win the Game**: Align five of your pieces in a row either horizontally, vertically, or diagonally to win the game and score a point. +4. **Restart or Reset**: Use the "Restart Game" button to start a new game or "Reset Score" to reset the scores to zero. + +## Screenshots 📸 +### Initial Screen +![Initial Screen](images/Gobblet.png) + +### The Board +![Piece Selection](images/GobbletBoard.png) + +### Gameplay +![Piece Selection](images/GobbletGamePlay.png) + +### Winning Condition +![Winning Condition](images/GobbletWin.png) + +### Settings +![Settings](images/GobbletSettings.png) + diff --git a/Games/Gobblet/images/Gobblet.png b/Games/Gobblet/images/Gobblet.png new file mode 100644 index 0000000000..889a303e4a Binary files /dev/null and b/Games/Gobblet/images/Gobblet.png differ diff --git a/Games/Gobblet/images/GobbletBoard.png b/Games/Gobblet/images/GobbletBoard.png new file mode 100644 index 0000000000..ec6be23d50 Binary files /dev/null and b/Games/Gobblet/images/GobbletBoard.png differ diff --git a/Games/Gobblet/images/GobbletGamePlay.png b/Games/Gobblet/images/GobbletGamePlay.png new file mode 100644 index 0000000000..d6567048d4 Binary files /dev/null and b/Games/Gobblet/images/GobbletGamePlay.png differ diff --git a/Games/Gobblet/images/GobbletSettings.png b/Games/Gobblet/images/GobbletSettings.png new file mode 100644 index 0000000000..fdd276e375 Binary files /dev/null and b/Games/Gobblet/images/GobbletSettings.png differ diff --git a/Games/Gobblet/images/GobbletWin.png b/Games/Gobblet/images/GobbletWin.png new file mode 100644 index 0000000000..1c3a2ff8e0 Binary files /dev/null and b/Games/Gobblet/images/GobbletWin.png differ diff --git a/Games/Gobblet/index.html b/Games/Gobblet/index.html new file mode 100644 index 0000000000..5539cf3930 --- /dev/null +++ b/Games/Gobblet/index.html @@ -0,0 +1,74 @@ + + + + + + + Gobblet + + + +
    +
    +

    Welcome to Gobblet!

    + +
    +
    + +
    +

    Gobblet

    +
    +
    +
    +
    +
    +
    +
    +

    Player Red Score: 0

    +

    Player Blue Score: 0

    +
    + + + + + + + + + + + +
    + + + + + + diff --git a/Games/Gobblet/mp3/BLACKPINK - Kill This Love Official Instrumental.mp3 b/Games/Gobblet/mp3/BLACKPINK - Kill This Love Official Instrumental.mp3 new file mode 100644 index 0000000000..c2a01baeb6 Binary files /dev/null and b/Games/Gobblet/mp3/BLACKPINK - Kill This Love Official Instrumental.mp3 differ diff --git a/Games/Gobblet/mp3/munch-sound-effect.mp3 b/Games/Gobblet/mp3/munch-sound-effect.mp3 new file mode 100644 index 0000000000..4ee54b40f1 Binary files /dev/null and b/Games/Gobblet/mp3/munch-sound-effect.mp3 differ diff --git a/Games/Gobblet/script.js b/Games/Gobblet/script.js new file mode 100644 index 0000000000..819dd54e64 --- /dev/null +++ b/Games/Gobblet/script.js @@ -0,0 +1,408 @@ +document.addEventListener("DOMContentLoaded", function() { + const startButton = document.getElementById('startButton'); + const startScreen = document.getElementById('startScreen'); + const board = document.getElementById("board"); + const player1Pieces = document.getElementById("player1-pieces"); + const player2Pieces = document.getElementById("player2-pieces"); + const message = document.getElementById("message"); + const winMessage = document.getElementById("winMessage"); + const score1 = document.getElementById("score1"); + const score2 = document.getElementById("score2"); + const restartGameButton = document.getElementById("restartGame"); + const resetScoreButton = document.getElementById("resetScore"); + const playButton = document.getElementById('playButton'); + const pauseButton = document.getElementById('pauseButton'); + const backgroundMusic = document.getElementById('backgroundMusic'); + const stackSound = document.getElementById('stackSound'); + const autoDim = document.getElementById('autoDim'); + const musicVolume = document.getElementById('musicVolume'); + const effectVolume = document.getElementById('effectVolume'); + const settingsIcon = document.getElementById('settingsIcon'); + const closeButton = document.querySelector('.close'); + + //Player that always begins is Red + let currentPlayer = 1; + //Player 1 is Red + let colorPlayer = "Red"; + //At the beginning no pieces are selected + let selectedPiece = null; + let boardState = new Array(25).fill(null).map(() => []); + let autoDimEnabled = true; + //Variable to control the game state + let gameOver = false; + + //Handle failed attempt to automatically play music on document load + backgroundMusic.play().catch(error => { + console.error("Error!, Automatic playing of the backgroundmusic!", error); + }); + + //Start button for the game + startButton.addEventListener('click', function() { + startScreen.style.display = 'none'; + backgroundMusic.play(); + }); + + //Initialize each cell on the board + for (let i = 0; i < 25; i++) { + let cell = document.createElement("div"); + cell.className = "cell"; + cell.dataset.index = i; + board.appendChild(cell); + //Set up click event listeners + cell.addEventListener('click', function() { + //Prevent interaction if the game is over + if (gameOver) return; + + if (selectedPiece && parseInt(selectedPiece.dataset.player) === currentPlayer && canPlacePiece(cell)) { + placePiece(cell, parseInt(cell.dataset.index)); + } else if (!selectedPiece && cell.querySelector('.piece') && parseInt(cell.querySelector('.piece').dataset.player) === currentPlayer) { + selectPiece(cell.querySelector('.piece'), parseInt(cell.dataset.index)); + } else if (!selectedPiece && boardState[i].length > 0 && parseInt(boardState[i][boardState[i].length - 1].dataset.player) === currentPlayer) { + selectPiece(boardState[i][boardState[i].length - 1], i); + } + }); + } + + //Initialize pieces for both player + function initializePieces() { + [player1Pieces, player2Pieces].forEach((container, index) => { + //Clear previous pieces + container.innerHTML = ''; + const player = index + 1; + [4, 3, 2, 1].forEach(size => { + for (let i = 0; i < 3; i++) { + let piece = document.createElement("div"); + piece.className = `piece piece${size}`; + piece.dataset.size = size; + piece.dataset.player = player; + container.appendChild(piece); + //Attach event listener for selecting pieces + piece.addEventListener('click', function() { + if (parseInt(piece.dataset.player) === currentPlayer && !piece.classList.contains('used')) { + selectPiece(piece); + } + }); + } + }); + }); + } + + //Select or deselect a piece when clicked + function selectPiece(piece, index) { + if (selectedPiece === piece) { + piece.classList.remove('selected'); + selectedPiece = null; + message.textContent = `Player ${colorPlayer}: Select a piece to play or move.`; + return; + } + if (selectedPiece) { + selectedPiece.classList.remove('selected'); + } + + selectedPiece = piece; + selectedPiece.classList.add('selected'); + message.textContent = `Player ${colorPlayer}: Click on the board to place or move it.`; + } + + //Determine if a piece can be placed on a specific cell + function canPlacePiece(cell) { + const topPiece = cell.querySelector('.piece'); + return (!topPiece || (parseInt(selectedPiece.dataset.size) > parseInt(topPiece.dataset.size) && parseInt(selectedPiece.dataset.player) !== parseInt(topPiece.dataset.player))) && !selectedPiece.classList.contains('used'); + } + + //Remove a piece from the pool when it has been placed on the board + function removePieceFromPool(selectedPiece) { + selectedPiece.classList.add('used'); + selectedPiece.style.display = 'none'; + } + + //Place a piece on a cell + function placePiece(cell, index) { + if (selectedPiece.parentNode.classList.contains('cell')) { + removePieceFromCell(selectedPiece.parentNode); + } + + const newPiece = createNewPiece(index); + addPieceToCell(newPiece, cell, index); + removePieceFromPool(selectedPiece); + + selectedPiece = null; + document.querySelectorAll('.selected').forEach(p => p.classList.remove('selected')); + + //check if placing the piece leads to a win + if (checkWin(currentPlayer)) { + gameOver = true; + message.textContent = `Player ${colorPlayer} wins!`; + document.getElementById('winMessage').textContent = `Player ${colorPlayer} wins!`; + showModal(); + updateScore(); + // setTimeout(() => alert(`Player ${colorPlayer} wins!`), 100); + } else { + switchPlayer(); + } + } + + function showModal() { + const modal = document.getElementById('winModal'); + modal.style.display = 'block'; + const closeBtn = modal.querySelector('.close'); + closeBtn.onclick = function() { + modal.style.display = 'none'; + }; + } + + //Remove a piece from a cell when another piece is placed on top of it + function removePieceFromCell(cell) { + const originalIndex = parseInt(selectedPiece.parentNode.dataset.index); + const stack = boardState[originalIndex]; + const removedPiece = stack.pop(); + if (stack.length > 0) { + const underlyingPiece = stack[stack.length - 1]; + const cellUnderlying = document.querySelector(`[data-index="${originalIndex}"]`); + //Clear the cell + cellUnderlying.innerHTML = ''; + //Add the bottom piece back to the cell + cellUnderlying.appendChild(underlyingPiece.cloneNode(true)); + } else { + //Clear the cell + cell.innerHTML = ''; + //Update the board state to indicate the cell is empty + boardState[originalIndex] = []; + } + + checkWinAfterMove(); + } + + function checkWinAfterMove() { + if (checkWin(1)) { + gameOver = true; + winMessage.textContent = `Player Red wins!`; + showModal(); + updateScoreStcks(); + } else if (checkWin(2)) { + gameOver = true; + winMessage.textContent = `Player Blue wins!`; + showModal(); + updateScoreStcks(); + } + } + + function updateScoreStcks() { + if (currentPlayer === 1) { + score2.textContent = parseInt(score2.textContent) + 1; + } else { + score1.textContent = parseInt(score1.textContent) + 1; + } + } + + //Create a new piece based on the selected piece's properties + function createNewPiece(index) { + const newPiece = selectedPiece.cloneNode(true); + newPiece.dataset.index = index; + return newPiece; + } + + //Add a piece to a cell + update the board state + function addPieceToCell(piece, cell, index) { + const topPiece = cell.querySelector('.piece'); + if (topPiece) { + const stack = boardState[index]; + stack.push(piece); + cell.appendChild(piece); + + //Play a sound when a piece is placed on top of another piece + playStackSound(); + } else { + //Clear the cell + cell.innerHTML = ''; + cell.appendChild(piece); + //Update the board state to include the new piece + boardState[index] = [piece]; + } + } + + //Check if the current player has won the game + function checkWin(player) { + const lines = [ + [0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], + [15, 16, 17, 18, 19], [20, 21, 22, 23, 24], + [0, 5, 10, 15, 20], [1, 6, 11, 16, 21], [2, 7, 12, 17, 22], + [3, 8, 13, 18, 23], [4, 9, 14, 19, 24], + [0, 6, 12, 18, 24], [4, 8, 12, 16, 20] + ]; + + return lines.some(line => { + let consecutiveCount = 0; + for (let i = 0; i < line.length; i++) { + const index = line[i]; + const cell = document.querySelector(`.cell[data-index="${index}"]`); + const topPiece = cell.querySelector('.piece:last-child'); + if (topPiece && parseInt(topPiece.dataset.player) === player) { + consecutiveCount++; + if (consecutiveCount === 5) { + //Player wins if they have five consecutive pieces + return true; + } + } else { + consecutiveCount = 0; + } + } + //Return false if no winning line is found + return false; + }); + } + + //Update the score for the current player + function updateScore() { + if (currentPlayer === 1) { + score1.textContent = parseInt(score1.textContent) + 1; + } else { + score2.textContent = parseInt(score2.textContent) + 1; + } + } + + //Switch the current player + function switchPlayer() { + currentPlayer = currentPlayer === 1 ? 2 : 1; + if (currentPlayer == 1) { + colorPlayer = "Red"; + } else { + colorPlayer = "Blue"; + } + //Deselect any selected piece + selectedPiece = null; + document.querySelectorAll('.selected').forEach(p => p.classList.remove('selected')); + message.textContent = `Player ${colorPlayer}: Select a piece to play or move.`; + } + + //Reset the game to its initial state + function resetGame() { + boardState.fill(null).map(() => ({ size: 0, player: null })); + document.querySelectorAll('.cell').forEach(cell => cell.innerHTML = ''); + document.querySelectorAll('.piece').forEach(piece => { + //Restore visibility for new game + piece.style.display = ''; + piece.classList.remove('used'); + piece.classList.remove('selected'); + }); + + gameOver = false; + //Hide the modal on game reset + document.getElementById('winModal').style.display = 'none'; + //Reinitialize pieces + initializePieces(); + currentPlayer = 1; + message.textContent = `Player Red begins.`; + } + + //Reset the score for both players to zero + function resetScore() { + score1.textContent = '0'; + score2.textContent = '0'; + } + + settingsIcon.addEventListener('click', function() { + document.getElementById('settingsModal').style.display = 'block'; + }); + + closeButton.addEventListener('click', function() { + document.getElementById('settingsModal').style.display = 'none'; + }); + + window.onclick = function(event) { + const modal = document.getElementById('settingsModal'); + if (event.target == modal) { + modal.style.display = 'none'; + } + }; + + const backgroundMusicController = (function() { + const musicElement = document.getElementById('backgroundMusic'); + + function play() { + musicElement.play(); + } + + function pause() { + musicElement.pause(); + } + + function setVolume(volumeLevel) { + musicElement.volume = volumeLevel; + } + + return { + play: play, + pause: pause, + setVolume: setVolume + }; + })(); + + function updateMusicVolume(volume) { + backgroundMusic.volume = volume; + } + + function updateEffectVolume(volume) { + stackSound.volume = volume; + } + + function toggleAutoDim(enabled) { + autoDimEnabled = enabled; + } + + function adjustMusicVolumeForStackSound() { + if (!autoDimEnabled) return; + + const originalVolume = backgroundMusic.volume; + //Dim the music to 50% of the original volume when the stack sound plays + backgroundMusic.volume *= 0.5; + stackSound.play(); + + stackSound.onended = function() { + //Restore the original music volume when the stack sound ends + backgroundMusic.volume = originalVolume; + }; + } + + function playStackSound() { + if (autoDimEnabled) { + adjustMusicVolumeForStackSound(); + stackSound.play(); + } else { + //Play the stack sound when a piece is placed on top of another + stackSound.play(); + } + } + + //Set the initial message when the document is loaded + message.textContent = `Player Red begins.`; + //Attach event listener to the restart game button + restartGameButton.addEventListener('click', resetGame); + //Attach event listener to the reset score button + resetScoreButton.addEventListener('click', resetScore); + playButton.addEventListener('click', function() { + //Play the background music when the play button is clicked + backgroundMusicController.play(); + }); + pauseButton.addEventListener('click', function() { + //Pause the background music when the pause button is clicked + backgroundMusicController.pause(); + }); + autoDim.addEventListener('change', function() { + //Toggle the auto dim feature based on the checkbox state + toggleAutoDim(this.checked); + }); + + musicVolume.addEventListener('input', function() { + //Update the music volume as the music volume slider changes + updateMusicVolume(this.value); + }); + + effectVolume.addEventListener('input', function() { + //Update the effect volume as the effect volume slider changes + updateEffectVolume(this.value); + }); + + //Initialize the pieces for both players when the document is loaded + initializePieces(); +}); diff --git a/Games/Gobblet/style.css b/Games/Gobblet/style.css new file mode 100644 index 0000000000..78dada0253 --- /dev/null +++ b/Games/Gobblet/style.css @@ -0,0 +1,242 @@ +body { + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + background-color: rgb(26, 26, 26); + font-family: Arial, sans-serif; +} + +.start-screen { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.8); + display: flex; + justify-content: center; + align-items: center; + z-index: 1000; +} + +.start-content { + text-align: center; + color: white; + padding: 20px; + border-radius: 10px; + background: #333; +} + +#startButton { + padding: 10px 20px; + font-size: 20px; + color: #fff; + background-color: #007BFF; + border: none; + border-radius: 5px; + cursor: pointer; + transition: background-color 0.3s; +} + +#startButton:hover { + background-color: #0056b3; +} + +.container { + text-align: center; + background-color: white; + padding: 40px; + border-radius: 20px; +} + +h1 { + color: #FF6347; + text-align: center; + font-size: 3em; + text-transform: uppercase; + text-shadow: 4px 4px 0px rgba(0, 0, 0, 0.1); + margin: 20px; + +} + +.game-area { + display: flex; + justify-content: center; + align-items: center; +} + +.pieces { + display: flex; + flex-direction: column; + gap: 5px; + margin-left: 20px; +} + +#board { + display: grid; + grid-template-columns: repeat(5, 80px); + grid-template-rows: repeat(5, 80px); + gap: 5px; + margin: 20px; +} + +.cell { + width: 80px; + height: 80px; + background-color: rgb(221, 177, 255); + border-radius: 50%; + border: 2px solid rgb(179, 80, 255); + display: flex; + justify-content: center; + align-items: center; + position: relative; + margin: 10px; + overflow: hidden; +} + +.cell::before { + content: ''; + position: absolute; + top: 10px; + left: 10px; + right: 10px; + bottom: 10px; + border-radius: 50%; +} + +.cell .piece { + position: absolute; + display: flex; + justify-content: center; + align-items: center; +} + +.piece1 { + width: 20px; + height: 20px; + background-color: #ffc8c8; + border-radius: 50%; + border: 3px solid #5ccd00; +} + +.piece2 { + width: 30px; + height: 30px; + background-color: #fd8282; + border-radius: 50%; + border: 3px solid #5ccd00; +} + +.piece3 { + width: 40px; + height: 40px; + background-color: #c43232; + border-radius: 50%; + border: 3px solid #5ccd00; +} + +.piece4 { + width: 50px; + height: 50px; + background-color: #8d0000; + border-radius: 50%; + border: 3px solid #5ccd00; +} + +.piece[data-player="2"].piece1 { + background-color: #ADD8E6; +} + +.piece[data-player="2"].piece2 { + background-color: #87CEEB; +} + +.piece[data-player="2"].piece3 { + background-color: #4682B4; +} + +.piece[data-player="2"].piece4 { + background-color: #0000CD; +} + + +.piece.selected { + border: 3px solid gold; +} + +#message { + margin: 20px 0; + font-size: 1.5em; +} + +#restartGame, +#resetScore, +#playButton, +#pauseButton { + padding: 10px 20px; + font-size: 1em; + cursor: pointer; + margin: 10px; + border-radius: 10px; +} + +#restartGame:hover, +#resetScore:hover, +#playButton:hover, +#pauseButton:hover { + background-color: #dbdbdb; + border: 2px solid gold; +} + +.iconHover:hover { + color: #ff0000; +} + +#scoreboard { + margin: 20px 0; + font-size: 1.2em; +} + +.modal { + display: none; + position: fixed; + left: 0; + top: 0; + width: 100%; + height: 100%; + background-color: rgba(39, 39, 39, 0.4); +} + +.modal-content { + background-color: #fefefe; + margin: 15% auto; + padding: 20px; + border: 3px solid red; + border-radius: 20px; + width: 50%; +} + +.close { + color: #aaa; + float: right; + font-size: 28px; + font-weight: bold; +} + +.close:hover, +.close:focus { + color: red; + text-decoration: none; + cursor: pointer; +} + +/* Keyframes voor de wiggle animatie */ +@keyframes wiggle { + 0%, 100% { + transform: rotate(-1deg) scaleX(-1); + } + 50% { + transform: rotate(1deg) scaleX(-1); + } +} diff --git a/Games/IKnowYou-Mind-Reading-Game/README.md b/Games/IKnowYou-Mind-Reading-Game/README.md new file mode 100644 index 0000000000..6edbc32b54 --- /dev/null +++ b/Games/IKnowYou-Mind-Reading-Game/README.md @@ -0,0 +1,31 @@ +# **IKnowYou - Mind Reading Game** + +--- + +
    + +## **Description 📃** +In "IKnowYou", players are invited to choose a number, which serves as their initial "amount of money." Through a series of interactive steps, the game mirrors everyday financial transactions and social decisions, eventually culminating in the game's ability to read the player's mind with 100% accuracy. + +## **Functionalities 🎮** +- Interactive slides prompt players to engage with hypothetical scenarios involving money and social interactions. +- The game dynamically changes its content based on user responses, guiding them through a sequence of choices. +- A mind reading element at the end of the game reveals the number chosen by the player, showcasing the game's predictive prowess. + +
    + +## **How to play? 🕹️** +- Click on the "Start" button to initiate the game. +- Follow the prompts to imagine a number, treat it as "money," and proceed through each slide by clicking "Next." +- Engage with each scenario presented and respond accordingly. +- Upon reaching the final stage, witness the game's accurate revelation of the initially chosen number. + +
    + +## **Screenshots 📸** + +
    + +![IKnowYou-Mind-Reading-Game](https://github.com/vansh-codes/GameZone/blob/IKnowYou/Games/IKnowYou-Mind-Reading-Game/assets/preview.png) +
    +--- diff --git a/Games/IKnowYou-Mind-Reading-Game/assets/cover.jpeg b/Games/IKnowYou-Mind-Reading-Game/assets/cover.jpeg new file mode 100644 index 0000000000..1262eda37c Binary files /dev/null and b/Games/IKnowYou-Mind-Reading-Game/assets/cover.jpeg differ diff --git a/Games/IKnowYou-Mind-Reading-Game/assets/five.jpeg b/Games/IKnowYou-Mind-Reading-Game/assets/five.jpeg new file mode 100644 index 0000000000..8a5699376d Binary files /dev/null and b/Games/IKnowYou-Mind-Reading-Game/assets/five.jpeg differ diff --git a/Games/IKnowYou-Mind-Reading-Game/assets/four.jpeg b/Games/IKnowYou-Mind-Reading-Game/assets/four.jpeg new file mode 100644 index 0000000000..587c65305f Binary files /dev/null and b/Games/IKnowYou-Mind-Reading-Game/assets/four.jpeg differ diff --git a/Games/IKnowYou-Mind-Reading-Game/assets/one.jpeg b/Games/IKnowYou-Mind-Reading-Game/assets/one.jpeg new file mode 100644 index 0000000000..8a2a4c06e3 Binary files /dev/null and b/Games/IKnowYou-Mind-Reading-Game/assets/one.jpeg differ diff --git a/Games/IKnowYou-Mind-Reading-Game/assets/preview.png b/Games/IKnowYou-Mind-Reading-Game/assets/preview.png new file mode 100644 index 0000000000..2a127b4335 Binary files /dev/null and b/Games/IKnowYou-Mind-Reading-Game/assets/preview.png differ diff --git a/Games/IKnowYou-Mind-Reading-Game/assets/shock.jpeg b/Games/IKnowYou-Mind-Reading-Game/assets/shock.jpeg new file mode 100644 index 0000000000..2acba9f222 Binary files /dev/null and b/Games/IKnowYou-Mind-Reading-Game/assets/shock.jpeg differ diff --git a/Games/IKnowYou-Mind-Reading-Game/assets/three.jpeg b/Games/IKnowYou-Mind-Reading-Game/assets/three.jpeg new file mode 100644 index 0000000000..d805757eb9 Binary files /dev/null and b/Games/IKnowYou-Mind-Reading-Game/assets/three.jpeg differ diff --git a/Games/IKnowYou-Mind-Reading-Game/assets/two.jpeg b/Games/IKnowYou-Mind-Reading-Game/assets/two.jpeg new file mode 100644 index 0000000000..2d310a0a07 Binary files /dev/null and b/Games/IKnowYou-Mind-Reading-Game/assets/two.jpeg differ diff --git a/Games/IKnowYou-Mind-Reading-Game/index.html b/Games/IKnowYou-Mind-Reading-Game/index.html new file mode 100644 index 0000000000..1a3acfdcaa --- /dev/null +++ b/Games/IKnowYou-Mind-Reading-Game/index.html @@ -0,0 +1,63 @@ + + + + + + IKnowYou - Mind Reading Game + + + + +
    + +
    +

    IKnowYou - Mind Reading Game

    + + + +
    +
    + + + + diff --git a/Games/IKnowYou-Mind-Reading-Game/script.js b/Games/IKnowYou-Mind-Reading-Game/script.js new file mode 100644 index 0000000000..df92b9ac39 --- /dev/null +++ b/Games/IKnowYou-Mind-Reading-Game/script.js @@ -0,0 +1,72 @@ +document.getElementById('start-btn').addEventListener('click', startGame); + +const slides = document.querySelectorAll('.slide'); +const slideImages = [ + 'assets/one.jpeg', // Image for slide 1 + 'assets/two.jpeg', // Image for slide 2 + 'assets/three.jpeg', // Image for slide 3 + 'assets/four.jpeg', // Image for slide 4 + 'assets/five.jpeg', // Image for slide 5 + 'assets/shock.jpeg' // Image for slide 6 +]; +let currentSlide = 0; + +document.querySelectorAll('.next-btn').forEach(btn => { + btn.addEventListener('click', () => { + nextSlide(); + }); +}); + +document.getElementById('show-result').addEventListener('click', () => { + // Proceed to guessing game + document.getElementById('questions').classList.add('hidden'); + document.getElementById('game').classList.remove('hidden'); +}); + +const money = [100,150,200,250,300,250,400,450,500,550,600]; + +const myMoney = document.getElementById('myMoney'); +const randomIndex = Math.floor(Math.random() * money.length); +myMoney.textContent = money[randomIndex]; + +const myGuess = [50,75,100,125,150,175,200,225,250,275,300]; +document.getElementById('guess').textContent = myGuess[randomIndex]; + + +function startGame() { + currentSlide = 0; + showSlide(currentSlide); + document.getElementById('start-btn').classList.add('hidden'); + document.getElementById('questions').classList.remove('hidden'); +} + +function showSlide(index) { + const slideImageElement = document.getElementById('slide-image'); + console.log("index: ", index); + if(index==6){ + console.log("index1: ", index); + slideImageElement.src = 'assets/cover.jpeg'; + } + slides.forEach((slide, i) => { + slide.classList.toggle('hidden', i !== index); + }); + if(index<6){ + console.log("indexif: ", index); + slideImageElement.src = slideImages[index]; + } +} + +function nextSlide() { + currentSlide++; + // if (currentSlide < (slides.length+1)) { + showSlide(currentSlide); + // } +} + +const reset = document.getElementById('reset-btn').addEventListener('click', resetGame); + +function resetGame() { + // currentSlide= 0; + document.getElementById('start-btn').classList.remove('hidden'); + document.getElementById('game').classList.add('hidden'); +} \ No newline at end of file diff --git a/Games/IKnowYou-Mind-Reading-Game/style.css b/Games/IKnowYou-Mind-Reading-Game/style.css new file mode 100644 index 0000000000..112442aae3 --- /dev/null +++ b/Games/IKnowYou-Mind-Reading-Game/style.css @@ -0,0 +1,83 @@ +body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + margin: 0; + background: linear-gradient(to right, #83a4d4, #b6fbff); +} + +.game-wrapper { + width: 85vw; + display: flex; + align-items: center; + /* border: 2px solid black; */ +} + +#slide-image { + justify-content: flex-start; + width: 400px; + height: 300px; + margin-right: 60px; + +} + +.container { + text-align: center; + background: white; + padding: 20px; + border-radius: 8px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); +} + +#start-btn{ + border-radius: 25px; + outline: none; + background-color:rgb(174, 238, 238); + cursor: pointer; +} + +#start-btn:hover{ + background-color: rgb(128, 235, 235); + border: 4px solid rgb(55, 55, 229); +} + +h1 { + font-size: 24px; + color: #2c3e50; +} + +button { + margin: 10px; + padding: 10px 20px; + font-size: 16px; + cursor: pointer; +} + + +.hidden { + display: none; +} + +.slide { + margin: 20px 20px; +} + +#questions { + margin-top: 20px; +} + +.footer{ + position: fixed; + bottom: 0; + background-color: rgb(73, 182, 255); + height: 30px; + padding-top: 8px; + width: 100vw; + text-align: center; +} + +.footer>a:hover{ + color: rgb(21, 8, 209); +} \ No newline at end of file diff --git a/Games/Mamba_Mayhem/README.md b/Games/Mamba_Mayhem/README.md new file mode 100644 index 0000000000..3f8edb86c9 --- /dev/null +++ b/Games/Mamba_Mayhem/README.md @@ -0,0 +1,30 @@ +# **Mamba Mayhem** + +--- + +
    + +## **Description 📃** +The Snake Game is a classic game where the player maneuvers a line (the snake) which grows in length, with the line itself being a primary obstacle. + +
    + +## **Functionalities 🎮** +- The game uses the arrow keys for navigation. +- The snake grows in length when it consumes the food that randomly appears. +- The game ends when the snake hits the game wall or its own body. + +
    + +## **How to play? 🕹️** +- Use the arrow keys to navigate the snake. +- Try to consume the food that appears randomly. +- Avoid hitting the game wall or the snake's own body. + +
    + +## **Screenshots 📸** + +![image](./assets/images/Mamba_Mayhem.png) + +
    diff --git a/Games/Mamba_Mayhem/assets/images/Mamba_Mayhem.png b/Games/Mamba_Mayhem/assets/images/Mamba_Mayhem.png new file mode 100644 index 0000000000..30340ca1ee Binary files /dev/null and b/Games/Mamba_Mayhem/assets/images/Mamba_Mayhem.png differ diff --git a/Games/Mamba_Mayhem/assets/images/game_img1.png b/Games/Mamba_Mayhem/assets/images/game_img1.png new file mode 100644 index 0000000000..d5e22de36c Binary files /dev/null and b/Games/Mamba_Mayhem/assets/images/game_img1.png differ diff --git a/Games/Mamba_Mayhem/index.html b/Games/Mamba_Mayhem/index.html new file mode 100644 index 0000000000..2c796f827f --- /dev/null +++ b/Games/Mamba_Mayhem/index.html @@ -0,0 +1,28 @@ + + + + + + Snake Game + + + + + + + +
    +

    000

    +

    000

    +
    +
    +
    +
    +
    +
    +

    Press Spacebar to START

    + + diff --git a/Games/Mamba_Mayhem/main.js b/Games/Mamba_Mayhem/main.js new file mode 100644 index 0000000000..545225ceeb --- /dev/null +++ b/Games/Mamba_Mayhem/main.js @@ -0,0 +1,189 @@ +// Defining HTML element +const board = document.getElementById("mainBoard"); +const text = document.getElementById("text"); +const score = document.getElementById("currentScore"); +const highScore = document.getElementById("highScore"); + +const generateRandomPosition = () => { + const x = Math.floor(Math.random() * 40) + 1; + const y = Math.floor(Math.random() * 40) + 1; + return { x, y }; +}; + +//Define game variables +let snake = [{ x: 20, y: 20 }]; +let food = generateRandomPosition(); +let direction = "right"; +let gameInterval; +let gameSpeedDelay = 250; +let gameStarted = false; + +// Draw game map, snake, food +const draw = () => { + board.innerHTML = ""; + drawSnake(); + drawFood(); +}; + +//draw snake +const drawSnake = () => { + snake.forEach((segment) => { + const snakeElement = createGameElement("div", "snake"); + setPosition(snakeElement, segment); + board.appendChild(snakeElement); + }); +}; + +//create snake or food cube or div +const createGameElement = (tag, className) => { + const element = document.createElement(tag); + element.className = className; + return element; +}; + +//set position of snake or food +const setPosition = (element, position) => { + element.style.gridColumn = position.x; + element.style.gridRow = position.y; +}; + +// draw food function +const drawFood = () => { + const foodElement = createGameElement("div", "food"); + setPosition(foodElement, food); + board.appendChild(foodElement); +}; + +const move = () => { + const head = { ...snake[0] }; + switch (direction) { + case "right": + head.x++; + + break; + case "up": + head.y--; + + break; + case "left": + head.x--; + + break; + case "down": + head.y++; + + break; + + default: + break; + } + snake.unshift(head); + if (head.x === food.x && head.y === food.y) { + food = generateRandomPosition(); + updateScore(); + clearInterval(gameInterval); //clear interval + gameInterval = setInterval(() => { + move(); + checkCollision(); + draw(); + }, gameSpeedDelay); + } else { + snake.pop(); + } +}; + +//start game +const startGame = () => { + gameStarted = true; + text.style.display = "none"; + gameInterval = setInterval(() => { + move(); + checkCollision(); + draw(); + }, gameSpeedDelay); +}; + +//keypress listener +const handleKeyPress = (event) => { + if ( + (!gameStarted && event.code === "Space") || + (!gameStarted && event.key === " ") + ) { + startGame(); + } else { + switch (event.key) { + case "ArrowUp": + direction = "up"; + break; + + case "ArrowDown": + direction = "down"; + break; + + case "ArrowLeft": + direction = "left"; + break; + + case "ArrowRight": + direction = "right"; + break; + + default: + break; + } + } +}; + +document.addEventListener("keydown", handleKeyPress); + +const checkCollision = () => { + const head = snake[0]; + + if (head.x < 1 || head.x > 40 || head.y < 1 || head.y > 40) { + console.log(`Event: Border collision`); + resetGame(); + } + + for (let i = 1; i < snake.length; i++) { + if (head.x === snake[i].x && head.y === snake[i].y) { + console.log(`Event: Snake collision`); + resetGame(); + updateScore(); + } + } +}; + +const resetGame = () => { + let foodElement = document.getElementById("food"); + let snakeElement = document.getElementById("snake"); + const currentScore = snake.length - 1; + if (currentScore > parseInt(highScore.textContent)) { + updateHighScore(); + } + snake = [{ x: 20, y: 20 }]; + food = generateRandomPosition(); + direction = "right"; + gameSpeedDelay = 250; + gameStarted = false; + text.style.display = "block"; + board.innerHTML = ""; + clearTimeout(gameInterval); + if (foodElement) { + board.removeChild(foodElement); + } + if (snakeElement) { + board.removeChild(snakeElement); + } + score.textContent = currentScore.toString().padStart(3, "0"); + updateScore(); +}; + +const updateScore = () => { + const currentScore = snake.length - 1; + score.textContent = currentScore.toString().padStart(3, "0"); +}; + +const updateHighScore = () => { + const currentScore = snake.length - 1; + highScore.textContent = currentScore.toString().padStart(3, "0"); +}; diff --git a/Games/Mamba_Mayhem/style.css b/Games/Mamba_Mayhem/style.css new file mode 100644 index 0000000000..9dec4204bd --- /dev/null +++ b/Games/Mamba_Mayhem/style.css @@ -0,0 +1,54 @@ +* { + padding: 0; + margin: 0; + box-sizing: border-box; +} + +.scoreBoard { + display: flex; + justify-content: space-between; + width: 50%; +} + +#currentScore, +#highScore { + color: rgb(173, 216, 144); +} + +body { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + height: 100vh; + font-family: "Pixelify Sans", sans-serif; + background-color: rgb(83, 83, 83); +} + +.snake { + background-color: rgb(173, 216, 144); +} + +.food{ + background-color: black; +} + +#mainBoard { + border: 5px solid rgb(140, 175, 116); + border-radius: 15px; + display: grid; + grid-template-columns: repeat(40, 10px); + grid-template-rows: repeat(40, 10px); + margin: 10px; +} + +.board { + border-radius: 30px; + border: 10px solid rgb(140, 175, 116); + background-color: rgb(49, 56, 40); +} + +#text { + position: absolute; + color: rgb(140, 175, 116); +} diff --git a/Games/Mario Matching Game/01.jpg b/Games/Mario Matching Game/01.jpg new file mode 100644 index 0000000000..51c56edd3d Binary files /dev/null and b/Games/Mario Matching Game/01.jpg differ diff --git a/Games/Mario Matching Game/02.jpg b/Games/Mario Matching Game/02.jpg new file mode 100644 index 0000000000..db8ce9cc8e Binary files /dev/null and b/Games/Mario Matching Game/02.jpg differ diff --git a/Games/Mario Matching Game/03.jpg b/Games/Mario Matching Game/03.jpg new file mode 100644 index 0000000000..97cd791cf2 Binary files /dev/null and b/Games/Mario Matching Game/03.jpg differ diff --git a/Games/Mario Matching Game/Readme.md b/Games/Mario Matching Game/Readme.md new file mode 100644 index 0000000000..3c80472ede --- /dev/null +++ b/Games/Mario Matching Game/Readme.md @@ -0,0 +1,23 @@ +# Mario Matching Game + +Welcome to the Mario Matching Game! This game challenges players to match three identical images within a specified time limit. + +## Image + +![image](https://github.com/dpvasani/Mario-Matching-Game/assets/109815626/fde14fbe-05fc-4231-9d26-ec8e975a633d) + + +## Gameplay + +- The game board consists of multiple tiles, each containing an image. + +## Features + +- Reset Button: Start a new game round by resetting the board and timer. + +## Technologies Used + +- HTML +- CSS +- JavaScript + diff --git a/Games/Mario Matching Game/index.html b/Games/Mario Matching Game/index.html new file mode 100644 index 0000000000..5ab2a96528 --- /dev/null +++ b/Games/Mario Matching Game/index.html @@ -0,0 +1,34 @@ + + + + + + + + + + + Game + + +

    Mario Matching Game

    +
    + + + +
    + + + + diff --git a/Games/Mario Matching Game/script.js b/Games/Mario Matching Game/script.js new file mode 100644 index 0000000000..6ebc1da48d --- /dev/null +++ b/Games/Mario Matching Game/script.js @@ -0,0 +1,30 @@ +let chk1 = document.querySelector('#chk1'); +let chk2 = document.querySelector('#chk2'); +let chk3 = document.querySelector('#chk3'); +let reset = document.querySelector('.reset'); +chk1.onclick = function(){ + if(chk1.checked === true){ + chk1.disabled = 'true' + } +} +chk2.onclick = function(){ + if(chk2.checked === true){ + chk2.disabled = 'true' + } +} +chk3.onclick = function(){ + if(chk3.checked === true){ + chk3.disabled = 'true' + } +} + +reset.onclick = function(){ + chk1.disabled = false + chk1.checked = false + + chk2.disabled = false + chk2.checked = false + + chk3.disabled = false + chk3.checked = false +} \ No newline at end of file diff --git a/Games/Mario Matching Game/style.css b/Games/Mario Matching Game/style.css new file mode 100644 index 0000000000..6edfd681d5 --- /dev/null +++ b/Games/Mario Matching Game/style.css @@ -0,0 +1,119 @@ +@font-face { + font-family: 'New Super Mario Font U', sans-serif; + src: url(https://fonts.cdnfonts.com/css/new-super-mario-font-u); +} + +* { + margin: 0; + padding: 0; + font-family: 'New Super Mario Font U', sans-serif; + box-sizing: border-box; +} + +body +{ + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + +} +h2 +{ + padding: 1rem; + text-align: center ; + margin-bottom: 3rem; + font-size: 2.5em; +} +.box +{ + position: relative; + width: 600px; + height: 200px; + border: 1px solid #888888; + box-shadow: 5px 10px #888888; + display: flex; + flex-wrap: wrap; + flex-direction: column; + align-items: center; + justify-content: center; +} +.box label +{ + position: relative; + width: 100%; + height: 33.333%; + border: 1px solid black; + border-bottom: none; +} + +.box label input { + position: relative; + appearance: none; + z-index: 10; +} + +.box label i{ + position:absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-size: 600px; +} + +.box label:nth-child(1) i { + background-image: url(01.jpg); + animation: animate 0.5s steps(3) infinite; +} +.box label:nth-child(2) i { + background-image: url(02.jpg); + animation: animate 0.4s steps(3) infinite; +} +.box label:nth-child(3) i { + background-image: url(03.jpg); + animation: animate 0.7s steps(3) infinite; +} + +@keyframes animate{ + 0% + { + background-position: 0px; + } + 100% + { + background-position: 600px; + } +} + +.box label input:checked ~ i { + animation-play-state: paused; +} + +.reset{ + margin-top: 3rem; + padding: 1rem; + font-size: large; + letter-spacing: 5px; + background-color: rgba(44, 40, 40, 0.897); + color: rgb(255, 255, 255); + border: none; + font-weight: 700; +} + +.reset:active +{ + background: rgba(250, 112, 102, 0.89); + transform: scale(0.95); +} + +@media screen and (max-width:600px) { + .box { + width: 300px; + height: 100px; + } + .box label i{ + background-size: 300px; + } +} \ No newline at end of file diff --git a/Games/Master_Typing/index.html b/Games/Master_Typing/index.html index aa978e259f..6a13c49bcb 100644 --- a/Games/Master_Typing/index.html +++ b/Games/Master_Typing/index.html @@ -12,18 +12,16 @@
    -
    - +

    MASTER TYPING


    - diff --git a/Games/Master_Typing/rules.html b/Games/Master_Typing/rules.html index b89f21a79a..f6303bbce9 100644 --- a/Games/Master_Typing/rules.html +++ b/Games/Master_Typing/rules.html @@ -4,20 +4,25 @@ - Document + Master Typing | Instructions - back +
    + + + + + back

    INSTRUCTIONS

    -

    This is a typing test which allows you test your typing skills

    -

    Click on the popped up key to start the test

    -

    The test limit is 60 seconds

    -

    A result will be generated after completion of test

    +

    ◘ This is a typing test which allows you test your typing skills

    +

    ◘ Click on the popped up key to start the test

    +

    ◘ The test limit is 60 seconds

    +

    ◘ A result will be generated after completion of test


    diff --git a/Games/Master_Typing/script.js b/Games/Master_Typing/script.js index de87dd72ae..61992f8adb 100644 --- a/Games/Master_Typing/script.js +++ b/Games/Master_Typing/script.js @@ -1,14 +1,14 @@ const keys = [..."ABCDEFGHIJKLMNOPQRSTUVWXYZ"]; -let wrongKeyTracker=[]; +let wrongKeyTracker = []; const timestamps = []; let wrongKey; -const wrongTeller=document.querySelector(".wrTeller"); +const wrongTeller = document.querySelector(".wrTeller"); console.log(wrongTeller.innerText); //Declear the variables for counting total entry and correct entry let totalEntry = 0; let correctEntry = 0; -for(let i=0;i<26;i++){ - wrongKeyTracker[i]=0; +for (let i = 0; i < 26; i++) { + wrongKeyTracker[i] = 0; } timestamps.unshift(getTimestamp()); @@ -22,12 +22,11 @@ function getRandomKey() { return keys[getRandomNumber(0, keys.length - 1)]; } -let lastPopUpkey=null; +let lastPopUpkey = null; function targetRandomKey() { const key = document.getElementById(getRandomKey()); key.classList.add("selected"); - lastPopUpkey=key; - + lastPopUpkey = key; } // Function to unselect the last popped-up key function unselectLastPopUpKey() { @@ -39,9 +38,9 @@ function unselectLastPopUpKey() { function getTimestamp() { return Math.floor(Date.now() / 1000); } -const totKey=document.querySelector(".TotScore"); -const wrKey=document.querySelector(".wrScore"); -const corKey=document.querySelector(".corScore"); +const totKey = document.querySelector(".TotScore"); +const wrKey = document.querySelector(".wrScore"); +const corKey = document.querySelector(".corScore"); document.addEventListener("keyup", (event) => { const keyPressed = String.fromCharCode(event.keyCode); const keyElement = document.getElementById(keyPressed); @@ -49,10 +48,10 @@ document.addEventListener("keyup", (event) => { //counting the total entry totalEntry++; - totKey.textContent="Key pressed :"+totalEntry; - // Add sound - const audio = new Audio("assets/Right_Press.mp3"); - audio.play(); + totKey.textContent = "Key pressed :" + totalEntry; + // Add sound + const audio = new Audio("assets/Right_Press.mp3"); + audio.play(); keyElement.classList.add("hit"); keyElement.addEventListener("animationend", () => { @@ -62,8 +61,8 @@ document.addEventListener("keyup", (event) => { if (keyPressed === highlightedKey.innerHTML) { //counting the correct entry correctEntry++; - - corKey.innerText="Correct: "+correctEntry; + + corKey.innerText = "Correct: " + correctEntry; // // Add right sound // const audio = new Audio("assets/Right_Press.mp3"); @@ -78,10 +77,9 @@ document.addEventListener("keyup", (event) => { highlightedKey.classList.remove("selected"); targetRandomKey(); - } - else{ - wrongKeyTracker[(highlightedKey.innerHTML).charCodeAt(0)-65]++; - wrKey.innerText="Incorrect: "+(totalEntry-correctEntry); + } else { + wrongKeyTracker[highlightedKey.innerHTML.charCodeAt(0) - 65]++; + wrKey.innerText = "Incorrect: " + (totalEntry - correctEntry); } // else { // // Add wrong sound @@ -90,8 +88,6 @@ document.addEventListener("keyup", (event) => { // } }); - - // ---------------------For the Timer-------------------------------- var timerElement = document.getElementById("timer"); @@ -99,12 +95,11 @@ var intervalId; var secondsLeft = 60; function startTimer() { - const startButton = document.querySelector("button:nth-of-type(1)"); - + targetRandomKey(); // Disable the start button - startButton.disabled = true; + startButton.disabled = true; // Reset the counts entries totalEntry = 0; @@ -118,7 +113,7 @@ function startTimer() { if (secondsLeft === 10) { showCountdownMessage(); // Show custom alert message } - + if (secondsLeft < 0) { //call assessment function for review result assessment(); @@ -136,26 +131,24 @@ function restartTimer() { secondsLeft = 60; timerElement.textContent = "00:00"; - unselectLastPopUpKey(); - + unselectLastPopUpKey(); //set all the counter to 0 - totKey.innerText="Total Key Pressed: 0"; - corKey.innerText="Correct: 0"; - wrKey.innerText="Incorrect: 0"; - wrongTeller.innerHTML=" "; + totKey.innerText = "Total Key Pressed: 0"; + corKey.innerText = "Correct: 0"; + wrKey.innerText = "Incorrect: 0"; + wrongTeller.innerHTML = " "; //remove the mark from key which was pressed wrong most amount of time - if(wrongKey!=null&&wrongKey.classList.contains("wrongSelection")) - wrongKey.classList.remove("wrongSelection"); - totalEntry=0; - correctEntry=0; - for(let i=0;i<26;i++){ - wrongKeyTracker[i]=0; + if (wrongKey != null && wrongKey.classList.contains("wrongSelection")) + wrongKey.classList.remove("wrongSelection"); + totalEntry = 0; + correctEntry = 0; + for (let i = 0; i < 26; i++) { + wrongKeyTracker[i] = 0; } // Enable the start button document.querySelector("button:nth-of-type(1)").disabled = false; - } function padNumber(number) { @@ -191,18 +184,20 @@ function assessment() { // Update the timerElement with the result content timerElement.innerHTML = "00:00"; let mostIncorrectKey; - let micval=0;//mostIncorrectKeyValue - for(let i=0;i<26;i++){ - if(micval0){ - wrongKey=document.getElementById(String.fromCharCode(mostIncorrectKey)); + if (micval > 0) { + wrongKey = document.getElementById(String.fromCharCode(mostIncorrectKey)); wrongKey.classList.add("wrongSelection"); - wrongTeller.innerText="The Key which need most Practice is "+String.fromCharCode(mostIncorrectKey); + wrongTeller.innerText = + "The Key which need most Practice is " + + String.fromCharCode(mostIncorrectKey); } } @@ -292,4 +287,4 @@ document.addEventListener("DOMContentLoaded", () => { // Set timeout for game completion after 60 seconds setTimeout(onGameCompleted, 67000); -}); \ No newline at end of file +}); diff --git a/Games/Master_Typing/style.css b/Games/Master_Typing/style.css index 4312cd5e4c..7dad24c2b8 100644 --- a/Games/Master_Typing/style.css +++ b/Games/Master_Typing/style.css @@ -1,5 +1,10 @@ body { - background: linear-gradient(90deg, rgba(0,194,32,1) 0%, rgba(113,77,231,1) 0%, rgba(93,220,255,1) 72%); + background: linear-gradient( + 90deg, + rgba(0, 194, 32, 1) 0%, + rgba(113, 77, 231, 1) 0%, + rgba(93, 220, 255, 1) 72% + ); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-weight: 500; display: flex; @@ -11,7 +16,7 @@ body { display: flex; justify-content: space-around; width: 70vw; - margin-bottom: 3%; + margin-bottom: 40px; } .details_div > div { @@ -26,18 +31,43 @@ body { box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); text-align: center; } - +.Back-button { + display: flex; + align-items: center; + justify-content: center; + gap: 10px; + /* background-color: rgba(255, 255, 255, 0.8); */ + border-radius: 15px; + padding: 20px; + width: 100px; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); + text-align: center; + cursor: pointer; + margin-bottom: 20px; + color: white; +} +.Back-button:hover { + transform: scale(1.05); + transition: 0.2s ease all; +} .home_btn i { font-size: 2em; /* color: white; */ } +.home_btn { + cursor: pointer; +} +.home_btn:hover { + transform: scale(1.05); + transition: 0.2s ease all; +} .load { background-color: rgba(113, 77, 231, 1); } .load h1 { - font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif; + font-family: "Gill Sans", "Gill Sans MT", Calibri, "Trebuchet MS", sans-serif; font-size: 1.5em; color: white; } @@ -52,97 +82,110 @@ body { .menu { /* background-color: white; */ - color: #202639; + color: #181818; padding: 10px; + cursor: pointer; /* border: 2px solid #202639; border-radius: 10px; */ - font-size: medium; + font-size: 20px; } +.menu:hover { + transform: scale(1.05); + transition: 0.2s ease all; +} + +.container1 { + background-color: rgba(75, 26, 26, 0.942); -.container1{ - - background-color:rgba(75, 26, 26, 0.942); - - padding:50px 50px 50px 50px; + padding: 50px 50px 50px 50px; border-radius: 30px; } -.container1 .rules article{ - - padding:10px 10px 10px 10px; +.container1 .rules article { + padding: 30px; border-radius: 30px; background-color: burlywood; } -.navbar{ +.navbar { margin-left: auto; } -.h2{ +.h2 { font-size: 15px; text-align: center; background-color: red; font-family: "cursive"; } -html{ +html { scroll-behavior: auto; } -.namesa{ +.namesa { font-style: italic; } -#maina{ - display:flex; +#maina { + display: flex; } -#maina div{ - display:inline-block; +#maina div { + display: inline-block; } .instructions { background-color: black; - height:400px; - width:500px; + height: 400px; + width: 500px; margin-right: auto; - display:flex; + display: flex; flex-direction: column; } -.instructions article{ - display:flex; - width:80%; +.instructions article { + display: flex; + width: 80%; background-color: blue; - margin-left:auto; - margin-right:auto; - margin-top:auto; - margin-bottom:auto; + margin-left: auto; + margin-right: auto; + margin-top: auto; + margin-bottom: auto; border-radius: 60px; flex-direction: column; - } -.instructions article h1{ - margin-left:auto; - margin-right:auto; +.instructions article h1 { + margin-left: auto; + margin-right: auto; } - -.container{ - background-image: linear-gradient(to left, #3f4c77, #3c4871, #39446b, #364165, #333d5f, #303a5a, #2e3654, #2b334f, #283049, #252c44, #23293e, #202639); - box-shadow: rgba(0, 0, 0, 0.25) 0px 54px 55px, rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px, rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px; - padding-right: 60px; - padding-left: 30px; +.container { + background-image: linear-gradient( + to left, + #3f4c77, + #3c4871, + #39446b, + #364165, + #333d5f, + #303a5a, + #2e3654, + #2b334f, + #283049, + #252c44, + #23293e, + #202639 + ); + box-shadow: rgba(0, 0, 0, 0.25) 0px 54px 55px, + rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px, + rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px; + padding: 40px; border-radius: 10px; display: flex; flex-direction: column; - align-items:center; - + align-items: center; } .title { color: mintcream; text-transform: uppercase; - margin-top: 10em; - margin-bottom: 3em; font-size: 1em; letter-spacing: 0.3em; } -.timer{ - color:mintcream; +.timer { + color: mintcream; margin-top: 1em; margin-bottom: 1em; font-size: 25px; @@ -259,7 +302,7 @@ button { li { height: 3em; width: 3em; - color: rgba(0,0,0,0.7); + color: rgba(0, 0, 0, 0.7); border-radius: 0.4em; line-height: 3em; letter-spacing: 1px; @@ -293,7 +336,7 @@ li { width: 5em; } -.pinky { +.pinky { background-color: crimson; border: 2px solid crimson; } @@ -301,7 +344,7 @@ li { color: crimson; } -.ring { +.ring { background-color: coral; border: 2px solid coral; } @@ -309,7 +352,7 @@ li { color: coral; } -.middle { +.middle { background-color: darkorange; border: 2px solid darkorange; } @@ -317,7 +360,7 @@ li { color: darkorange; } -.pointer1st { +.pointer1st { background-color: gold; border: 2px solid gold; } @@ -325,7 +368,7 @@ li { color: gold; } -.pointer2nd { +.pointer2nd { background-color: khaki; border: 2px solid khaki; } @@ -340,12 +383,12 @@ li { .selected { background-color: transparent; - -webkit-animation: vibrate-1 0.3s linear infinite both; - animation: vibrate-1 0.3s linear infinite both; + -webkit-animation: vibrate-1 0.3s linear infinite both; + animation: vibrate-1 0.3s linear infinite both; } -.wrongSelection{ - background-color: red ; - border:5px solid black; +.wrongSelection { + background-color: red; + border: 5px solid black; } /* ---------------------------------------------- @@ -356,159 +399,157 @@ li { * ---------------------------------------------- */ .hit { - -webkit-animation: hit 0.3s cubic-bezier(0.390, 0.575, 0.565, 1.000) both; - animation: hit 0.3s cubic-bezier(0.390, 0.575, 0.565, 1.000) both; + -webkit-animation: hit 0.3s cubic-bezier(0.39, 0.575, 0.565, 1) both; + animation: hit 0.3s cubic-bezier(0.39, 0.575, 0.565, 1) both; } @-webkit-keyframes hit { 0% { -webkit-transform: scale(1.2); - transform: scale(1.2); + transform: scale(1.2); } 100% { -webkit-transform: scale(1); - transform: scale(1); + transform: scale(1); } } @keyframes hit { 0% { -webkit-transform: scale(1.2); - transform: scale(1.2); + transform: scale(1.2); } 100% { -webkit-transform: scale(1); - transform: scale(1); + transform: scale(1); } } @-webkit-keyframes vibrate-1 { 0% { -webkit-transform: translate(0); - transform: translate(0); + transform: translate(0); } 20% { -webkit-transform: translate(-2px, 2px); - transform: translate(-2px, 2px); + transform: translate(-2px, 2px); } 40% { -webkit-transform: translate(-2px, -2px); - transform: translate(-2px, -2px); + transform: translate(-2px, -2px); } 60% { -webkit-transform: translate(2px, 2px); - transform: translate(2px, 2px); + transform: translate(2px, 2px); } 80% { -webkit-transform: translate(2px, -2px); - transform: translate(2px, -2px); + transform: translate(2px, -2px); } 100% { -webkit-transform: translate(0); - transform: translate(0); + transform: translate(0); } } @keyframes vibrate-1 { 0% { -webkit-transform: translate(0); - transform: translate(0); + transform: translate(0); } 20% { -webkit-transform: translate(-2px, 2px); - transform: translate(-2px, 2px); + transform: translate(-2px, 2px); } 40% { -webkit-transform: translate(-2px, -2px); - transform: translate(-2px, -2px); + transform: translate(-2px, -2px); } 60% { -webkit-transform: translate(2px, 2px); - transform: translate(2px, 2px); + transform: translate(2px, 2px); } 80% { -webkit-transform: translate(2px, -2px); - transform: translate(2px, -2px); + transform: translate(2px, -2px); } 100% { -webkit-transform: translate(0); - transform: translate(0); + transform: translate(0); } } /* ------------for button----------------------------- */ -.btn{ -margin-top: 10px; -margin-bottom: 30px; -padding-left: 60px; -text-align: center; -display: flex; -justify-content: space-between; +.btn { + margin-top: 10px; + padding-left: 60px; + text-align: center; + display: flex; + justify-content: space-between; } .button { -align-items: center; -appearance: none; -margin-right: 30px; -background-color: #FCFCFD; -border-radius: 4px; -border-width: 0; -box-shadow: rgba(45, 35, 66, 0.4) 0 2px 4px,rgba(45, 35, 66, 0.3) 0 7px 13px -3px,#D6D6E7 0 -3px 0 inset; -box-sizing: border-box; -color: #36395A; -cursor: pointer; -display: inline-flex; -font-family: "JetBrains Mono",monospace; -height: 48px; -justify-content: center; -line-height: 1; -list-style: none; -overflow: hidden; -padding-left: 16px; -padding-right: 16px; -position: relative; -text-align: left; -text-decoration: none; -transition: box-shadow .15s,transform .15s; -user-select: none; --webkit-user-select: none; -touch-action: manipulation; -white-space: nowrap; -will-change: box-shadow,transform; -font-size: 18px; + align-items: center; + appearance: none; + margin-right: 30px; + background-color: #fcfcfd; + border-radius: 4px; + border-width: 0; + box-shadow: rgba(45, 35, 66, 0.4) 0 2px 4px, + rgba(45, 35, 66, 0.3) 0 7px 13px -3px, #d6d6e7 0 -3px 0 inset; + box-sizing: border-box; + color: #36395a; + cursor: pointer; + display: inline-flex; + font-family: "JetBrains Mono", monospace; + height: 48px; + justify-content: center; + line-height: 1; + list-style: none; + overflow: hidden; + padding-left: 16px; + padding-right: 16px; + position: relative; + text-align: left; + text-decoration: none; + transition: box-shadow 0.15s, transform 0.15s; + user-select: none; + -webkit-user-select: none; + touch-action: manipulation; + white-space: nowrap; + will-change: box-shadow, transform; + font-size: 18px; } .button:focus { -box-shadow: #D6D6E7 0 0 0 1.5px inset, rgba(45, 35, 66, 0.4) 0 2px 4px, rgba(45, 35, 66, 0.3) 0 7px 13px -3px, #D6D6E7 0 -3px 0 inset; - + box-shadow: #d6d6e7 0 0 0 1.5px inset, rgba(45, 35, 66, 0.4) 0 2px 4px, + rgba(45, 35, 66, 0.3) 0 7px 13px -3px, #d6d6e7 0 -3px 0 inset; } .button:hover { -box-shadow: rgba(45, 35, 66, 0.4) 0 4px 8px, rgba(45, 35, 66, 0.3) 0 7px 13px -3px, #D6D6E7 0 -3px 0 inset; -transform: translateY(-2px); + box-shadow: rgba(45, 35, 66, 0.4) 0 4px 8px, + rgba(45, 35, 66, 0.3) 0 7px 13px -3px, #d6d6e7 0 -3px 0 inset; + transform: translateY(-2px); } .button:active { -box-shadow: #D6D6E7 0 3px 7px inset; -transform: translateY(2px); + box-shadow: #d6d6e7 0 3px 7px inset; + transform: translateY(2px); } -.start-button:hover{ - background-color: #D2FDAE ; +.start-button:hover { + background-color: #d2fdae; } -.start-button:active{ - background-color: #29BF2E ; - +.start-button:active { + background-color: #29bf2e; } -.reset-button:hover{ - background-color: #DE5B4E; +.reset-button:hover { + background-color: #de5b4e; } -.reset-button:active{ - background-color: #F0420F ; - +.reset-button:active { + background-color: #f0420f; } - - /* CSS for the popup and backdrop */ - .popup-overlay { +/* CSS for the popup and backdrop */ +.popup-overlay { position: fixed; top: 0; left: 0; @@ -532,17 +573,17 @@ transform: translateY(2px); .popup-overlay.hidden { display: none; } -.keyContainer{ - display:flex; - width:70vw; +.keyContainer { + display: flex; + width: 70vw; justify-content: space-around; - color:white; + color: white; font-size: 20px; } -.wrTeller{ +.wrTeller { font-size: 20px; font-weight: 700; - color:white; + color: white; } /* Custom countdown message styles */ diff --git a/Games/Pop_the_Bubbles/Bubbles.jpg b/Games/Pop_the_Bubbles/Bubbles.jpg new file mode 100644 index 0000000000..3f07d23270 Binary files /dev/null and b/Games/Pop_the_Bubbles/Bubbles.jpg differ diff --git a/Games/Pop_the_Bubbles/README.md b/Games/Pop_the_Bubbles/README.md new file mode 100644 index 0000000000..43ec26c0af --- /dev/null +++ b/Games/Pop_the_Bubbles/README.md @@ -0,0 +1,26 @@ +# Pop The Bubbles! + +"Pop The Bubbles!" is a fast-paced, retro-style game where your reflexes and number recognition skills are put to the test. You have 60 seconds to pop as many bubbles as possible, focusing on bubbles with the current target number for bonus points. Perfect for players of all ages, it's easy to learn and endlessly fun! + +## Features + +- Fast-paced gameplay +- Retro-style graphics +- Reflex and number recognition challenge +- Bonus points for popping bubbles with the target number +- 60-second time limit for each round + +## How to Play + +1. Open the `index.html` file in your web browser. +2. Click or tap on bubbles with the current target number to pop them. +3. Aim to pop as many bubbles as possible within 60 seconds. +4. Keep an eye on the target number for bonus points. +5. Enjoy the fast-paced action and compete for the highest score! + + +## Customization + +You can customize the game by modifying the `script.js` file. Adjust the gameplay mechanics, time limit, bubble appearance, and scoring system to suit your preferences. + + diff --git a/Games/Pop_the_Bubbles/index.html b/Games/Pop_the_Bubbles/index.html new file mode 100644 index 0000000000..d8008b99f1 --- /dev/null +++ b/Games/Pop_the_Bubbles/index.html @@ -0,0 +1,28 @@ + + + + + + Bubble Popping Game + + + +
    +

    Pop The Bubbles!

    +

    Pop bubbles with the target number for bonus points!

    +
    + Score: + 0 + Time: + 0 +
    +
    + Hit: + 0 +
    +
    +
    + + + + \ No newline at end of file diff --git a/Games/Pop_the_Bubbles/script.js b/Games/Pop_the_Bubbles/script.js new file mode 100644 index 0000000000..c51c28c879 --- /dev/null +++ b/Games/Pop_the_Bubbles/script.js @@ -0,0 +1,85 @@ +document.addEventListener('DOMContentLoaded', (event) => { + const scoreValue = document.getElementById('score-value'); + const timerValue = document.getElementById('timer'); + const hitValue = document.getElementById('hit'); + const bubbleContainer = document.getElementById('bubble-container'); + + let score = 0; + let timeLeft = 60; + let targetNumber = generateTargetNumber(); + + function startGame() { + updateTimer(); + generateBubbles(); + const gameInterval = setInterval(() => { + timeLeft--; + updateTimer(); + if (timeLeft <= 0) { + clearInterval(gameInterval); + endGame(); + } + }, 1000); + } + + function updateTimer() { + timerValue.textContent = timeLeft; + } + + function generateTargetNumber() { + const target = Math.floor(Math.random() * 10); + hitValue.textContent = target; + return target; + } + + function generateBubbles() { + bubbleContainer.innerHTML = ''; + for (let i = 0; i < 152; i++) { + const bubble = document.createElement('div'); + bubble.className = 'bubble'; + const bubbleNumber = Math.floor(Math.random() * 10); + bubble.textContent = bubbleNumber; + bubble.addEventListener('click', () => popBubble(bubble, bubbleNumber)); + bubbleContainer.appendChild(bubble); + } + } + + function popBubble(bubble, number) { + bubbleContainer.removeChild(bubble); + if (number === targetNumber) { + score += 10; + } else { + score++; + } + scoreValue.textContent = score; + targetNumber = generateTargetNumber(); + refillBubbles(); + } + + function refillBubbles() { + const currentBubbles = bubbleContainer.children.length; + for (let i = currentBubbles; i < 152; i++) { + const bubble = document.createElement('div'); + bubble.className = 'bubble'; + const bubbleNumber = Math.floor(Math.random() * 10); + bubble.textContent = bubbleNumber; + bubble.addEventListener('click', () => popBubble(bubble, bubbleNumber)); + bubbleContainer.appendChild(bubble); + } + } + + function endGame() { + alert(`Game over! Your score is ${score}.`); + resetGame(); + } + + function resetGame() { + score = 0; + timeLeft = 60; + scoreValue.textContent = score; + timerValue.textContent = timeLeft; + targetNumber = generateTargetNumber(); + generateBubbles(); + } + + startGame(); + }); \ No newline at end of file diff --git a/Games/Pop_the_Bubbles/style.css b/Games/Pop_the_Bubbles/style.css new file mode 100644 index 0000000000..59a62f14e8 --- /dev/null +++ b/Games/Pop_the_Bubbles/style.css @@ -0,0 +1,121 @@ +@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap'); +body { + font-family: 'Press Start 2P', cursive, sans-serif; + text-align: center; + background-image:'bg.jpg'; + background-size: cover; + } + + .game-container { + margin: 50px auto; + max-width: 1100px; + padding: 20px; + + } + + body { + font-family: 'Press Start 2P', cursive, sans-serif; + text-align: center; + + background-image: 'bg.jpg'; + background-size: cover; /* Gradient from dark blue to light blue */ + } + + + + +#scoreboard-container { + background-color: rgb(105, 84, 10); + border-radius: 8px; + padding: 10px; + margin-bottom: 20px; +} + +#scoreboard { + display: flex; + justify-content: space-around; +} + +.bubble { + background-color: #e8f1a0; + color: #ffffff; + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; + font-size: 12px; + cursor: pointer; + user-select: none; + width: 50px; + height: 50px; +} + +#target-container { + margin: 20px 0; + font-size: 20px; +} + + + #scoreboard { + display: flex; + justify-content: space-around; + margin-bottom: 20px; + } + .box { + display: inline-block; + padding: 5px 10px; + border: 1px solid #000000; + border-radius: 5px; + color: rgb(255, 255, 255); + margin-right: 5px; + background-color: #f5f550 + } + + .value-box { + display: inline-block; + padding: 5px 10px; + border: 1px solid #000000; + border-radius: 5px; + color: rgb(255, 255, 255); + margin-right: 5px; + background-color: rgb(214, 75, 75); + + + } + + + + + #bubble-container { + display: grid; + grid-template-columns: repeat(19, 1fr); + grid-template-rows: repeat(8, 1fr); + gap: 5px; + width: 1060px; + height: 455px; + background-color: #A7FFEB; + border: 1px solid #01796b; + border-radius: 10px; + padding: 10px; + box-sizing: border-box; + } + + + .bubble { + background-color: #5DEBD7; + color: #000000; + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; + font-size: 12px; + cursor: pointer; + user-select: none; + width: 50px; + height: 50px; + } + + #target-container { + margin: 20px 0; + font-size: 20px; + } diff --git a/Games/Quest_For_Riches/README.md b/Games/Quest_For_Riches/README.md new file mode 100644 index 0000000000..8aa61f133c --- /dev/null +++ b/Games/Quest_For_Riches/README.md @@ -0,0 +1,33 @@ +# **Quest for Riches** + +--- + +## **Description 📃** + +Quest for Riches is a side-scrolling action-adventure game where players navigate through a fantasy world, battling enemies and solving puzzles to find hidden treasure. The game includes a health system, enemy AI, player combat mechanics, and level progression. The game is designed to be engaging and fun, with increasing difficulty as the player advances through the levels. + +## **Functionalities 🎮** + +- Two levels +- Player controls for moving left, right, jumping, and attacking +- Simple enemy AI with predictable movement patterns +- Puzzles such as finding keys and matching code patterns +- Scoring system based on treasures collected and level completion time +- Simple design for desktop browsers + +## **How to play? 🕹️** + +1. Use the **A** and **D** keys to move the player character left and right. +2. Use the **Spacebar** to jump. +3. Use **E** to interact. +4. **Left Mouse Click** to attack. +5. Navigate through the levels by speaking to NPCs and following missions. +6. Collect coins to increase your score. +7. Solve the code pattern to open the treasure. +8. Try to complete all levels with the highest score possible. + +## **Screenshots 📸** + +![Quest For Riches](assets/images/Quest_For_Riches.png) + +--- diff --git a/Games/Quest_For_Riches/assets/images/Quest_For_Riches.png b/Games/Quest_For_Riches/assets/images/Quest_For_Riches.png new file mode 100644 index 0000000000..4fd8bbf2dd Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/Quest_For_Riches.png differ diff --git a/Games/Quest_For_Riches/assets/images/background/background_layer_1.png b/Games/Quest_For_Riches/assets/images/background/background_layer_1.png new file mode 100644 index 0000000000..8d314533dd Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/background/background_layer_1.png differ diff --git a/Games/Quest_For_Riches/assets/images/background/background_layer_2.png b/Games/Quest_For_Riches/assets/images/background/background_layer_2.png new file mode 100644 index 0000000000..49cc60e884 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/background/background_layer_2.png differ diff --git a/Games/Quest_For_Riches/assets/images/background/background_layer_3.png b/Games/Quest_For_Riches/assets/images/background/background_layer_3.png new file mode 100644 index 0000000000..1b9dee49a2 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/background/background_layer_3.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/Chests.png b/Games/Quest_For_Riches/assets/images/sprites/Chests.png new file mode 100644 index 0000000000..404919a53d Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/Chests.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/Treasure.png b/Games/Quest_For_Riches/assets/images/sprites/Treasure.png new file mode 100644 index 0000000000..96b669412d Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/Treasure.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Attack_1.png b/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Attack_1.png new file mode 100644 index 0000000000..18b93fc919 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Attack_1.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Attack_2.png b/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Attack_2.png new file mode 100644 index 0000000000..03d448906f Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Attack_2.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Attack_3.png b/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Attack_3.png new file mode 100644 index 0000000000..66f8bf3957 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Attack_3.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Dead.png b/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Dead.png new file mode 100644 index 0000000000..a7878709ba Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Dead.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Hurt.png b/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Hurt.png new file mode 100644 index 0000000000..d1c0e91ee8 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Hurt.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Idle.png b/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Idle.png new file mode 100644 index 0000000000..31cfac319a Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Idle.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Jump.png b/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Jump.png new file mode 100644 index 0000000000..d2935477c4 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Jump.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Run+Attack.png b/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Run+Attack.png new file mode 100644 index 0000000000..30743b7cff Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Run+Attack.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Run.png b/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Run.png new file mode 100644 index 0000000000..0d1ecc3a88 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Run.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Walk.png b/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Walk.png new file mode 100644 index 0000000000..5a7e81fb68 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/enemies/monster/Walk.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Attack_1.png b/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Attack_1.png new file mode 100644 index 0000000000..0a36b5b95e Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Attack_1.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Attack_2.png b/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Attack_2.png new file mode 100644 index 0000000000..ccdcd1dbab Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Attack_2.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Attack_3.png b/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Attack_3.png new file mode 100644 index 0000000000..96153da08c Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Attack_3.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Dead.png b/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Dead.png new file mode 100644 index 0000000000..6cd684f741 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Dead.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Hurt.png b/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Hurt.png new file mode 100644 index 0000000000..b06b40a605 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Hurt.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Idle.png b/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Idle.png new file mode 100644 index 0000000000..7106f3d617 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Idle.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Idle_2.png b/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Idle_2.png new file mode 100644 index 0000000000..cbe5c02779 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Idle_2.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Jump.png b/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Jump.png new file mode 100644 index 0000000000..477bca29af Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Jump.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Run.png b/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Run.png new file mode 100644 index 0000000000..f1745cb14c Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Run.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Walk.png b/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Walk.png new file mode 100644 index 0000000000..97c1b76679 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/enemies/wizard/Walk.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/gold_coin.png b/Games/Quest_For_Riches/assets/images/sprites/gold_coin.png new file mode 100644 index 0000000000..fa14ae1e05 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/gold_coin.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/gold_coins_pile.png b/Games/Quest_For_Riches/assets/images/sprites/gold_coins_pile.png new file mode 100644 index 0000000000..9ec89efc06 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/gold_coins_pile.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/gold_key.png b/Games/Quest_For_Riches/assets/images/sprites/gold_key.png new file mode 100644 index 0000000000..3bc1ddce3b Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/gold_key.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/npc/archer/Idle.png b/Games/Quest_For_Riches/assets/images/sprites/npc/archer/Idle.png new file mode 100644 index 0000000000..5012f68fac Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/npc/archer/Idle.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/npc/healer/Idle.png b/Games/Quest_For_Riches/assets/images/sprites/npc/healer/Idle.png new file mode 100644 index 0000000000..666f43a402 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/npc/healer/Idle.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/player/Attack_1.png b/Games/Quest_For_Riches/assets/images/sprites/player/Attack_1.png new file mode 100644 index 0000000000..c02d78f3ea Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/player/Attack_1.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/player/Attack_2.png b/Games/Quest_For_Riches/assets/images/sprites/player/Attack_2.png new file mode 100644 index 0000000000..f286a10418 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/player/Attack_2.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/player/Attack_3.png b/Games/Quest_For_Riches/assets/images/sprites/player/Attack_3.png new file mode 100644 index 0000000000..c24408ef28 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/player/Attack_3.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/player/Dead.png b/Games/Quest_For_Riches/assets/images/sprites/player/Dead.png new file mode 100644 index 0000000000..1fb0ac2815 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/player/Dead.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/player/Hurt.png b/Games/Quest_For_Riches/assets/images/sprites/player/Hurt.png new file mode 100644 index 0000000000..9794962045 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/player/Hurt.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/player/Idle.png b/Games/Quest_For_Riches/assets/images/sprites/player/Idle.png new file mode 100644 index 0000000000..94f7b98724 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/player/Idle.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/player/Idle_2.png b/Games/Quest_For_Riches/assets/images/sprites/player/Idle_2.png new file mode 100644 index 0000000000..959e24a7a4 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/player/Idle_2.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/player/Jump.png b/Games/Quest_For_Riches/assets/images/sprites/player/Jump.png new file mode 100644 index 0000000000..145900ddd4 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/player/Jump.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/player/Run.png b/Games/Quest_For_Riches/assets/images/sprites/player/Run.png new file mode 100644 index 0000000000..1b72407189 Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/player/Run.png differ diff --git a/Games/Quest_For_Riches/assets/images/sprites/player/Walk.png b/Games/Quest_For_Riches/assets/images/sprites/player/Walk.png new file mode 100644 index 0000000000..11ca122bea Binary files /dev/null and b/Games/Quest_For_Riches/assets/images/sprites/player/Walk.png differ diff --git a/Games/Quest_For_Riches/assets/sounds/backgroundmusic.mp3 b/Games/Quest_For_Riches/assets/sounds/backgroundmusic.mp3 new file mode 100644 index 0000000000..177d55cb4d Binary files /dev/null and b/Games/Quest_For_Riches/assets/sounds/backgroundmusic.mp3 differ diff --git a/Games/Quest_For_Riches/assets/sounds/chat.wav b/Games/Quest_For_Riches/assets/sounds/chat.wav new file mode 100644 index 0000000000..167782da8a Binary files /dev/null and b/Games/Quest_For_Riches/assets/sounds/chat.wav differ diff --git a/Games/Quest_For_Riches/assets/sounds/coin.wav b/Games/Quest_For_Riches/assets/sounds/coin.wav new file mode 100644 index 0000000000..243c94dcc8 Binary files /dev/null and b/Games/Quest_For_Riches/assets/sounds/coin.wav differ diff --git a/Games/Quest_For_Riches/assets/sounds/levelcomplete.wav b/Games/Quest_For_Riches/assets/sounds/levelcomplete.wav new file mode 100644 index 0000000000..d4dc5ac47d Binary files /dev/null and b/Games/Quest_For_Riches/assets/sounds/levelcomplete.wav differ diff --git a/Games/Quest_For_Riches/assets/sounds/menu.wav b/Games/Quest_For_Riches/assets/sounds/menu.wav new file mode 100644 index 0000000000..94a35dc52c Binary files /dev/null and b/Games/Quest_For_Riches/assets/sounds/menu.wav differ diff --git a/Games/Quest_For_Riches/assets/sounds/treasure.wav b/Games/Quest_For_Riches/assets/sounds/treasure.wav new file mode 100644 index 0000000000..ed1ddec03a Binary files /dev/null and b/Games/Quest_For_Riches/assets/sounds/treasure.wav differ diff --git a/Games/Quest_For_Riches/css/styles.css b/Games/Quest_For_Riches/css/styles.css new file mode 100644 index 0000000000..9403629acd --- /dev/null +++ b/Games/Quest_For_Riches/css/styles.css @@ -0,0 +1,309 @@ +@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap'); + +/* Basic styles for the body */ +body { + padding: 0; + font-family: Arial, sans-serif; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + background-color: black; +} + +/* Styles for main and controls screen */ +#mainScreen, #controlsScreen { + text-align: center; + color: white; + font-family: "Press Start 2P", system-ui; +} + +#mainScreen { + display: hidden; + flex-direction: column; + justify-content: center; + align-items: center; + height: 80vh; +} + +#controlsScreen { + display: hidden; + flex-direction: column; + justify-content: center; + align-items: center; + height: 100vh; +} + +/* Button styles */ +button { + background: yellow; + border: none; + padding: 10px 20px; + margin: 10px; + font-family: "Press Start 2P", system-ui; + font-size: 18px; + cursor: pointer; +} + +button:hover { + background: orange; +} + +/* Class to hide elements */ +.hidden { + display: none; +} + +/* Chat bubble styles */ +.chatBubble { + position: absolute; + display: none; + background: black; + border: 1px solid white; + padding: 20px; + border-radius: 10px; + font-family: "Press Start 2P", system-ui; + color: white; + font-size: 14px; + font-weight: 400; + max-width: 200px; + word-wrap: break-word; +} + +/* Prompt E styles */ +.promptE { + position: absolute; + display: none; + background: black; + border: 1px solid white; + padding: 20px; + border-radius: 5px; + font-family: "Press Start 2P", system-ui; + color: white; + font-size: 14px; +} + +/* Shake animation for modal */ +@keyframes shake { + 0% { transform: translateX(0); } + 25% { transform: translateX(-10px); } + 50% { transform: translateX(10px); } + 75% { transform: translateX(-10px); } + 100% { transform: translateX(0); } +} + +.shake { + animation: shake 0.5s; +} + +/* Modal styles */ +.modal { + display: none; + position: fixed; + z-index: 1; + padding-top: 100px; + left: 0; + top: 0; + width: 100%; + height: 100%; + overflow: auto; + background-color: rgba(0, 0, 0, 0.9); +} + +.modal-content { + background-color: #000000; + margin: auto; + padding: 20px; + border: 1px solid #888; + border-radius: 10px; + width: 80%; + max-width: 400px; + color: white; + text-align: center; +} + +/* Close button styles for modal */ +.close { + color: white; + float: right; + font-size: 28px; + font-weight: bold; +} + +.close:hover, +.close:focus { + color: #ffcc00; + text-decoration: none; + cursor: pointer; +} + +/* Puzzle instructions styles */ +#puzzleInstructions { + font-size: 24px; + color: #ffcc00; + margin-bottom: 20px; +} + +/* Puzzle input styles */ +#puzzleInput { + width: 100%; + padding: 10px; + margin: 10px 0; + box-sizing: border-box; + font-size: 18px; + background-color: white; + color: black; + border: none; + border-radius: 5px; + text-align: center; +} + +/* Submit puzzle button styles */ +#submitPuzzle { + background-color: #ffcc00; + color: black; + padding: 10px 20px; + border: none; + border-radius: 5px; + font-size: 18px; + cursor: pointer; +} + +#submitPuzzle:hover { + background-color: #ff9900; +} + +/* Mission tracker styles */ +#missionTracker { + position: absolute; + top: 10px; + right: 10px; + background: black; + border: 1px solid white; + padding: 10px; + border-radius: 5px; + font-family: "Press Start 2P", system-ui; + color: white; + font-size: 14px; + width: 200px; + text-align: center; +} + +/* Transition screen styles */ +#transitionScreen { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.8); + display: none; + justify-content: center; + align-items: center; + z-index: 1000; +} + +.transitionContent { + background: black; + border: 1px solid white; + padding: 40px; + border-radius: 10px; + text-align: center; + color: white; + font-family: "Press Start 2P", system-ui; + position: relative; +} + +.transitionContent .close { + position: absolute; + top: 10px; + right: 10px; + cursor: pointer; + font-size: 24px; +} + +.transitionContent button { + display: block; + width: 100%; + margin: 20px 0; + padding: 10px; + font-size: 18px; + background: yellow; + border: none; + border-radius: 5px; + cursor: pointer; + font-family: "Press Start 2P", system-ui; +} + +.transitionContent button:hover { + background: orange; +} + +/* End game screen styles */ +#endGameScreen { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.8); + display: none; + justify-content: center; + align-items: center; + z-index: 1000; +} + +.endGameContent { + background: black; + border: 1px solid white; + padding: 40px; + border-radius: 10px; + text-align: center; + color: white; + font-family: "Press Start 2P", system-ui; + position: relative; +} + +.endGameContent .close { + position: absolute; + top: 10px; + right: 10px; + cursor: pointer; + font-size: 24px; +} + +.endGameContent button { + display: block; + width: 100%; + margin: 20px 0; + padding: 10px; + font-size: 18px; + background: yellow; + border: none; + border-radius: 5px; + cursor: pointer; + font-family: "Press Start 2P", system-ui; +} + +.endGameContent button:hover { + background: orange; +} + +/* Back to GameZone button styles */ +.backToGameZone { + display: block; + width: 100%; + margin: 20px 0; + padding: 10px; + font-size: 18px; + background: yellow; + border: none; + border-radius: 5px; + cursor: pointer; + font-family: "Press Start 2P", system-ui; +} + +.backToGameZone a { + color: black; + text-decoration: none; +} diff --git a/Games/Quest_For_Riches/index.html b/Games/Quest_For_Riches/index.html new file mode 100644 index 0000000000..288364e286 --- /dev/null +++ b/Games/Quest_For_Riches/index.html @@ -0,0 +1,89 @@ + + + + + + Quest for Riches + + + + + + + +
    +

    Quest for Riches

    + + +
    + + + + + + + + +
    +
    E
    + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Games/Quest_For_Riches/js/audioManager.js b/Games/Quest_For_Riches/js/audioManager.js new file mode 100644 index 0000000000..eb2ed4e316 --- /dev/null +++ b/Games/Quest_For_Riches/js/audioManager.js @@ -0,0 +1,45 @@ +class AudioManager { + constructor() { + this.sounds = {}; + } + + // Load a sound and store it in the sounds object + loadSound(name, src) { + const sound = new Audio(src); + this.sounds[name] = sound; + } + + // Play a sound by name + playSound(name) { + if (this.sounds[name]) { + this.sounds[name].play(); + } + } + + // Stop a sound by name + stopSound(name) { + if (this.sounds[name]) { + this.sounds[name].pause(); + this.sounds[name].currentTime = 0; + } + } + + // Set the volume for a specific sound + setVolume(name, volume) { + if (this.sounds[name]) { + this.sounds[name].volume = volume; + } + } +} + +// Instantiate AudioManager and load sounds +const audioManager = new AudioManager(); +audioManager.loadSound("coin", "assets/sounds/coin.wav"); +audioManager.loadSound("chat", "assets/sounds/chat.wav"); +audioManager.loadSound("levelComplete", "assets/sounds/levelcomplete.wav"); +audioManager.loadSound("menu", "assets/sounds/menu.wav"); +audioManager.loadSound("treasure", "assets/sounds/treasure.wav"); +audioManager.loadSound("background", "assets/sounds/backgroundmusic.mp3"); + +// Set initial volume for background music +audioManager.setVolume("background", 0.25); diff --git a/Games/Quest_For_Riches/js/chest.js b/Games/Quest_For_Riches/js/chest.js new file mode 100644 index 0000000000..f31da55bcb --- /dev/null +++ b/Games/Quest_For_Riches/js/chest.js @@ -0,0 +1,208 @@ +class Chest { + constructor(x, y) { + this.position = { x, y }; + this.width = 48; // Width of a single frame + this.height = 33; // Height of a single frame + this.scale = 3; // Scale factor to fit the game + this.scaledWidth = this.width * this.scale; + this.scaledHeight = this.height * this.scale; + this.isOpen = false; + this.coinPile = null; // Reference to the coin pile animation + + // Load the chest sprite + this.image = new Image(); + this.image.src = "assets/images/sprites/Chests.png"; + + // Define the frames for the chest we want to use (row 5 and 6) + this.frames = 5; + this.frameX = 0; + this.frameY = 4; // Start at row 5 + this.frameSpeed = 10; + this.frameTick = 0; + this.animationComplete = false; // Flag to check if animation is complete + + // Create the chat bubble and prompt elements + this.chatBubble = document.createElement("div"); + this.chatBubble.classList.add("chatBubble"); + document.body.appendChild(this.chatBubble); + + this.promptE = document.createElement("div"); + this.promptE.classList.add("promptE"); + this.promptE.innerText = "E"; + document.body.appendChild(this.promptE); + + // Puzzle elements + this.puzzleModal = document.getElementById("puzzleModal"); + this.puzzleInstructions = document.getElementById("puzzleInstructions"); + this.puzzleInput = document.getElementById("puzzleInput"); + this.submitPuzzleButton = document.getElementById("submitPuzzle"); + this.puzzleSolution = ""; + + // Add event listeners for puzzle interactions + this.submitPuzzleButton.addEventListener("click", () => { + if (this.puzzleInput.value === this.puzzleSolution) { + this.solvePuzzle(player); + } else { + this.shakePuzzleModal(); // Trigger shake animation + } + }); + + const closeModal = () => { + this.puzzleModal.style.display = "none"; + this.puzzleInput.value = ""; + }; + + document.querySelector(".close").addEventListener("click", closeModal); + window.addEventListener("click", (event) => { + if (event.target === this.puzzleModal) { + closeModal(); + } + }); + } + + // Draw the chest on the canvas + draw(cameraOffsetX) { + c.drawImage( + this.image, + this.frameX * this.width, + this.frameY * this.height, + this.width, + this.height, + this.position.x - cameraOffsetX, + this.position.y, + this.scaledWidth, + this.scaledHeight + ); + } + + // Show the 'E' prompt above the chest + showPromptE(cameraOffsetX) { + const promptX = this.position.x - cameraOffsetX + this.scaledWidth / 2; + const promptY = this.position.y - 30; // Above the chest + + const canvasRect = document.querySelector("canvas").getBoundingClientRect(); + this.promptE.style.left = `${canvasRect.left + promptX - 10}px`; + this.promptE.style.top = `${canvasRect.top + promptY - 20}px`; + this.promptE.style.display = "block"; + } + + // Hide the 'E' prompt + hidePromptE() { + this.promptE.style.display = "none"; + } + + // Show a chat bubble above the chest + showChatBubble(cameraOffsetX, text) { + const bubbleX = this.position.x - cameraOffsetX + this.scaledWidth / 2; + const bubbleY = this.position.y - 100; // Above the chest + + const canvasRect = document.querySelector("canvas").getBoundingClientRect(); + this.chatBubble.style.left = `${canvasRect.left + bubbleX}px`; + this.chatBubble.style.top = `${canvasRect.top + bubbleY}px`; + this.chatBubble.innerHTML = text.replace(/\n/g, "
    "); + this.chatBubble.style.display = "block"; + } + + // Hide the chat bubble + hideChatBubble() { + this.chatBubble.style.display = "none"; + } + + // Generate a random puzzle solution + generatePuzzle() { + const patternLength = 5; + const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + this.puzzleSolution = Array.from({ length: patternLength }) + .map(() => + characters.charAt(Math.floor(Math.random() * characters.length)) + ) + .join(""); + this.puzzleInstructions.innerText = this.puzzleSolution; + } + + // Solve the puzzle and open the chest + solvePuzzle(player) { + this.isOpen = true; + this.frameY = 5; // Change to row 6 for the open chest + // Create coin pile animation + this.coinPile = new CoinPile( + this.position.x, + this.position.y - this.scaledHeight / 2 + ); + player.coins += 50; // Add 50 coins to the player's coin count + player.hasCollectedTreasure = true; // Set treasure collected state + audioManager.playSound("treasure"); + this.hidePromptE(); + this.puzzleModal.style.display = "none"; // Close the modal + } + + // Shake the puzzle modal to indicate incorrect solution + shakePuzzleModal() { + const modalContent = this.puzzleModal.querySelector(".modal-content"); + modalContent.classList.add("shake"); + setTimeout(() => { + modalContent.classList.remove("shake"); + }, 500); // Duration of the shake animation + } + + // Update the chest state and animations + update(cameraOffsetX, player, enemies) { + const modalVisible = this.puzzleModal.style.display === "block"; + + // Interaction logic when the player is near the chest + if ( + !modalVisible && // Only interact if the modal is not visible + !this.isOpen && + player.position.x < this.position.x + this.scaledWidth && + player.position.x + player.width > this.position.x && + player.position.y < this.position.y + this.scaledHeight && + player.height + player.position.y > this.position.y + ) { + // Show E prompt if in proximity + if (!player.isInteracting) { + this.showPromptE(cameraOffsetX + 40); + } + + // Check if player is in proximity and presses 'e' to open the chest + if (keys.e.pressed) { + if (!player.hasKey) { + this.showChatBubble( + cameraOffsetX, + "You need a key to open this chest." + ); + } else if (enemies.length > 0) { + this.showChatBubble( + cameraOffsetX, + "Defeat all enemies to open the chest." + ); + } else { + this.generatePuzzle(); + this.puzzleModal.style.display = "block"; + } + } + } else { + this.hidePromptE(); + this.hideChatBubble(); + } + + // Update frame animation + if (!this.animationComplete) { + this.frameTick++; + if (this.frameTick >= this.frameSpeed) { + this.frameTick = 0; + this.frameX++; + if (this.frameX >= this.frames) { + this.frameX = this.frames - 1; // Stay on the last frame + this.animationComplete = true; // Animation complete + } + } + } + + // Update coin pile animation if present + if (this.coinPile) { + this.coinPile.update(cameraOffsetX); + } + + this.draw(cameraOffsetX); + } +} diff --git a/Games/Quest_For_Riches/js/coin.js b/Games/Quest_For_Riches/js/coin.js new file mode 100644 index 0000000000..acd1127772 --- /dev/null +++ b/Games/Quest_For_Riches/js/coin.js @@ -0,0 +1,46 @@ +class Coin { + constructor(x, y, player) { + this.position = { x, y }; + this.width = 32; // Width of the coin sprite + this.height = 32; // Height of the coin sprite + this.scale = 2; // Scale factor + this.scaledWidth = this.width * this.scale; + this.scaledHeight = this.height * this.scale; + this.collected = false; + this.player = player; // Reference to the player to increase the coin count + + // Load the coin sprite + this.image = new Image(); + this.image.src = "assets/images/sprites/gold_coin.png"; + } + + // Draw the coin on the canvas if it has not been collected + draw(cameraOffsetX) { + if (this.collected) return; + + c.drawImage( + this.image, + this.position.x - cameraOffsetX, + this.position.y, + this.scaledWidth, + this.scaledHeight + ); + } + + // Update the coin state and check for collision with the player + update(cameraOffsetX, player) { + if ( + !this.collected && + player.position.x < this.position.x + this.scaledWidth && + player.position.x + player.width > this.position.x && + player.position.y < this.position.y + this.scaledHeight && + player.height + player.position.y > this.position.y + ) { + this.collected = true; // Mark the coin as collected + audioManager.playSound("coin"); // Play coin collection sound + player.coins += 1; // Increase player's coin count + } + + this.draw(cameraOffsetX); // Draw the coin + } +} diff --git a/Games/Quest_For_Riches/js/coinPile.js b/Games/Quest_For_Riches/js/coinPile.js new file mode 100644 index 0000000000..28380668d4 --- /dev/null +++ b/Games/Quest_For_Riches/js/coinPile.js @@ -0,0 +1,39 @@ +class CoinPile { + constructor(x, y) { + this.position = { x, y }; + this.image = new Image(); + this.image.src = "assets/images/sprites/gold_coins_pile.png"; + this.width = 32; // Width of the coin pile image + this.height = 32; // Height of the coin pile image + this.scale = 3; // Increase the scale factor to fit the game + this.scaledWidth = this.width * this.scale; + this.scaledHeight = this.height * this.scale; + this.velocityY = -1; // Velocity for moving upwards + this.alpha = 1; // Transparency for fade out + this.fadeSpeed = 0.01; // Speed of fading out + } + + // Draw the coin pile on the canvas with transparency + draw(cameraOffsetX) { + c.save(); + c.globalAlpha = this.alpha; // Set the transparency + c.drawImage( + this.image, + this.position.x - cameraOffsetX, + this.position.y, + this.scaledWidth, + this.scaledHeight + ); + c.restore(); + } + + // Update the position and transparency of the coin pile + update(cameraOffsetX) { + this.position.y += this.velocityY; // Move the coin pile upwards + this.alpha -= this.fadeSpeed; // Reduce the transparency + if (this.alpha <= 0) { + this.alpha = 0; // Ensure alpha does not go below 0 + } + this.draw(cameraOffsetX); // Draw the coin pile + } +} diff --git a/Games/Quest_For_Riches/js/enemy.js b/Games/Quest_For_Riches/js/enemy.js new file mode 100644 index 0000000000..b0086b9ca5 --- /dev/null +++ b/Games/Quest_For_Riches/js/enemy.js @@ -0,0 +1,232 @@ +class Enemy { + constructor(x, y, spriteData, patrolDistance = 100, type = "wizard") { + if (!spriteData) { + throw new Error("spriteData is required"); + } + this.position = { x, y }; + this.initialPosition = { x, y }; + this.patrolDistance = patrolDistance; + this.velocity = { x: 1, y: 0 }; + this.width = spriteData.width; + this.height = spriteData.height; + this.scale = 2; + this.scaledWidth = this.width * this.scale; + this.scaledHeight = this.height * this.scale; + this.health = 3; + this.gravity = 0.3; + this.direction = "left"; + this.isAttacking = false; + this.attackCooldown = 0; + this.patrolDirection = Math.random() > 0.5 ? 1 : -1; + this.isDead = false; + this.state = "idle"; + this.type = type; + + this.sprites = spriteData.sprites; + this.loaded = false; + + // Load all sprite images + let loadedImagesCount = 0; + const totalImages = Object.keys(this.sprites).length; + for (let key in this.sprites) { + const img = new Image(); + img.src = this.sprites[key].src; + img.onload = () => { + loadedImagesCount++; + if (loadedImagesCount === totalImages) { + this.loaded = true; + } + }; + this.sprites[key].img = img; + } + + this.currentSprite = "idle"; + this.frameIndex = 0; + this.frameSpeed = this.sprites[this.currentSprite].speed; + this.frameTick = 0; + } + + // Set the current animation + setAnimation(animation) { + if (this.currentSprite !== animation) { + this.currentSprite = animation; + this.frameIndex = 0; + this.frameSpeed = this.sprites[animation].speed; + } + } + + // Update the state of the enemy based on player position + updateState(player) { + if (this.isDead) { + this.setAnimation("dead"); + return; + } + + const distanceToPlayer = Math.abs(this.position.x - player.position.x); + const yDistanceToPlayer = Math.abs(this.position.y - player.position.y); + + if (distanceToPlayer < 50 && yDistanceToPlayer < 80) { + this.state = "attack"; + } else if (distanceToPlayer < 300) { + this.state = "run"; + } else { + this.state = "walk"; + } + + if (this.state === "attack") { + this.isAttacking = true; + this.velocity.x = 0; + this.setAnimation("attack1"); + if ( + this.frameIndex === this.sprites.attack1.frames - 1 && + this.attackCooldown <= 0 + ) { + player.takeDamage(); + this.attackCooldown = 60; + } + } else { + this.isAttacking = false; + if (this.state === "run") { + if (this.position.x < player.position.x) { + this.direction = "right"; + this.velocity.x = 1.5; + } else { + this.direction = "left"; + this.velocity.x = -1.5; + } + this.setAnimation("run"); + } else if (this.state === "walk") { + if (this.position.x <= this.initialPosition.x - this.patrolDistance) { + this.patrolDirection = 1; + this.direction = "right"; + } else if ( + this.position.x >= + this.initialPosition.x + this.patrolDistance + ) { + this.patrolDirection = -1; + this.direction = "left"; + } + this.velocity.x = this.patrolDirection; + this.setAnimation("walk"); + } + } + + if (this.attackCooldown > 0) { + this.attackCooldown--; + } + } + + // Draw the enemy on the canvas + draw(cameraOffsetX) { + if (!this.loaded) return; + + const sprite = this.sprites[this.currentSprite]; + const frameWidth = this.width; + const frameHeight = this.height; + const sx = this.frameIndex * frameWidth; + const sy = 0; + + c.save(); + + if (this.direction === "left") { + c.scale(-1, 1); + c.drawImage( + sprite.img, + sx, + sy, + frameWidth, + frameHeight, + -(this.position.x - cameraOffsetX + this.scaledWidth), + this.position.y, + this.scaledWidth, + this.scaledHeight + ); + } else { + c.drawImage( + sprite.img, + sx, + sy, + frameWidth, + frameHeight, + this.position.x - cameraOffsetX, + this.position.y, + this.scaledWidth, + this.scaledHeight + ); + } + + c.restore(); + + this.drawHealthBar(cameraOffsetX); + } + + // Draw the health bar above the enemy + drawHealthBar(cameraOffsetX) { + const healthBarWidth = this.scaledWidth * 0.6; + const healthBarHeight = 10; + const healthBarX = + this.position.x - cameraOffsetX + (this.scaledWidth - healthBarWidth) / 2; + const healthBarY = this.position.y - 20; + + c.fillStyle = "red"; + c.fillRect(healthBarX, healthBarY, healthBarWidth, healthBarHeight); + + c.fillStyle = "green"; + c.fillRect( + healthBarX, + healthBarY, + (healthBarWidth * this.health) / 3, + healthBarHeight + ); + + c.strokeStyle = "black"; + c.strokeRect(healthBarX, healthBarY, healthBarWidth, healthBarHeight); + } + + // Update the enemy's position and state + update(cameraOffsetX, player) { + this.updateState(player); + + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + // Apply gravity + if (this.position.y + this.scaledHeight + this.velocity.y < canvas.height) { + this.velocity.y += this.gravity; + } else { + this.velocity.y = 0; + } + + // Ensure the enemy stays within the game world bounds + if (this.position.x < 0) { + this.position.x = 0; + } else if (this.position.x + this.scaledWidth > GAME_WORLD_WIDTH) { + this.position.x = GAME_WORLD_WIDTH - this.scaledWidth; + } + + // Update the frame index for animation + this.frameTick++; + if (this.frameTick >= this.frameSpeed) { + this.frameTick = 0; + const sprite = this.sprites[this.currentSprite]; + this.frameIndex = (this.frameIndex + 1) % sprite.frames; + } + + this.draw(cameraOffsetX); + } + + // Handle taking damage + takeDamage() { + if (this.isDead) return; + this.health -= 1; + if (this.health <= 0) { + this.isDead = true; + this.setAnimation("dead"); + } else { + this.setAnimation("hurt"); + setTimeout(() => { + this.setAnimation("idle"); + }, (this.sprites.hurt.frames * this.frameSpeed * 1000) / 60); + } + } +} diff --git a/Games/Quest_For_Riches/js/game.js b/Games/Quest_For_Riches/js/game.js new file mode 100644 index 0000000000..90674a81e3 --- /dev/null +++ b/Games/Quest_For_Riches/js/game.js @@ -0,0 +1,458 @@ +// Select the HTML elements +const mainScreen = document.getElementById("mainScreen"); +const controlsScreen = document.getElementById("controlsScreen"); +const canvas = document.querySelector("canvas"); +const c = canvas.getContext("2d"); +const missionTracker = document.getElementById("missionTracker"); +const startButton = document.getElementById("startButton"); +const controlsButton = document.getElementById("controlsButton"); +const backButton = document.getElementById("backButton"); + +// Set the canvas size +canvas.width = 960; +canvas.height = 540; + +const GAME_WORLD_WIDTH = canvas.width * 3; // Game world size +const player = new Player(); + +let levelIndex = 0; // Current level index +let level = null; + +function hideNPCUIElements() { + if (player.npc) { + player.npc.hideChatBubble(); + player.npc.hidePromptE(); + } +} + +// Initialize the level +function initializeLevel(index) { + if (index >= 0 && index < levelData.length) { + level = new Level(levelData[index]); + level.initializeGameWorld(player); + player.npc.resetState(); // Reset NPC state + } else { + console.error("Invalid level index:", index); + } +} + +initializeLevel(levelIndex); + +let currentMissionIndex = 0; + +// Update the mission tracker +function updateMissionTracker() { + if (currentMissionIndex < level.missions.length) { + missionTracker.innerHTML = `Mission: ${level.missions[currentMissionIndex]}`; + } else { + missionTracker.innerHTML = "Mission Complete!"; + } +} + +updateMissionTracker(); + +// Load background layers +const backgroundLayers = [ + { src: "assets/images/background/background_layer_1.png", zIndex: 1, x: 0 }, + { src: "assets/images/background/background_layer_2.png", zIndex: 2, x: 0 }, + { src: "assets/images/background/background_layer_3.png", zIndex: 3, x: 0 }, +]; + +const loadedBackgrounds = []; + +backgroundLayers.forEach((layer) => { + const img = new Image(); + img.src = layer.src; + img.onload = () => { + loadedBackgrounds.push({ img, zIndex: layer.zIndex, x: layer.x }); + if (loadedBackgrounds.length === backgroundLayers.length) { + animate(); + } + }; + img.onerror = () => { + console.error("Failed to load image:", layer.src); + }; +}); + +const keys = { + " ": { pressed: false }, + a: { pressed: false }, + d: { pressed: false }, + e: { pressed: false }, +}; + +let cameraOffsetX = 0; + +// Handle keydown events +window.addEventListener("keydown", (event) => { + if ( + document.getElementById("transitionScreen").classList.contains("hidden") + ) { + switch (event.key) { + case " ": + if (player.velocity.y === 0) { + player.velocity.y = -10; + player.setAnimation("jump"); + } + break; + case "a": + keys.a.pressed = true; + player.setAnimation("run"); + player.direction = "left"; + break; + case "d": + keys.d.pressed = true; + player.setAnimation("run"); + player.direction = "right"; + break; + case "e": + keys.e.pressed = true; + player.isInteracting = true; + player.npc.interact(player); // Trigger interaction with player state + break; + } + } +}); + +// Handle keyup events +window.addEventListener("keyup", (event) => { + switch (event.key) { + case "a": + keys.a.pressed = false; + if (!keys.d.pressed) { + player.setAnimation("idle"); + } + break; + case "d": + keys.d.pressed = false; + if (!keys.a.pressed) { + player.setAnimation("idle"); + } + break; + case "e": + keys.e.pressed = false; + player.isInteracting = false; + break; + } +}); + +// Handle mouse click events +canvas.addEventListener("mousedown", (event) => { + if (player.attackCooldown <= 0) { + player.isAttacking = true; // Set a flag to indicate an attack is initiated + player.attack(); + } +}); + +// Draw background layers +function drawBackgrounds() { + loadedBackgrounds.sort((a, b) => a.zIndex - b.zIndex); + loadedBackgrounds.forEach((layer) => { + // Tile the background image to cover the entire game world width + for (let i = -1; i <= GAME_WORLD_WIDTH / canvas.width; i++) { + c.drawImage( + layer.img, + layer.x + i * canvas.width - cameraOffsetX, + 0, + canvas.width, + canvas.height + ); + } + }); +} + +// Check mission progress +function checkMissionProgress() { + switch (currentMissionIndex) { + case 0: + if (player.npc.isChatting && player.npc.dialogueState > 2) { + currentMissionIndex++; + } + break; + case 1: + if (level.enemies.length === 0) { + currentMissionIndex++; + } + break; + case 2: + if (player.hasKey) { + currentMissionIndex++; + } + break; + case 3: + if (level.chest.isOpen) { + currentMissionIndex++; + } + break; + case 4: + if ( + player.npc.isChatting && + player.npc.dialogueState === 0 && + player.hasCollectedTreasure + ) { + currentMissionIndex++; + } + break; + } + updateMissionTracker(); +} + +// Handle combat +function handleCombat(player, enemy) { + if ( + player.position.x < enemy.position.x + enemy.scaledWidth && + player.position.x + player.width > enemy.position.x && + player.position.y < enemy.position.y + enemy.scaledHeight && + player.height + player.position.y > enemy.position.y + ) { + if (player.isAttacking && player.attackCooldown <= 0) { + enemy.takeDamage(); + player.attackCooldown = 60; // Reset player attack cooldown + player.isAttacking = false; // Reset attack flag + + if (enemy.health <= 0) { + const index = level.enemies.indexOf(enemy); + if (index > -1) { + level.enemies.splice(index, 1); // Remove defeated enemy + } + } + } + } +} + +let startTime; + +// Start the level +function startLevel() { + startTime = new Date(); + audioManager.playSound("background"); + audioManager.sounds["background"].loop = true; +} + +// End the level +function endLevel() { + const endTime = new Date(); + const timeTaken = Math.floor((endTime - startTime) / 1000); + const coinsCollected = player.coins; + const score = calculateScore(coinsCollected, timeTaken); + + document.getElementById("coinsCollected").innerText = coinsCollected; + document.getElementById("timeTaken").innerText = `${timeTaken}s`; + document.getElementById("finalScore").innerText = score; + + const transitionScreen = document.getElementById("transitionScreen"); + transitionScreen.classList.remove("hidden"); + transitionScreen.style.display = "flex"; + audioManager.playSound("levelComplete"); +} + +// Calculate score +function calculateScore(coins, time) { + return coins * 10 - time * 5; +} + +// Event listeners for buttons +document.getElementById("replayButton").addEventListener("click", () => { + hideNPCUIElements(); + audioManager.playSound("menu"); + initializeLevel(levelIndex); + resetGameState(); + startLevel(); + updateMissionTracker(); + transitionScreen.classList.add("hidden"); + transitionScreen.style.display = "none"; +}); + +document.getElementById("nextLevelButton").addEventListener("click", () => { + hideNPCUIElements(); + audioManager.playSound("menu"); + levelIndex++; + if (levelIndex < levelData.length) { + initializeLevel(levelIndex); + resetGameState(); + startLevel(); + updateMissionTracker(); + const transitionScreen = document.getElementById("transitionScreen"); + transitionScreen.classList.add("hidden"); + transitionScreen.style.display = "none"; + } else { + const endGameScreen = document.getElementById("endGameScreen"); + endGameScreen.classList.remove("hidden"); + endGameScreen.style.display = "flex"; + } +}); + +document.getElementById("closeEndGameScreen").addEventListener("click", () => { + const endGameScreen = document.getElementById("endGameScreen"); + endGameScreen.classList.add("hidden"); + endGameScreen.style.display = "none"; +}); + +document.getElementById("replayGameButton").addEventListener("click", () => { + hideNPCUIElements(); + audioManager.playSound("menu"); + levelIndex = 0; + initializeLevel(levelIndex); + resetGameState(); + transitionScreen.classList.add("hidden"); + transitionScreen.style.display = "none"; + startLevel(); + updateMissionTracker(); + const endGameScreen = document.getElementById("endGameScreen"); + endGameScreen.classList.add("hidden"); + endGameScreen.style.display = "none"; +}); + +document + .getElementById("closeTransitionScreen") + .addEventListener("click", () => { + const transitionScreen = document.getElementById("transitionScreen"); + transitionScreen.classList.add("hidden"); + transitionScreen.style.display = "none"; + }); + +// Reset game state +function resetGameState() { + player.position = { x: 50, y: 50 }; + player.velocity = { x: 0, y: 0 }; + player.health = 20; + player.coins = 0; + player.hasKey = false; + player.hasCollectedTreasure = false; + player.setAnimation("idle"); + + if (player.npc) { + player.npc.resetState(); // Reset NPC state + } + + currentMissionIndex = 0; + cameraOffsetX = 0; + + // Clear puzzle input and modal state + document.getElementById("puzzleInput").value = ""; + document.getElementById("puzzleModal").style.display = "none"; + + // Reset the chest state + if (level && level.chest) { + level.chest.isOpen = false; + level.chest.frameY = 4; + level.chest.frameX = 0; + level.chest.frameTick = 0; + level.chest.animationComplete = false; + level.chest.puzzleSolution = ""; + } + + // Re-initialize coins + if (level && level.coinsData) { + level.coins = level.coinsData.map( + (coin) => new Coin(coin.x, coin.y, player) + ); + } + + // Re-initialize enemies + if (level && level.enemiesData) { + level.enemies = level.enemiesData.map( + (enemy) => new Enemy(enemy.x, enemy.y, enemy.spriteData) + ); + } + + console.log("Game state reset. Current level:", levelIndex); +} + +// Initialize the main screen +mainScreen.classList.remove("hidden"); +mainScreen.style.display = "flex"; + +// Event listener for start button +startButton.addEventListener("click", () => { + mainScreen.classList.add("hidden"); + mainScreen.style.display = "none"; + canvas.classList.remove("hidden"); + missionTracker.classList.remove("hidden"); + audioManager.playSound("menu"); + startLevel(); +}); + +// Event listener for controls button +controlsButton.addEventListener("click", () => { + mainScreen.classList.add("hidden"); + mainScreen.style.display = "none"; + controlsScreen.classList.remove("hidden"); + controlsScreen.style.display = "flex"; + audioManager.playSound("menu"); +}); + +// Event listener for back button +backButton.addEventListener("click", () => { + controlsScreen.classList.add("hidden"); + controlsScreen.style.display = "none"; + mainScreen.classList.remove("hidden"); + mainScreen.style.display = "flex"; + audioManager.playSound("menu"); +}); + +// Main animation loop +function animate() { + window.requestAnimationFrame(animate); + + c.clearRect(0, 0, canvas.width, canvas.height); + + drawBackgrounds(); + + player.velocity.x = 0; + const playerSpeed = 2; + if (keys.d.pressed && player.position.x + player.width < GAME_WORLD_WIDTH) { + player.velocity.x = playerSpeed; + } else if (keys.a.pressed && player.position.x > 0) { + player.velocity.x = -playerSpeed; + } + + player.update(cameraOffsetX); + player.npc.update(cameraOffsetX, player); // Update the NPC + + cameraOffsetX = Math.max( + 0, + Math.min( + player.position.x - canvas.width / 2 + player.width / 2, + GAME_WORLD_WIDTH - canvas.width + ) + ); + + // Update enemies + level.enemies.forEach((enemy) => { + if (typeof enemy.update === "function") { + enemy.update(cameraOffsetX, player); + handleCombat(player, enemy); + } + }); + + // Update coins + level.coins.forEach((coin) => { + coin.update(cameraOffsetX, player); + }); + + // Update the key + if (level && level.key && typeof level.key.update === "function") { + level.key.update(cameraOffsetX, player); + } + + // Update the chest + if (level && level.chest && typeof level.chest.update === "function") { + level.chest.update(cameraOffsetX, player, level.enemies); + } + + // Update the mission tracker position to stay at the top right of the canvas + const canvasRect = canvas.getBoundingClientRect(); + missionTracker.style.left = `${ + canvasRect.right - missionTracker.offsetWidth - 20 + }px`; + missionTracker.style.top = `${canvasRect.top + 20}px`; + + checkMissionProgress(); +} + +// Ensure background music is playing when the document is loaded +document.addEventListener("DOMContentLoaded", () => { + audioManager.playSound("background"); + audioManager.sounds["background"].loop = true; +}); diff --git a/Games/Quest_For_Riches/js/key.js b/Games/Quest_For_Riches/js/key.js new file mode 100644 index 0000000000..180a7b98a7 --- /dev/null +++ b/Games/Quest_For_Riches/js/key.js @@ -0,0 +1,42 @@ +class Key { + constructor(x, y) { + this.position = { x, y }; + this.image = new Image(); + this.image.src = "assets/images/sprites/gold_key.png"; + this.width = 16; // Width of the key image + this.height = 16; // Height of the key image + this.scale = 4; // Scale factor to fit the game + this.scaledWidth = this.width * this.scale; + this.scaledHeight = this.height * this.scale; + this.collected = false; + } + + // Draw the key on the canvas + draw(cameraOffsetX) { + if (!this.collected) { + c.drawImage( + this.image, + this.position.x - cameraOffsetX, + this.position.y, + this.scaledWidth, + this.scaledHeight + ); + } + } + + // Update the key state and check for collision with the player + update(cameraOffsetX, player) { + if ( + !this.collected && + player.position.x < this.position.x + this.scaledWidth && + player.position.x + player.width > this.position.x && + player.position.y < this.position.y + this.scaledHeight && + player.height + player.position.y > this.position.y + ) { + this.collected = true; + player.hasKey = true; + } + + this.draw(cameraOffsetX); + } +} diff --git a/Games/Quest_For_Riches/js/levels.js b/Games/Quest_For_Riches/js/levels.js new file mode 100644 index 0000000000..c75eaaeafb --- /dev/null +++ b/Games/Quest_For_Riches/js/levels.js @@ -0,0 +1,519 @@ +/** + * Represents a game level with various entities like coins, enemies, NPCs, key, and chest. + */ +class Level { + /** + * Creates a new level instance. + * @param {Object} data - The level data containing missions, coins, enemies, NPC, dialogues, key, and chest positions. + * @param {Array} data.missions - List of mission descriptions for the level. + * @param {Array} data.coins - List of coin objects containing x and y positions. + * @param {Array} data.enemies - List of enemy objects containing x, y, and sprite data. + * @param {Object} data.npc - NPC data including position and sprite data. + * @param {Object} data.npcDialogues - Dialogues for the NPC with different states. + * @param {Object} data.keyPosition - Position object containing x and y for the key. + * @param {Object} data.chestPosition - Position object containing x and y for the chest. + */ + constructor(data) { + this.missions = data.missions; + this.coinsData = data.coins; + this.enemiesData = data.enemies; + this.npcData = data.npc; + this.npcDialogues = data.npcDialogues; + this.keyPosition = data.keyPosition; + this.chestPosition = data.chestPosition; + this.coins = []; + this.enemies = []; + } + + /** + * Initializes the game world by creating instances of coins, enemies, NPC, key, and chest. + * @param {Player} player - The player instance to associate with the NPC. + */ + initializeGameWorld(player) { + // Initialize coins + this.coins = this.coinsData.map((coin) => { + const newCoin = new Coin(coin.x, coin.y, player); + return newCoin; + }); + + // Initialize enemies + this.enemies = this.enemiesData.map((enemyData) => { + if (!enemyData.spriteData) { + console.error("Missing spriteData for enemy:", enemyData); + } + const enemyType = enemyData.spriteData.sprites.attack1 + ? "monster" + : "wizard"; + const newEnemy = new Enemy( + enemyData.x, + enemyData.y, + enemyData.spriteData, + 100, + enemyType + ); + return newEnemy; + }); + + // Initialize NPC + if (this.npcData) { + player.npc = new NPC( + this.npcData.x, + this.npcData.y, + this.npcData.spriteData + ); + } + + // Initialize key + this.key = new Key(this.keyPosition.x, this.keyPosition.y); + + // Initialize chest + this.chest = new Chest(this.chestPosition.x, this.chestPosition.y); + } + + /** + * Retrieves the appropriate dialogue for the NPC based on the current state and whether the treasure is collected. + * @param {number} dialogueState - The current dialogue state of the NPC. + * @param {boolean} hasCollectedTreasure - Indicates if the player has collected the treasure. + * @returns {string} The dialogue text for the NPC. + */ + getNPCDialogue(dialogueState, hasCollectedTreasure) { + if (hasCollectedTreasure) { + return this.npcDialogues.final; + } + return this.npcDialogues[dialogueState] || this.npcDialogues.default; + } +} + +// Example level data for creating instances of Level class +const levelData = [ + { + missions: [ + "Talk to The Archer", // Mission 1 + "Defeat all Wizards", // Mission 2 + "Collect the Key", // Mission 3 + "Open the Chest", // Mission 4 + "Return to The Archer", // Mission 5 + ], + coins: [ + { x: 950, y: 300 }, // Coin 1 position + { x: 1300, y: 400 }, // Coin 2 position + { x: 1500, y: 300 }, // Coin 3 position + { x: 1600, y: 300 }, // Coin 4 position + { x: 1900, y: 400 }, // Coin 5 position + { x: 2200, y: 400 }, // Coin 6 position + { x: 2600, y: 400 }, // Coin 7 position + ], + enemies: [ + { + x: 1000, + y: 300, + spriteData: { + width: 128, + height: 128, + sprites: { + idle: { + src: "assets/images/sprites/enemies/wizard/Idle.png", + frames: 6, + speed: 5, + }, + run: { + src: "assets/images/sprites/enemies/wizard/Run.png", + frames: 8, + speed: 3, + }, + attack1: { + src: "assets/images/sprites/enemies/wizard/Attack_1.png", + frames: 10, + speed: 10, + }, + dead: { + src: "assets/images/sprites/enemies/wizard/Dead.png", + frames: 4, + speed: 10, + }, + hurt: { + src: "assets/images/sprites/enemies/wizard/Hurt.png", + frames: 4, + speed: 10, + }, + walk: { + src: "assets/images/sprites/enemies/wizard/Walk.png", + frames: 7, + speed: 5, + }, + }, + }, + }, + { + x: 1400, + y: 300, + spriteData: { + width: 128, + height: 128, + sprites: { + idle: { + src: "assets/images/sprites/enemies/wizard/Idle.png", + frames: 6, + speed: 5, + }, + run: { + src: "assets/images/sprites/enemies/wizard/Run.png", + frames: 8, + speed: 3, + }, + attack1: { + src: "assets/images/sprites/enemies/wizard/Attack_1.png", + frames: 10, + speed: 10, + }, + dead: { + src: "assets/images/sprites/enemies/wizard/Dead.png", + frames: 4, + speed: 10, + }, + hurt: { + src: "assets/images/sprites/enemies/wizard/Hurt.png", + frames: 4, + speed: 10, + }, + walk: { + src: "assets/images/sprites/enemies/wizard/Walk.png", + frames: 7, + speed: 5, + }, + }, + }, + }, + { + x: 1800, + y: 300, + spriteData: { + width: 128, + height: 128, + sprites: { + idle: { + src: "assets/images/sprites/enemies/wizard/Idle.png", + frames: 6, + speed: 5, + }, + run: { + src: "assets/images/sprites/enemies/wizard/Run.png", + frames: 8, + speed: 3, + }, + attack1: { + src: "assets/images/sprites/enemies/wizard/Attack_1.png", + frames: 10, + speed: 10, + }, + dead: { + src: "assets/images/sprites/enemies/wizard/Dead.png", + frames: 4, + speed: 10, + }, + hurt: { + src: "assets/images/sprites/enemies/wizard/Hurt.png", + frames: 4, + speed: 10, + }, + walk: { + src: "assets/images/sprites/enemies/wizard/Walk.png", + frames: 7, + speed: 5, + }, + }, + }, + }, + ], + npc: { + x: 300, + y: 300, + spriteData: { + width: 128, + height: 128, + sprites: { + idle: { + src: "assets/images/sprites/npc/archer/Idle.png", + frames: 6, + speed: 5, + }, + }, + }, + }, + npcDialogues: { + 0: "Greetings, adventurer!", + 1: "Dark times have befallen our forest.\nEvil wizards roam freely.", + 2: "Please, we need your strength.\nDefeat those wizards and reclaim the treasure they're guarding!", + default: "Good luck, brave soul!", + final: + "Well done, adventurer!\nThanks for dealing with those wizards. You saved us!", + }, + keyPosition: { x: 1800, y: 100 }, + chestPosition: { x: 2800, y: 460 }, + }, + { + missions: [ + "Find the Healer", // Mission 1 + "Defeat the Monsters", // Mission 2 + "Collect the Sacred Stone", // Mission 3 + "Open the Sacred Chest", // Mission 4 + "Return to the Healer", // Mission 5 + ], + coins: [ + { x: 500, y: 200 }, // Coin 1 position + { x: 800, y: 300 }, // Coin 2 position + { x: 1100, y: 200 }, // Coin 3 position + { x: 1400, y: 300 }, // Coin 4 position + { x: 1700, y: 200 }, // Coin 5 position + { x: 2000, y: 300 }, // Coin 6 position + { x: 2300, y: 400 }, // Coin 7 position + ], + enemies: [ + { + x: 1300, + y: 300, + spriteData: { + width: 96, + height: 96, + sprites: { + idle: { + src: "assets/images/sprites/enemies/monster/Idle.png", + frames: 2, + speed: 5, + }, + run: { + src: "assets/images/sprites/enemies/monster/Run.png", + frames: 6, + speed: 2, + }, + attack1: { + src: "assets/images/sprites/enemies/monster/Attack_1.png", + frames: 4, + speed: 5, + }, + attack2: { + src: "assets/images/sprites/enemies/monster/Attack_2.png", + frames: 5, + speed: 10, + }, + attack3: { + src: "assets/images/sprites/enemies/monster/Attack_3.png", + frames: 5, + speed: 10, + }, + runAttack: { + src: "assets/images/sprites/enemies/monster/Run+Attack.png", + frames: 6, + speed: 10, + }, + dead: { + src: "assets/images/sprites/enemies/monster/Dead.png", + frames: 4, + speed: 10, + }, + hurt: { + src: "assets/images/sprites/enemies/monster/Hurt.png", + frames: 4, + speed: 10, + }, + walk: { + src: "assets/images/sprites/enemies/monster/Walk.png", + frames: 7, + speed: 5, + }, + }, + }, + }, + { + x: 1600, + y: 300, + spriteData: { + width: 96, + height: 96, + sprites: { + idle: { + src: "assets/images/sprites/enemies/monster/Idle.png", + frames: 2, + speed: 5, + }, + run: { + src: "assets/images/sprites/enemies/monster/Run.png", + frames: 6, + speed: 2, + }, + attack1: { + src: "assets/images/sprites/enemies/monster/Attack_1.png", + frames: 4, + speed: 5, + }, + attack2: { + src: "assets/images/sprites/enemies/monster/Attack_2.png", + frames: 5, + speed: 10, + }, + attack3: { + src: "assets/images/sprites/enemies/monster/Attack_3.png", + frames: 5, + speed: 10, + }, + runAttack: { + src: "assets/images/sprites/enemies/monster/Run+Attack.png", + frames: 6, + speed: 10, + }, + dead: { + src: "assets/images/sprites/enemies/monster/Dead.png", + frames: 4, + speed: 10, + }, + hurt: { + src: "assets/images/sprites/enemies/monster/Hurt.png", + frames: 4, + speed: 10, + }, + walk: { + src: "assets/images/sprites/enemies/monster/Walk.png", + frames: 7, + speed: 5, + }, + }, + }, + }, + { + x: 1900, + y: 300, + spriteData: { + width: 96, + height: 96, + sprites: { + idle: { + src: "assets/images/sprites/enemies/monster/Idle.png", + frames: 2, + speed: 5, + }, + run: { + src: "assets/images/sprites/enemies/monster/Run.png", + frames: 6, + speed: 2, + }, + attack1: { + src: "assets/images/sprites/enemies/monster/Attack_1.png", + frames: 4, + speed: 5, + }, + attack2: { + src: "assets/images/sprites/enemies/monster/Attack_2.png", + frames: 5, + speed: 10, + }, + attack3: { + src: "assets/images/sprites/enemies/monster/Attack_3.png", + frames: 5, + speed: 10, + }, + runAttack: { + src: "assets/images/sprites/enemies/monster/Run+Attack.png", + frames: 6, + speed: 10, + }, + dead: { + src: "assets/images/sprites/enemies/monster/Dead.png", + frames: 4, + speed: 10, + }, + hurt: { + src: "assets/images/sprites/enemies/monster/Hurt.png", + frames: 4, + speed: 10, + }, + walk: { + src: "assets/images/sprites/enemies/monster/Walk.png", + frames: 7, + speed: 5, + }, + }, + }, + }, + { + x: 2200, + y: 300, + spriteData: { + width: 96, + height: 96, + sprites: { + idle: { + src: "assets/images/sprites/enemies/monster/Idle.png", + frames: 2, + speed: 5, + }, + run: { + src: "assets/images/sprites/enemies/monster/Run.png", + frames: 6, + speed: 2, + }, + attack1: { + src: "assets/images/sprites/enemies/monster/Attack_1.png", + frames: 4, + speed: 5, + }, + attack2: { + src: "assets/images/sprites/enemies/monster/Attack_2.png", + frames: 5, + speed: 10, + }, + attack3: { + src: "assets/images/sprites/enemies/monster/Attack_3.png", + frames: 5, + speed: 10, + }, + runAttack: { + src: "assets/images/sprites/enemies/monster/Run+Attack.png", + frames: 6, + speed: 10, + }, + dead: { + src: "assets/images/sprites/enemies/monster/Dead.png", + frames: 4, + speed: 10, + }, + hurt: { + src: "assets/images/sprites/enemies/monster/Hurt.png", + frames: 4, + speed: 10, + }, + walk: { + src: "assets/images/sprites/enemies/monster/Walk.png", + frames: 7, + speed: 5, + }, + }, + }, + }, + ], + npc: { + x: 300, + y: 300, + spriteData: { + width: 128, + height: 128, + sprites: { + idle: { + src: "assets/images/sprites/npc/healer/Idle.png", + frames: 5, + speed: 5, + }, + }, + }, + }, + npcDialogues: { + 0: "Welcome back, hero!", + 1: "We are in desperate need of your help again.\nMonsters have invaded our land.\n They will hurt our people if we don't stop them!", + 2: "Please defeat those monsters.\nThere will be a treasure waiting for you as a reward!", + default: "Best of luck, brave soul. Please be careful!", + final: "You've done it!\nOur land is safe once again. Thank you!", + }, + keyPosition: { x: 2000, y: 150 }, + chestPosition: { x: 2800, y: 460 }, + }, + // Add more levels here... +]; diff --git a/Games/Quest_For_Riches/js/npc.js b/Games/Quest_For_Riches/js/npc.js new file mode 100644 index 0000000000..4a746173fd --- /dev/null +++ b/Games/Quest_For_Riches/js/npc.js @@ -0,0 +1,226 @@ +/** + * Represents a Non-Player Character (NPC) in the game. + */ +class NPC { + /** + * Creates a new NPC instance. + * @param {number} x - The x-coordinate of the NPC. + * @param {number} y - The y-coordinate of the NPC. + * @param {Object} spriteData - The data for the NPC's sprite. + * @param {number} spriteData.width - The width of a single frame in the sprite. + * @param {number} spriteData.height - The height of a single frame in the sprite. + * @param {Object} spriteData.sprites - An object containing sprite animations and their details. + */ + constructor(x, y, spriteData) { + this.position = { x, y }; + this.width = spriteData.width; // Width of a single frame + this.height = spriteData.height; // Height of a single frame + this.scale = 2; // Scale factor + this.scaledWidth = this.width * this.scale; + this.scaledHeight = this.height * this.scale; + this.direction = "left"; // Initial direction the NPC is facing + this.isChatting = false; // Flag to indicate if the NPC is chatting + this.dialogueState = 0; // Track the dialogue state + this.finalDialogueDone = false; // Flag to check if the final dialogue is done + + this.chatBubble = document.createElement("div"); + this.chatBubble.classList.add("chatBubble"); + document.body.appendChild(this.chatBubble); + this.promptE = document.createElement("div"); + this.promptE.classList.add("promptE"); + this.promptE.innerText = "E"; + document.body.appendChild(this.promptE); + + // Load the sprite sheet + this.sprites = spriteData.sprites; + this.loaded = false; // Flag to check if images are loaded + this.currentSprite = "idle"; + this.frameIndex = 0; + this.frameSpeed = this.sprites[this.currentSprite].speed; + this.frameTick = 0; + + // Load images + const img = new Image(); + img.src = this.sprites[this.currentSprite].src; + img.onload = () => { + this.loaded = true; + }; + this.sprites[this.currentSprite].img = img; + } + + /** + * Resets the NPC's state to its initial values. + */ + resetState() { + this.isChatting = false; + this.dialogueState = 0; + this.finalDialogueDone = false; + this.hideChatBubble(); + this.hidePromptE(); + } + + /** + * Draws the NPC on the canvas. + * @param {number} cameraOffsetX - The offset of the camera on the x-axis. + */ + draw(cameraOffsetX) { + if (!this.loaded) return; // Only draw if images are loaded + + const sprite = this.sprites[this.currentSprite]; + const sx = this.frameIndex * this.width; + const sy = 0; + + // Save the current context state + c.save(); + + if (this.direction === "left") { + // Flip the context horizontally + c.scale(-1, 1); + // Draw the image flipped + c.drawImage( + sprite.img, + sx, + sy, + this.width, + this.height, + -(this.position.x - cameraOffsetX + this.scaledWidth), + this.position.y, + this.scaledWidth, + this.scaledHeight + ); + } else { + // Draw the image normally + c.drawImage( + sprite.img, + sx, + sy, + this.width, + this.height, + this.position.x - cameraOffsetX, + this.position.y, + this.scaledWidth, + this.scaledHeight + ); + } + + // Restore the context state + c.restore(); + } + + /** + * Displays the prompt 'E' above the NPC when the player is in proximity. + * @param {number} cameraOffsetX - The offset of the camera on the x-axis. + */ + showPromptE(cameraOffsetX) { + const promptX = this.position.x - cameraOffsetX + this.scaledWidth / 2; + const promptY = this.position.y - 30; // Above the NPC + + // Get canvas position + const canvasRect = document.querySelector("canvas").getBoundingClientRect(); + + // Adjust prompt position based on canvas position + this.promptE.style.left = `${canvasRect.left + promptX - 10}px`; + this.promptE.style.top = `${canvasRect.top + promptY - 20}px`; + this.promptE.style.display = "block"; + } + + /** + * Hides the prompt 'E'. + */ + hidePromptE() { + this.promptE.style.display = "none"; + } + + /** + * Displays a chat bubble above the NPC with the given text. + * @param {number} cameraOffsetX - The offset of the camera on the x-axis. + * @param {string} text - The text to display in the chat bubble. + */ + showChatBubble(cameraOffsetX, text) { + const bubbleX = this.position.x - cameraOffsetX + this.scaledWidth / 2; + const bubbleY = this.position.y - 100; // Above the NPC + + // Get canvas position + const canvasRect = document.querySelector("canvas").getBoundingClientRect(); + + // Adjust bubble position based on canvas position + this.chatBubble.style.left = `${canvasRect.left + bubbleX}px`; + this.chatBubble.style.top = `${canvasRect.top + bubbleY}px`; + this.chatBubble.innerHTML = text.replace(/\n/g, "
    "); + this.chatBubble.style.display = "block"; + } + + /** + * Hides the chat bubble. + */ + hideChatBubble() { + this.chatBubble.style.display = "none"; + } + + /** + * Updates the NPC's state and handles interactions with the player. + * @param {number} cameraOffsetX - The offset of the camera on the x-axis. + * @param {Player} player - The player instance. + */ + update(cameraOffsetX, player) { + // Update the frame index for animation + this.frameTick++; + if (this.frameTick >= this.frameSpeed) { + this.frameTick = 0; + const sprite = this.sprites[this.currentSprite]; + this.frameIndex = (this.frameIndex + 1) % sprite.frames; + } + + this.draw(cameraOffsetX); + + // Check if player is in proximity + const proximityRangeX = 150; // Range for X-axis proximity + const proximityRangeY = 100; // Range for Y-axis proximity + const inProximity = + Math.abs(this.position.x - player.position.x) < proximityRangeX && + Math.abs(this.position.y - player.position.y) < proximityRangeY; + + if (inProximity && !this.isChatting) { + this.showPromptE(cameraOffsetX); + if (player.isInteracting) { + this.isChatting = true; + audioManager.playSound("chat"); // Play chat sound + } + } else { + this.hidePromptE(); + if (!inProximity) { + this.isChatting = false; + this.dialogueState = 0; // Reset dialogue state when out of proximity + } + } + + // Draw chat bubble if chatting + if (this.isChatting) { + let chatText = level.getNPCDialogue( + this.dialogueState, + player.hasCollectedTreasure + ); + this.showChatBubble(cameraOffsetX, chatText); + } else { + this.hideChatBubble(); + } + } + + /** + * Handles player interactions with the NPC, such as progressing dialogue. + * @param {Player} player - The player instance. + */ + interact(player) { + if (this.isChatting) { + if (this.finalDialogueDone) { + endLevel(); // Show the transition screen after final dialogue + } else if (player.hasCollectedTreasure) { + this.dialogueState = 0; // Reset dialogue state after completion + this.finalDialogueDone = true; // Set flag for final dialogue + } else { + this.dialogueState = (this.dialogueState + 1) % 4; // Cycle through dialogue states + audioManager.playSound("chat"); // Play chat sound when interaction changes the dialogue state + } + } + } +} diff --git a/Games/Quest_For_Riches/js/player.js b/Games/Quest_For_Riches/js/player.js new file mode 100644 index 0000000000..b805dbd74a --- /dev/null +++ b/Games/Quest_For_Riches/js/player.js @@ -0,0 +1,262 @@ +/** + * Represents the player in the game. + */ +class Player { + /** + * Creates a new player instance. + */ + constructor() { + this.position = { x: 50, y: 50 }; // Initial position of the player + this.velocity = { x: 0, y: 0 }; // Initial velocity of the player + + this.originalWidth = 128; // Original frame width + this.originalHeight = 128; // Original frame height + this.scale = 2; // Scale factor to make the character larger + this.width = this.originalWidth * this.scale; // Scaled width + this.height = this.originalHeight * this.scale; // Scaled height + this.sides = { bottom: this.position.y + this.height }; + this.gravity = 0.3; + this.direction = "right"; // Initial direction + this.health = 20; // Player health + this.attackCooldown = 0; // Cooldown for attacking + this.isAttacking = false; // Flag to indicate if the player is attacking + this.coins = 0; // Player coin count + this.hasKey = false; // Flag to indicate if the player has the key + this.hasCollectedTreasure = false; // Flag to indicate if the player has collected the treasure + + // Load sprite sheets + this.sprites = { + idle: { + src: "assets/images/sprites/player/Idle.png", + frames: 8, + speed: 5, + }, + run: { src: "assets/images/sprites/player/Run.png", frames: 8, speed: 5 }, + jump: { + src: "assets/images/sprites/player/Jump.png", + frames: 8, + speed: 5, + }, + walk: { + src: "assets/images/sprites/player/Walk.png", + frames: 8, + speed: 5, + }, + attack: { + src: "assets/images/sprites/player/Attack_3.png", + frames: 4, + speed: 10, + }, + hurt: { + src: "assets/images/sprites/player/Hurt.png", + frames: 4, + speed: 10, + }, + dead: { + src: "assets/images/sprites/player/Dead.png", + frames: 4, + speed: 10, + }, + }; + + // Initialize current animation + this.currentSprite = "idle"; + this.frameIndex = 0; + this.frameSpeed = this.sprites[this.currentSprite].speed; + this.frameTick = 0; + + // Load images + for (let key in this.sprites) { + const img = new Image(); + img.src = this.sprites[key].src; + this.sprites[key].img = img; + } + } + + /** + * Sets the player's current animation. + * @param {string} animation - The name of the animation to set. + */ + setAnimation(animation) { + if (this.currentSprite !== animation) { + this.currentSprite = animation; + this.frameIndex = 0; // Reset frame index + this.frameSpeed = this.sprites[animation].speed; // Update frame speed + } + } + + /** + * Draws the player on the canvas. + * @param {number} cameraOffsetX - The offset of the camera on the x-axis. + */ + draw(cameraOffsetX) { + const sprite = this.sprites[this.currentSprite]; + const sx = this.frameIndex * this.originalWidth; + const sy = 0; + + // Save the current context state + c.save(); + + if (this.direction === "left") { + // Flip the context horizontally + c.scale(-1, 1); + // Draw the image flipped + c.drawImage( + sprite.img, + sx, + sy, + this.originalWidth, + this.originalHeight, + -this.position.x - this.width + cameraOffsetX, + this.position.y, + this.width, + this.height + ); + } else { + // Draw the image normally + c.drawImage( + sprite.img, + sx, + sy, + this.originalWidth, + this.originalHeight, + this.position.x - cameraOffsetX, + this.position.y, + this.width, + this.height + ); + } + + // Restore the context state + c.restore(); + } + + /** + * Draws the player's health bar on the screen. + */ + drawHealthBar() { + c.fillStyle = "red"; + c.fillRect(10, 10, this.health * 10, 20); + c.strokeStyle = "black"; + c.strokeRect(10, 10, 200, 20); + } + + /** + * Draws the player's coin count on the screen. + */ + drawCoinCount() { + // Draw coin icon + const coinImg = new Image(); + coinImg.src = "assets/images/sprites/gold_coin.png"; + c.drawImage(coinImg, 220, 10, 30, 30); + + // Draw coin count + c.fillStyle = "white"; + c.font = "24px Arial"; + c.fillText(`x ${this.coins}`, 250, 30); + } + + /** + * Draws the key indicator on the screen if the player has the key. + */ + drawKeyIndicator() { + if (this.hasKey) { + // Draw key icon + const keyImg = new Image(); + keyImg.src = "assets/images/sprites/gold_key.png"; + c.drawImage(keyImg, 320, 10, 30, 30); + } + } + + /** + * Handles the player taking damage. + */ + takeDamage() { + if (this.currentSprite !== "dead") { + this.health -= 1; + if (this.health <= 0) { + this.setAnimation("dead"); + setTimeout(() => { + // Restart the game or show game over screen + window.location.reload(); + }, (this.sprites.dead.frames * this.frameSpeed * 1000) / 60); // Duration of the dead animation + } else { + this.setAnimation("hurt"); + setTimeout(() => { + this.setAnimation("idle"); + }, (this.sprites.hurt.frames * this.frameSpeed * 1000) / 60); // Duration of the hurt animation + } + } + } + + /** + * Handles the player attacking. + */ + attack() { + if (this.attackCooldown <= 0) { + this.setAnimation("attack"); + this.attackCooldown = 60; // Cooldown for 1 second assuming 60 FPS + this.isAttacking = true; // Set the attacking flag to true + } + } + + /** + * Updates the player's state and position. + * @param {number} cameraOffsetX - The offset of the camera on the x-axis. + */ + update(cameraOffsetX) { + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + this.sides.bottom = this.position.y + this.height; + + // Apply gravity + if (this.sides.bottom + this.velocity.y < canvas.height) { + this.velocity.y += this.gravity; + } else { + this.velocity.y = 0; + if (this.currentSprite === "jump") { + // Reset to run if moving horizontally, otherwise idle + if (keys.a.pressed || keys.d.pressed) { + this.setAnimation("run"); + } else { + this.setAnimation("idle"); + } + } + } + + // Ensure the player stays within the game world bounds + if (this.position.x < 0) { + this.position.x = 0; + } else if (this.position.x + this.width > GAME_WORLD_WIDTH) { + this.position.x = GAME_WORLD_WIDTH - this.width; + } + + // Update the frame index for animation + this.frameTick++; + if (this.frameTick >= this.frameSpeed) { + this.frameTick = 0; + const sprite = this.sprites[this.currentSprite]; + this.frameIndex = (this.frameIndex + 1) % sprite.frames; + + // If the current animation is attack and it reaches the last frame, revert to idle or run + if (this.currentSprite === "attack" && this.frameIndex === 0) { + this.isAttacking = false; // Reset attacking flag + if (keys.a.pressed || keys.d.pressed) { + this.setAnimation("run"); + } else { + this.setAnimation("idle"); + } + } + } + + // Handle attack cooldown + if (this.attackCooldown > 0) { + this.attackCooldown--; + } + + this.draw(cameraOffsetX); + this.drawHealthBar(); + this.drawCoinCount(); // Draw the coin count on the screen + this.drawKeyIndicator(); // Draw the key indicator on the screen + } +} diff --git a/Games/Sliding_puzzle/Readme.md b/Games/Sliding_puzzle/Readme.md new file mode 100644 index 0000000000..3f091d2665 --- /dev/null +++ b/Games/Sliding_puzzle/Readme.md @@ -0,0 +1,23 @@ +## Sliding Puzzle + +Sliding Puzzle is a single-player puzzle game. The goal of the game is to rearrange the numbered tiles in order from 1 to 15, with the empty space being the last tile. You can move the tiles by swiping in the direction of the empty space. + +The game keeps track of your score and time. The score is incremented every time you move a tile. The timer starts when you begin a new game and stops when you solve the puzzle. + +### How to Play + +1. Tap "New Game" to start a new game. +2. Click a tile to make it move in the direction of the empty space. +3. Continue swiping tiles until the puzzle is solved (numbers are in order from 1 to 15). + +### Tips + +* Plan your moves ahead of time. +* Try to work on getting the corner pieces in place first. +* There are many different ways to solve the puzzle. Experiment and find what works best for you. + +I hope you enjoy playing Sliding Puzzle! + +Here's an image of the game window. + +![Screenshot 2024-06-21 005055](https://github.com/kunjgit/GameZone/assets/141642724/fc66d8b7-1f5a-4a1e-a0d9-d6ea0d5d7fcf) \ No newline at end of file diff --git a/Games/Sliding_puzzle/index.html b/Games/Sliding_puzzle/index.html new file mode 100644 index 0000000000..2e139fceda --- /dev/null +++ b/Games/Sliding_puzzle/index.html @@ -0,0 +1,52 @@ + + + + + + + Document + + + + + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Sliding Puzzle

    +
    +
    +
    Score
    +
    0
    +
    Time
    +
    0
    +
    +
    + +
    +
    + + + + diff --git a/Games/Sliding_puzzle/main.js b/Games/Sliding_puzzle/main.js new file mode 100644 index 0000000000..bda2c7920e --- /dev/null +++ b/Games/Sliding_puzzle/main.js @@ -0,0 +1,178 @@ +let board =[]; +let moves =0; +let seconds=0; +let tileContainer = document.querySelector(".tileContainer"); +let moveElement = document.getElementById("moveElement"); +let timerElement = document.getElementById("timer"); +let intervalId; +const alert = document.getElementById("alert"); + +createBoard(); +fillBoard(); + +function createBoard() { + for(let i=0;i<4;i++) { + let row=[]; + for(let j=0;j<4;j++) { + row.push(0); + } + board.push(row); + } +} + +function fillBoard() { + let numbers = Array.from({length:15},(_,i)=>i+1); + numbers.push(null); + let emptyIndex = numbers.length-1; + for (let i=0;i<1000;i++) { + let swapIndex = getRandomValidMove(emptyIndex); + [numbers[emptyIndex],numbers[swapIndex]] = [numbers[swapIndex],numbers[emptyIndex]] ; + emptyIndex = swapIndex; + } + let index = 0; + for (let y=3;y>=0;y--) { + for (let x=0;x<4;x++) { + if(index0) validMoves.push(emptyIndex-1); + if(x<3) validMoves.push(emptyIndex+1); + if(y>0) validMoves.push(emptyIndex-4); + if(y<3) validMoves.push(emptyIndex+4); + + return validMoves[Math.floor(Math.random()*validMoves.length)]; +} + +function addTileAt(x,y,value) { + board[x][y] = value; + addTileToPage(x,y,board[x][y]); +} + +function addTileToPage(row,column,value) { + let tile = document.createElement("div"); + tile.classList.add( + "tile", + "row"+(row+1), + "column"+(column+1), + "value"+value + ); + tile.innerHTML = value; + tileContainer.appendChild(tile); +} + +function startNewGame() { + alert.style.display = "none"; + tileContainer.innerHTML = ""; + moveElement.innerHTML =0; + timerElement.innerHTML = 0; + board = []; + moves = 0; + seconds = 0; + createBoard(); + fillBoard(); + window.onload = addClickEventToTiles(); + stopTimer(); +} + +function startTimer() { + intervalId = setInterval(function(){ + seconds++; + timerElement.innerHTML = seconds; + },1000); +} + +function stopTimer() { + clearInterval(intervalId); +} + +window.onload = addClickEventToTiles(); + +function addClickEventToTiles() { + let tiles = document.querySelectorAll(".tile"); + tiles.forEach(function(tile){ + tile.addEventListener("click",onTileClick); + }); +} + +function onTileClick(event) { + if(moves ==0) + startTimer(); + let [row,column] = getRowAndColumn(event.target); + moveTiles(row-1,column-1); + let gameOver = isGameOver(); + if(gameOver){ + showAlert(); + stopTimer(); + } +} + +function getRowAndColumn(element) { + let classes = element.classList; + let row,column; + for (let i=0;i=0 && newX<4 && newY>=0 && newY<4 && board[newX][newY]=== 0) { + board[newX][newY] = board[x][y]; + board[x][y] = 0; + let tileClass = ".row"+(x+1)+".column"+(y+1); + let tile = document.querySelector(tileClass); + moveTileOnPage(newX,newY,tile); + moves++; + moveElement.innerHTML = moves; + break; + } + } +} + +function moveTileOnPage(row,column,tile) { + let classes = Array.from(tile.classList); + classes.forEach((className)=>{ + if(className.startsWith("row") || className.startsWith("column")) { + tile.classList.remove(className); + } + }); + tile.classList.add("row"+(row+1),"column"+(column+1)); +} + +function isGameOver() { + for(let i=0;i<15;i++) { + if(board[3-Math.floor(i/4)][i%4]!== i+1) { + return false; + } + } + return board[0][3]===0; +} + +function showAlert() { + alert.innerHTML = '
    You won!
    '; + alert.style.display = "flex"; + alert.style.flexDirection = "column"; + stopTimer(); +} \ No newline at end of file diff --git a/Games/Sliding_puzzle/style.css b/Games/Sliding_puzzle/style.css new file mode 100644 index 0000000000..d7a3b74541 --- /dev/null +++ b/Games/Sliding_puzzle/style.css @@ -0,0 +1,166 @@ +body{ + display: flex; + background: whitesmoke; + align-items: center; + justify-content: center; + font-family: Arial, Helvetica, sans-serif; + } + .container { + position: relative; + display: flex; + flex-direction: row; + } + .board { + display: flex; + width: 40vw; + height: 40vw; + flex-wrap: wrap; + align-items: center; + justify-content: center; + border-radius: 5px; + padding-top: 10px; + padding-bottom: 10px; + background-color: #313231; + } + .square { + display: flex; + width: 22%; + height: 22%; + margin: 1%; + border-radius: 3px; + background: #dce4e7; + justify-content: center; + align-items: center; + position: relative; + } + .elementContainer { + margin-bottom: 70px; + } + .title{ + display: flex; + align-items: center; + justify-content: center; + margin-left: 10px; + } + h1 { + font-size: 20px; + color:black; + } + .moveElementContainer { + display: flex; + flex-direction: column; + background: #313231; + padding:15px 25px; + font-size: 25px; + font-weight: bold; + border-radius: 3px; + color: white; + text-align: center; + margin-left: 10px; + } + + #moveLabel,#timerLabel { + color:whitesmoke; + font-size: 20px; + } + button { + width:180px; + height: 50px; + outline: none; + font-size: large; + font-weight: bold; + background-color: #313231; + color:#f9f6f2; + border: none; + border-radius: 3px; + margin-left: 10px; + margin-top: 10px; + cursor: pointer; + } + + .tile { + width: 22%; + height: 22%; + display: flex; + z-index: 1; + align-items: center; + justify-content: center; + font-size: 50px; + font-weight: bold; + position: absolute; + color:whitesmoke; + background-color: #3db1a6; + transition: top 0.25s, left 0.25s; + } + + .row1{ + top:75%; + } + .row2{ + top:51%; + } + .row3{ + top:27%; + } + .row4{ + top:3%; + } + + .column1{ + left:3%; + } + .column2{ + left:27%; + } + .column3{ + left:51%; + } + .column4{ + left:75%; + } + + #alert { + color:#19b188; + background: rgba(238, 228, 218, 0.73); + font-size: 60px; + font-weight: bold; + width: 100%; + height: 100%; + justify-content: center; + align-items: center; + display: none; + position: absolute; + z-index: 3; + } + + @media(max-width:600px) { + body{ + flex-wrap: wrap; + } + .elementContainer { + margin: 0; + } + .tile{ + font-size: 20px; + } + h1 { + font-size:14px; + } + button { + width: 100px; + height: 30px; + font-size: small; + } + .moveElementContainer,#moveLabel,#timerLabel{ + font-size: 14px; + } + #moveLabel { + font-size: 14px; + } + .board{ + padding-top: 5px; + padding-bottom: 5px; + width: 60vw; + height: 60vw; + } + } \ No newline at end of file diff --git a/Games/SnakeBites/README.md b/Games/SnakeBites/README.md new file mode 100644 index 0000000000..d522933d72 --- /dev/null +++ b/Games/SnakeBites/README.md @@ -0,0 +1,42 @@ +# **SnakeBites Game** + +--- + +
    + +## **Description 📃** +- This project is built on a basic web tech stacks such as HTML, CSS and Javascript. +- This game is just for fun. + +## **functionalities 🎮** +- This game is a single player game. +- Using Up, Down, Left and Right Arrows, move the snake. +- By eating food, score will increase. +- High score will be updated when current score will be more than the high score. + +## ** Additional Features ** +- Displaying the current score and high score of the player. +- Implementing a graphical user interface (GUI) for a more interactive experience. +- Adding background sound and moving snake and eating food sounds. + +
    + +## **How to play? 🕹️** +- This is a single player game. +- Using Up, Down, Left and Right Arrows, move the snake in such a way it does not touch the boundaries and also not the snake body. +- If head of the snake smash into their body and the boundaries, will result into **"GAME OVER"** +- By eating the food, score will increase. + +
    + +## **Screenshots 📸** + +
    + +![image](../SnakeBites/images/Snake-game.png) + +
    + +## **Working video 📹** + + diff --git a/Games/SnakeBites/Snake_Bites.css b/Games/SnakeBites/Snake_Bites.css new file mode 100644 index 0000000000..7e50f64947 --- /dev/null +++ b/Games/SnakeBites/Snake_Bites.css @@ -0,0 +1,111 @@ +:root{ + --background: #d9d9d9; + --color: #ffc300; + --accent: #000814; + --shade: #001d3d; +} +*{ + padding: 0; + margin: 0; + box-sizing: border-box; + text-align: center; + font-family: 'Lato', sans-serif; +} +body{ + background-color:#fdf0d5; +} +.body{ + display: flex; + justify-content: center; + align-items: center; +} +img{ + position: fixed; + bottom: 0; + right: 0; + height:300px; + object-fit: cover; +} +h1{ + position: absolute; + top: 15px; + left: 20px; + font-size: 50px; + font-family: 'Rubik', sans-serif; + color: var(--accent); +} +#scoreBox{ + position: absolute; + top: 80px; + left: 20px; + font-size: 20px; +} +#hiscoreBox{ + position: absolute; + top: 80px; + left: 200px; + font-size: 20px; +} +#board{ + background: linear-gradient(var(--accent), #669bbc); + width: 90vmin; + height: 92vmin; + margin-top: 25px; + box-shadow: 0px 0px 10px 2px rgb(25, 26, 27) ; + display:grid; + grid-template-rows: repeat(18, 1fr); + grid-template-columns: repeat(18, 1fr); +} +.head{ + background: linear-gradient(#780000, #c1121f); + box-shadow: 0px 0px 5px 2px rgb(25, 26, 27) ; + border: 0.25vmin solid black; + border-radius: 9px; + transform:scale(1.02); + +} +.snake{ + background-color: #c1121f; + box-shadow: 0px 0px 5px 2px rgb(25, 26, 27) ; + border-radius: 12px; +} +.food{ + background: linear-gradient(#ee9b00, #e9d8a6); + border: 0.5vmin solid #e76f51; + border-radius: 8px; +} +.back{ + all: unset; + position:fixed; + top:25px; + right:30px; + background-color: var(--accent); + color: var(--color); + padding: 15px; + border-radius: 1rem; +} + +@media screen and (max-width:1000px) { + .body{ + flex-direction: column; + margin: 8% 0; + } + img{ + display: none; + } + h1{ + position: relative; + text-align: center; + } + #scoreBox{ + left: 5px; + } + #hiscoreBox{ + left:100px; + } + .back{ + top:70px; + right:25px; + font-size: 10px; + } +} \ No newline at end of file diff --git a/Games/SnakeBites/Snake_Bites.html b/Games/SnakeBites/Snake_Bites.html new file mode 100644 index 0000000000..832b9f6dcc --- /dev/null +++ b/Games/SnakeBites/Snake_Bites.html @@ -0,0 +1,31 @@ + + + + + + + + + + + + + Snake-Bites + + + +
    +

    Snake Bites

    + + +
    +
    Score: 0
    +
    High Score: 0
    +
    +
    +
    + + + + + \ No newline at end of file diff --git a/Games/SnakeBites/Snake_Bites.js b/Games/SnakeBites/Snake_Bites.js new file mode 100644 index 0000000000..c715b0bfa8 --- /dev/null +++ b/Games/SnakeBites/Snake_Bites.js @@ -0,0 +1,141 @@ +// Game Constants & Variables +let inputDir = {x: 0, y: 0}; +const foodSound = new Audio('food.mp3'); +const gameOverSound = new Audio('gameover.mp3'); +const moveSound = new Audio('move.mp3'); +const musicSound = new Audio('music.mp3'); +let speed = prompt("Enter speed of the Snake you want: (5: easy, 10: medium, >15: hard)"); +let score = 0; +let lastPaintTime = 0; +let snakeArr = [ + {x: 13, y: 15} +]; + +food = {x: 6, y: 7}; + +// Game Functions +function main(ctime) { + window.requestAnimationFrame(main); + if((ctime - lastPaintTime)/1000 < 1/speed){ + return; + } + musicSound.play(); + lastPaintTime = ctime; + gameEngine(); +} + +function isCollide(snake) { + // If you bump into yourself + for (let i = 1; i < snakeArr.length; i++) { + if(snake[i].x === snake[0].x && snake[i].y === snake[0].y){ + return true; + } + } + // If you bump into the wall + if(snake[0].x >= 18 || snake[0].x <=0 || snake[0].y >= 18 || snake[0].y <=0){ + return true; + } + + return false; +} + +function gameEngine(){ + // Part 1: Updating the snake array & Food + if(isCollide(snakeArr)){ + gameOverSound.play(); + musicSound.pause(); + inputDir = {x: 0, y: 0}; + alert("Game Over. Press any key to play again!"); + snakeArr = [{x: 13, y: 15}]; + score = 0; + } + + // If you have eaten the food, increment the score and regenerate the food + if(snakeArr[0].y === food.y && snakeArr[0].x ===food.x){ + foodSound.play(); + score += 1; + if(score>hiscoreval){ + hiscoreval = score; + localStorage.setItem("hiscore", JSON.stringify(hiscoreval)); + hiscoreBox.innerHTML = "HiScore: " + hiscoreval; + } + scoreBox.innerHTML = "Score: " + score; + snakeArr.unshift({x: snakeArr[0].x + inputDir.x, y: snakeArr[0].y + inputDir.y}); + let a = 2; + let b = 16; + food = {x: Math.round(a + (b-a)* Math.random()), y: Math.round(a + (b-a)* Math.random())} + } + + // Moving the snake + for (let i = snakeArr.length - 2; i>=0; i--) { + snakeArr[i+1] = {...snakeArr[i]}; + } + + snakeArr[0].x += inputDir.x; + snakeArr[0].y += inputDir.y; + + // Part 2: Display the snake and Food + // Display the snake + board.innerHTML = ""; + snakeArr.forEach((e, index)=>{ + snakeElement = document.createElement('div'); + snakeElement.style.gridRowStart = e.y; + snakeElement.style.gridColumnStart = e.x; + + if(index === 0){ + snakeElement.classList.add('head'); + } + else{ + snakeElement.classList.add('snake'); + } + board.appendChild(snakeElement); + }); + // Display the food + foodElement = document.createElement('div'); + foodElement.style.gridRowStart = food.y; + foodElement.style.gridColumnStart = food.x; + foodElement.classList.add('food') + board.appendChild(foodElement); +} + +// Main logic starts here +musicSound.play(); +let hiscore = localStorage.getItem("hiscore"); +if(hiscore === null){ + hiscoreval = 0; + localStorage.setItem("hiscore", JSON.stringify(hiscoreval)) +} +else{ + hiscoreval = JSON.parse(hiscore); + hiscoreBox.innerHTML = "HiScore: " + hiscore; +} + +window.requestAnimationFrame(main); +window.addEventListener('keydown', e =>{ + inputDir = {x: 0, y: 1} // Start the game + moveSound.play(); + switch (e.key) { + case "ArrowUp": + inputDir.x = 0; + inputDir.y = -1; + break; + + case "ArrowDown": + inputDir.x = 0; + inputDir.y = 1; + break; + + case "ArrowLeft": + inputDir.x = -1; + inputDir.y = 0; + break; + + case "ArrowRight": + inputDir.x = 1; + inputDir.y = 0; + break; + default: + break; + } + +}); \ No newline at end of file diff --git a/Games/SnakeBites/food.mp3 b/Games/SnakeBites/food.mp3 new file mode 100644 index 0000000000..076198c984 Binary files /dev/null and b/Games/SnakeBites/food.mp3 differ diff --git a/Games/SnakeBites/gameover.mp3 b/Games/SnakeBites/gameover.mp3 new file mode 100644 index 0000000000..414bf65143 Binary files /dev/null and b/Games/SnakeBites/gameover.mp3 differ diff --git a/Games/SnakeBites/images/Snake-game.png b/Games/SnakeBites/images/Snake-game.png new file mode 100644 index 0000000000..e93bab58e4 Binary files /dev/null and b/Games/SnakeBites/images/Snake-game.png differ diff --git a/Games/SnakeBites/images/logo.jpeg b/Games/SnakeBites/images/logo.jpeg new file mode 100644 index 0000000000..3b86b8c06b Binary files /dev/null and b/Games/SnakeBites/images/logo.jpeg differ diff --git a/Games/SnakeBites/images/snake.gif b/Games/SnakeBites/images/snake.gif new file mode 100644 index 0000000000..44d0e7b985 Binary files /dev/null and b/Games/SnakeBites/images/snake.gif differ diff --git a/Games/SnakeBites/move.mp3 b/Games/SnakeBites/move.mp3 new file mode 100644 index 0000000000..4d3d245db4 Binary files /dev/null and b/Games/SnakeBites/move.mp3 differ diff --git a/Games/SnakeBites/music.mp3 b/Games/SnakeBites/music.mp3 new file mode 100644 index 0000000000..f1507af376 Binary files /dev/null and b/Games/SnakeBites/music.mp3 differ diff --git a/Games/SnakeBites/snakebites.mp4 b/Games/SnakeBites/snakebites.mp4 new file mode 100644 index 0000000000..4432a24f61 Binary files /dev/null and b/Games/SnakeBites/snakebites.mp4 differ diff --git a/Games/Spell_Bee/README.md b/Games/Spell_Bee/README.md new file mode 100644 index 0000000000..d1c9742626 --- /dev/null +++ b/Games/Spell_Bee/README.md @@ -0,0 +1,19 @@ +# Spell Bee + +The game is based on real life spelling bee competition. Listen to word and Enter correct spelling of that word. + +# How to Play + +To begin playing, click on "Begin" button and game will start. Player can listen to the pronunciation of word and can type in the answer bar. +Player can also listen to the word used in a sentence or can see its meaning for proper guessin but it will charge him some score points. + + +# Scores + +Score points are awareded and deducted based on: + 1. Correct Answer +5 points + 2. Speak Sentence -2 points + 3. Show Meaning -1 point. + +# Contributed by : +https://github.com/Markcosay \ No newline at end of file diff --git a/Games/Spell_Bee/Spell Bee.png b/Games/Spell_Bee/Spell Bee.png new file mode 100644 index 0000000000..dd31cfccd1 Binary files /dev/null and b/Games/Spell_Bee/Spell Bee.png differ diff --git a/Games/Spell_Bee/assets/spell_bee_screenshot.png b/Games/Spell_Bee/assets/spell_bee_screenshot.png new file mode 100644 index 0000000000..87720cc939 Binary files /dev/null and b/Games/Spell_Bee/assets/spell_bee_screenshot.png differ diff --git a/Games/Spell_Bee/index.html b/Games/Spell_Bee/index.html new file mode 100644 index 0000000000..1c37881608 --- /dev/null +++ b/Games/Spell_Bee/index.html @@ -0,0 +1,396 @@ + + + + + + + Spell Bee + + + + +
    + +
    +
    + + + +
    + + + + +
    +
    Level: 1
    +
    Score: 0
    +
    +
    + + + + diff --git a/Games/Spirograph/Readme.md b/Games/Spirograph/Readme.md new file mode 100644 index 0000000000..e336157d4d --- /dev/null +++ b/Games/Spirograph/Readme.md @@ -0,0 +1,23 @@ +## Spirograph Simulator + +This code simulates a Spirograph, a fun tool for drawing intricate curves. + +**How to Play:** + +1. **Open the HTML file:** Double-click the `index.html` file in your web browser. +2. **Adjust settings:** + - Change gear sizes (r1, r2, r3) and frequency values (f1, f2, f3) to modify the curve's shape (sliders or input boxes). +3. **Start drawing:** Click the "Play" button. The spirograph will come alive! +4. **Pause/Resume:** Click "Pause" to stop the animation and "Play" to resume. +5. **Reset:** Click "Reset" to clear the drawing and start fresh with the current settings. +6. **Save your artwork:** Click "Save" to download the current drawing as a PNG image. + + +**Getting Started:** + +1. Clone or download the repository. +2. Open `index.html` in your browser. + +**Enjoy the world of spirograph curves!** + +![Spirograph](https://github.com/GSSoC24/Contributor/assets/141642724/bf5e34a3-b8a8-4d7f-9732-894a20fbb7a9) \ No newline at end of file diff --git a/Games/Spirograph/index.html b/Games/Spirograph/index.html new file mode 100644 index 0000000000..83183785d4 --- /dev/null +++ b/Games/Spirograph/index.html @@ -0,0 +1,48 @@ + + + + + + Document + + + + + +
    +
    +
    + + + +
    +
    + + + +
    +
    + + + + + +
    +
    + + + + + + + + + + + + + + + + + diff --git a/Games/Spirograph/main.js b/Games/Spirograph/main.js new file mode 100644 index 0000000000..507ef01cd8 --- /dev/null +++ b/Games/Spirograph/main.js @@ -0,0 +1,111 @@ +let t=0; +let play = false; +let r1 =50; +let r2 =50; +let r3 =50; +let f1 =13; +let f2 =-7; +let f3 =-3; +let xprev =0; +let yprev =0; +let isRadial = false; +let speed = 1; +let myCanvas; + +function setup() { + myCanvas = createCanvas(600,400); + myCanvas.parent(canvasContainer); + background(255); + colorMode("HSB"); +} + +pausePlayButton.addEventListener("click",()=>{ + f1 = f1Input.value =="" ? f1:f1Input.value; + f2 = f2Input.value =="" ? f2:f2Input.value; + f3 = f3Input.value =="" ? f3:f3Input.value; + r1 = r1Input.value =="" ? r1:r1Input.value; + r2 = r2Input.value =="" ? r2:r2Input.value; + r3 = r3Input.value =="" ? r3:r3Input.value; + speed = speedInput.value =="" ? speed:parseFloat(speedInput.value); + f1Input.disabled =true; + f2Input.disabled =true; + f3Input.disabled =true; + r1Input.disabled =true; + r2Input.disabled =true; + r3Input.disabled =true; + speedInput.disabled =true; + radial.disabled =true; + isRadial = radial.checked; + play = !play; + pausePlayButton.textContent = play ? "Pause" : "Play"; +}); + +resetButton.addEventListener("click",()=>{ + play = false; + f1Input.disabled = false; + f2Input.disabled = false; + f3Input.disabled = false; + r1Input.disabled = false; + r2Input.disabled = false; + r3Input.disabled = false; + speedInput.disabled = false; + radial.disabled = false; + pausePlayButton.textContent = "play"; + myCanvas.clear(); + background(255); + xprev = 0; + yprev =0; + t=0; +}); + +saveButton.addEventListener("click",()=>{ + saveCanvas("myCanvas","png"); +}); + +function draw() { + if(!play) + return; + + translate(width/2,height/2); + let x=0; + let y=0; + let a = [r1,r2,r3]; + let c_n = [f1/100,f2/100,f3/100]; + let c_s= [0,0,0]; + + for (let i=0; i<3; i++) { + x+= a[i] * cos(c_n[i]*t+c_s[i]); + y+= a[i] * sin(c_n[i]*t+c_s[i]); + } + + if(!isRadial && (xprev !=0 || yprev !=0)) + line(xprev,yprev,x,y); + xprev = x; + yprev =y; + if(isRadial) + line(0,0,x,y); + + stroke(1*t%255,2*t%255,4*t%255); + t+= speed; +} + + + + + + + + + + + + + + + + + + + + + diff --git a/Games/Spirograph/style.css b/Games/Spirograph/style.css new file mode 100644 index 0000000000..e83b7eeb62 --- /dev/null +++ b/Games/Spirograph/style.css @@ -0,0 +1,56 @@ +body{ + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + background-color: black; + font-family: Arial, Helvetica, sans-serif; +} + +#inputContainer { + display: flex; + flex-direction: column; + background-color: whitesmoke; + border-radius: 5px; + margin: 5px; + padding: 10px; +} + +#inputContainer > div:not(:last-child) { + display: flex; + justify-content: space-around; + align-items: center; + margin: 10px; +} + +#inputContainer > div:last-child { + display: flex; + justify-content: center; + align-items: center; +} + +input[type="number"] { + width: 120px; + height: 20px; + padding: 5px; + outline: none; + border-radius: 5px; + margin: 5px; +} + +button { + border: none; + background-color: green; + color: whitesmoke; + width: 80px; + height: 40px; + border-radius: 5px; + cursor: pointer; + font-weight: bold; + margin: 10px; +} + +label { + font-weight: bold; + margin: 5px; +} \ No newline at end of file diff --git a/Games/Taash Game/asset/images/Desktop.png b/Games/Taash Game/asset/images/Desktop.png new file mode 100644 index 0000000000..4d1c6ae817 Binary files /dev/null and b/Games/Taash Game/asset/images/Desktop.png differ diff --git a/Games/Taash Game/asset/images/Tab-preview.png b/Games/Taash Game/asset/images/Tab-preview.png new file mode 100644 index 0000000000..01abe22275 Binary files /dev/null and b/Games/Taash Game/asset/images/Tab-preview.png differ diff --git a/Games/Taash Game/asset/images/mobile.png b/Games/Taash Game/asset/images/mobile.png new file mode 100644 index 0000000000..d70f64b28a Binary files /dev/null and b/Games/Taash Game/asset/images/mobile.png differ diff --git a/Games/Taash Game/index.html b/Games/Taash Game/index.html index 2d05937546..03a6f882bd 100644 --- a/Games/Taash Game/index.html +++ b/Games/Taash Game/index.html @@ -15,7 +15,7 @@

    Taash Game

    Let's Play

    -
    +

    You: 0

    diff --git a/Games/Taash Game/script.js b/Games/Taash Game/script.js index b38f56eeed..f33a803566 100644 --- a/Games/Taash Game/script.js +++ b/Games/Taash Game/script.js @@ -1,3 +1,4 @@ +let count=0 let blackjackGame = { you: { scoreSpan: "#your-blackjack-result", @@ -65,24 +66,28 @@ document .addEventListener("click", blackjackRestart); function blackjackHit() { + count+=1 if (blackjackGame["isStand"] === false) { let card = randomCard(); - showCard(card, YOU); + showCard('your-box',card, YOU,count); updateScore(card, YOU); showScore(YOU); } } - function randomCard() { let randomIndex = Math.floor(Math.random() * 13); return blackjackGame["cards"][randomIndex]; } -function showCard(card, activePlayer) { +function showCard(player,card, activePlayer,counting) { if (activePlayer["score"] <= 21) { let cardImage = document.createElement("img"); cardImage.src = `images/${card}.png`; - cardImage.style = `width:${widthSize()}; height:${heightSize()};`; + if(counting>1){ + let your_BOX=document.getElementById(player).children[counting-1] + your_BOX.id=counting===2?'right':counting===3?"center":"left" + } + cardImage.style = `height:${heightSize()};object-fit: contain;`; document.querySelector(activePlayer["div"]).appendChild(cardImage); hitSound.play(); } @@ -98,12 +103,7 @@ function widthSize() { } function heightSize() { - if (windowHeight > 700) { - let newHeightSize = window.screen.height * 0.18; - return newHeightSize; - } else { - return window.screen.height * 0.15; - } + return 150+'px' } function updateScore(card, activePlayer) { @@ -117,12 +117,13 @@ function updateScore(card, activePlayer) { activePlayer["score"] += blackjackGame["cardsMap"][card]; } - console.log(activePlayer["score"]); } function showScore(activePlayer) { //Bust logic if score is over 21 if (activePlayer["score"] > 21) { + let Bust=document.querySelector(activePlayer.div).lastElementChild + Bust.id="Bust" document.querySelector(activePlayer["scoreSpan"]).textContent = "BUST!"; document.querySelector(activePlayer["scoreSpan"]).style.color = "red"; } else { @@ -132,6 +133,7 @@ function showScore(activePlayer) { } function blackjackStand() { + count=0 if (blackjackGame.pressOnce === false) { blackjackGame["isStand"] = true; let yourImages = document @@ -140,7 +142,7 @@ function blackjackStand() { for (let i = 0; i < yourImages.length; i++) { let card = randomCard(); - showCard(card, DEALER); + showCard("dealer-box",card, DEALER,i+1); updateScore(card, DEALER); showScore(DEALER); } @@ -203,6 +205,7 @@ function showWinner(winner) { } function blackjackDeal() { + count=0 if (blackjackGame["isTurnsOver"] === true) { // Select all the images in both the user and dealer box let yourImages = document @@ -239,6 +242,7 @@ function blackjackDeal() { } function blackjackRestart() { + count=0 blackjackDeal(); document.querySelector("#wins").textContent = 0; document.querySelector("#losses").textContent = 0; diff --git a/Games/Taash Game/style.css b/Games/Taash Game/style.css index f0ce85e2cc..eaef959479 100644 --- a/Games/Taash Game/style.css +++ b/Games/Taash Game/style.css @@ -1,5 +1,5 @@ body { - background: url("https://images.pexels.com/photos/956999/milky-way-starry-sky-night-sky-star-956999.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"); + background: url("https://cdn.vectorstock.com/i/500p/34/82/green-casino-poker-table-texture-game-background-vector-47533482.jpg"); background-repeat: no-repeat; background-size: cover; @@ -12,9 +12,15 @@ body { text-align: center; color: white; width:75%; + display: flex; + flex-direction: column; + gap: 2rem; } - +#board{background-color: purple;border-radius: 247px;padding: 2rem;box-shadow: 1px 2px 2px 12px rgb(211 164 18 / 70%);} +#your-box,#dealer-box{min-height: 200px;} +#your-box{border-top-right-radius: 247px;border-top-left-radius: 247px;box-shadow: inset 0 10px 12px rgb(253 253 253 / 48%);position: relative;min-width: 600px;} +#dealer-box{border-bottom-left-radius: 247px;border-bottom-right-radius: 247px;box-shadow: inset 0 -10px 12px rgb(253 253 253 / 48%);position: relative;min-width: 600px;} .flex-blackjack-row-1, .flex-blackjack-row-2, .flex-blackjack-row-3 { @@ -37,7 +43,28 @@ body { .flex-blackjack-row-2 div img { padding: 10px; } - +img{position: relative;z-index: 2;} +#right{ + height: 150px; + object-fit: contain; + position: relative; + right: -61px; + box-sizing: border-box; + rotate: 166deg; + top: 3px; + z-index: 1; +} +#left{ + height: 150px; + object-fit: contain; + position: relative; + left: -61px; + box-sizing: border-box; + rotate: -166deg; + top: 3px; + z-index: 1; +} +#center{position: relative;z-index: 2;} table { border: 3px solid black; border-collapse: collapse; @@ -63,3 +90,22 @@ table td { background-image: url(https://i.stack.imgur.com/q02th.jpg); border: 3px solid black; } +@media (max-width:950px) { + #board{min-width: 80%;} + #your-box,#dealer-box{ + min-width: 90%; + min-height: 300px; + } +} +@media (max-width:650px) { + .container{width: 100%;} +} +@media (max-width:470px) { + #center,#left,#right{ + left: 0px; + box-sizing: border-box; + rotate:0deg; + top: 0px; + z-index: 1; + } +} \ No newline at end of file diff --git a/Games/Tic-tac-toe/README.md b/Games/Tic-tac-toe/README.md new file mode 100644 index 0000000000..ba1ceba839 --- /dev/null +++ b/Games/Tic-tac-toe/README.md @@ -0,0 +1,31 @@ +# **Tic Tac Toe** + +--- + +
    + +## **Description 📃** + +- Tic Tac Toe is a classic two-player game where players take turns marking the spaces in a 3×3 grid. The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row wins the game. + +## **Functionalities 🎮** + +- Two-player game mode. +- Visual representation of the game board. +- Real-time updates of the game state. +- Winning condition check and message display. +- Winning animation with music. + +
    + +## **How to play? 🕹️** + +1. Open the `index.html` file in your browser. +2. The first player (X) clicks on an empty cell to mark it. +3. The second player (O) takes their turn by clicking on another empty cell. +4. The game alternates turns between players X and O. +5. The game checks for a winner after each turn. If a player has three marks in a row (horizontally, vertically, or diagonally), a winning message is displayed, and a winning animation is played. +6. If all cells are filled without any player winning, the game ends in a draw. + +
    + diff --git a/Games/Tic-tac-toe/index.html b/Games/Tic-tac-toe/index.html new file mode 100644 index 0000000000..6797c039a1 --- /dev/null +++ b/Games/Tic-tac-toe/index.html @@ -0,0 +1,29 @@ + + + + + + Tic Tac Toe + + + +

    Tic Tac Toe

    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + + + diff --git a/Games/Tic-tac-toe/panda.avif b/Games/Tic-tac-toe/panda.avif new file mode 100644 index 0000000000..d42877377b Binary files /dev/null and b/Games/Tic-tac-toe/panda.avif differ diff --git a/Games/Tic-tac-toe/script.js b/Games/Tic-tac-toe/script.js new file mode 100644 index 0000000000..ed331eab4c --- /dev/null +++ b/Games/Tic-tac-toe/script.js @@ -0,0 +1,71 @@ +const cells = document.querySelectorAll('.cell'); +const message = document.getElementById('message'); +const winnerAnimation = document.getElementById('winner-animation'); +const winMusic = document.getElementById('win-music'); +let currentPlayer = 'X'; +let board = ['', '', '', '', '', '', '', '', '']; +let gameActive = true; + +const winningConditions = [ + [0, 1, 2], + [3, 4, 5], + [6, 7, 8], + [0, 3, 6], + [1, 4, 7], + [2, 5, 8], + [0, 4, 8], + [2, 4, 6] +]; + +function handleCellClick(event) { + const clickedCell = event.target; + const clickedCellIndex = parseInt(clickedCell.getAttribute('data-index')); + + if (board[clickedCellIndex] !== '' || !gameActive) { + return; + } + + board[clickedCellIndex] = currentPlayer; + clickedCell.innerText = currentPlayer; + checkResult(); +} + +function checkResult() { + let roundWon = false; + for (let i = 0; i < winningConditions.length; i++) { + const winCondition = winningConditions[i]; + let a = board[winCondition[0]]; + let b = board[winCondition[1]]; + let c = board[winCondition[2]]; + if (a === '' || b === '' || c === '') { + continue; + } + if (a === b && b === c) { + roundWon = true; + break; + } + } + + if (roundWon) { + message.innerText = `${currentPlayer} wins!`; + gameActive = false; + displayWinnerAnimation(); + return; + } + + let roundDraw = !board.includes(''); + if (roundDraw) { + message.innerText = 'Draw!'; + gameActive = false; + return; + } + + currentPlayer = currentPlayer === 'X' ? 'O' : 'X'; +} + +function displayWinnerAnimation() { + winnerAnimation.classList.remove('hidden'); + winMusic.play(); +} + +cells.forEach(cell => cell.addEventListener('click', handleCellClick)); diff --git a/Games/Tic-tac-toe/styles.css b/Games/Tic-tac-toe/styles.css new file mode 100644 index 0000000000..af084f2441 --- /dev/null +++ b/Games/Tic-tac-toe/styles.css @@ -0,0 +1,46 @@ +body { + display: flex; + flex-direction: column; + align-items: center; + font-family: Arial, sans-serif; +} + +h1 { + margin-top: 20px; +} + +.game-board { + display: grid; + grid-template-columns: repeat(3, 100px); + grid-template-rows: repeat(3, 100px); + gap: 5px; + margin-top: 20px; +} + +.cell { + display: flex; + align-items: center; + justify-content: center; + width: 100px; + height: 100px; + background-color: #f0f0f0; + border: 2px solid #333; + font-size: 2em; + cursor: pointer; +} + +.hidden { + display: none; +} + +#winner-animation { + display: flex; + flex-direction: column; + align-items: center; + margin-top: 20px; +} + +#winner-animation img { + width: 200px; + height: auto; +} diff --git a/Games/Tic-tac-toe/win-music.mp3 b/Games/Tic-tac-toe/win-music.mp3 new file mode 100644 index 0000000000..50fa4824a3 Binary files /dev/null and b/Games/Tic-tac-toe/win-music.mp3 differ diff --git a/Games/Tic_Tac_Toe_Neon/index.html b/Games/Tic_Tac_Toe_Neon/index.html new file mode 100644 index 0000000000..e2b561b115 --- /dev/null +++ b/Games/Tic_Tac_Toe_Neon/index.html @@ -0,0 +1,27 @@ + + + + + + Tic-Tac-Toe + + + +
    +

    Tic-Tac-Toe Neon

    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    + + + diff --git a/Games/Tic_Tac_Toe_Neon/readme.md b/Games/Tic_Tac_Toe_Neon/readme.md new file mode 100644 index 0000000000..17447b28c8 --- /dev/null +++ b/Games/Tic_Tac_Toe_Neon/readme.md @@ -0,0 +1 @@ +tic tac toe game with neon color which makes an ambient immence for gameplay diff --git a/Games/Tic_Tac_Toe_Neon/script.js b/Games/Tic_Tac_Toe_Neon/script.js new file mode 100644 index 0000000000..7b22499b99 --- /dev/null +++ b/Games/Tic_Tac_Toe_Neon/script.js @@ -0,0 +1,86 @@ +const cells = document.querySelectorAll('[data-cell]'); +const board = document.getElementById('game-board'); +const restartButton = document.getElementById('restartButton'); +let isCircleTurn; + +const WINNING_COMBINATIONS = [ + [0, 1, 2], + [3, 4, 5], + [6, 7, 8], + [0, 3, 6], + [1, 4, 7], + [2, 5, 8], + [0, 4, 8], + [2, 4, 6] +]; + +const startGame = () => { + isCircleTurn = false; + cells.forEach(cell => { + cell.classList.remove('x'); + cell.classList.remove('circle'); + cell.innerHTML = ''; // Clear the cell's content + cell.removeEventListener('click', handleClick); + cell.addEventListener('click', handleClick, { once: true }); + }); + setBoardHoverClass(); +}; + +const handleClick = (e) => { + const cell = e.target; + const currentClass = isCircleTurn ? 'circle' : 'x'; + placeMark(cell, currentClass); + if (checkWin(currentClass)) { + endGame(false); + } else if (isDraw()) { + endGame(true); + } else { + swapTurns(); + setBoardHoverClass(); + } +}; + +const endGame = (draw) => { + if (draw) { + alert("Draw!"); + } else { + alert(`${isCircleTurn ? "O's" : "X's"} Wins!`); + } +}; + +const isDraw = () => { + return [...cells].every(cell => { + return cell.classList.contains('x') || cell.classList.contains('circle'); + }); +}; + +const placeMark = (cell, currentClass) => { + cell.classList.add(currentClass); + cell.innerHTML = currentClass === 'x' ? 'X' : 'O'; // Display X or O +}; + +const swapTurns = () => { + isCircleTurn = !isCircleTurn; +}; + +const setBoardHoverClass = () => { + board.classList.remove('x'); + board.classList.remove('circle'); + if (isCircleTurn) { + board.classList.add('circle'); + } else { + board.classList.add('x'); + } +}; + +const checkWin = (currentClass) => { + return WINNING_COMBINATIONS.some(combination => { + return combination.every(index => { + return cells[index].classList.contains(currentClass); + }); + }); +}; + +startGame(); + +restartButton.addEventListener('click', startGame); diff --git a/Games/Tic_Tac_Toe_Neon/style.css b/Games/Tic_Tac_Toe_Neon/style.css new file mode 100644 index 0000000000..ec61de40a5 --- /dev/null +++ b/Games/Tic_Tac_Toe_Neon/style.css @@ -0,0 +1,59 @@ +body { + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + background-color: #000; + color: #fff; + font-family: Arial, sans-serif; + margin: 0; +} + +.game-container { + text-align: center; +} + +h1 { + color: #00ffcc; + text-shadow: 0 0 10px #00ffcc, 0 0 20px #00ffcc; +} + +#game-board { + display: grid; + grid-template-columns: repeat(3, 100px); + grid-template-rows: repeat(3, 100px); + gap: 10px; + margin: 20px auto; +} + +.cell { + width: 100px; + height: 100px; + background-color: #1a1a1a; + display: flex; + justify-content: center; + align-items: center; + font-size: 2rem; + cursor: pointer; + box-shadow: 0 0 20px #00ffcc; + transition: background-color 0.3s; +} + +.cell:hover { + background-color: #333; +} + +button { + padding: 10px 20px; + font-size: 1rem; + color: #00ffcc; + background-color: #000; + border: 2px solid #00ffcc; + cursor: pointer; + transition: background-color 0.3s, color 0.3s; +} + +button:hover { + background-color: #00ffcc; + color: #000; +} diff --git a/Games/Town_Rise_Game/index.html b/Games/Town_Rise_Game/index.html new file mode 100644 index 0000000000..3a90374b79 --- /dev/null +++ b/Games/Town_Rise_Game/index.html @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + TownRise + + +
    + + +

    +
    +
    + + + +
    +
    +
    + +
    + +
    + + + \ No newline at end of file diff --git a/Games/Town_Rise_Game/js/army.js b/Games/Town_Rise_Game/js/army.js new file mode 100644 index 0000000000..6b185901a7 --- /dev/null +++ b/Games/Town_Rise_Game/js/army.js @@ -0,0 +1,23 @@ +class General { + +} + +class Army { + constructor(infantry, archery, chivalry,){ + this.infantry = infantry; + this.archery = archery; + this.chivalry = chivalry; + } + + get power(){ + return this.powerCalc(); + } + + powerCalc(){ + return this.infantry + (this.archery * 2) + (this.archery * 4); + } +} + +export function combat(){ + const quadrado = new Army(10,5,3); +} \ No newline at end of file diff --git a/Games/Town_Rise_Game/js/buildings.js b/Games/Town_Rise_Game/js/buildings.js new file mode 100644 index 0000000000..9c05d906f3 --- /dev/null +++ b/Games/Town_Rise_Game/js/buildings.js @@ -0,0 +1,153 @@ +import { game } from "../data/gameData.js"; +import { updateDataInfo } from "./ui/ui.js"; +import { buildingHTML, destroyBuildingHTML,updateMapItemsScale } from "./ui/buildingsUI.js"; +import { average } from "./funcs.js"; +import { jobs } from "./jobs.js"; +import { buildingsData } from "../data/buildingsData.js"; +import { resourceChange } from "./resources.js"; + +import { cropField } from "./buildings/cropField.js"; +import { orchard } from "./buildings/orchard.js"; +import { homes } from "./buildings/homes.js"; + +export function buildingsUpdate(){ + jobs(); + + //Specific Updates + cropField(); + orchard(); + + generalUpdate(); + + homes(); + + updateMapItemsScale(); + +/* + //school(); + cropField(); + farm(); + tailorsmith(); + foundry(); + lumbermill(); + sawmill(); + //warehouse(); + //quarry(); + mine(); + tavern();*/ +} + +function generalUpdate(){ + for(const b in buildingsData){ + const building = buildingsData[b]; + + let allInputSupply = []; + let allJobSupply = []; + + //Jobs + for(const j in building.jobs){ + let jobSupply = game[j]/game[j+"_jobs"]; + + if(jobSupply > 1) jobSupply = 1; + if(!jobSupply) jobSupply = 0; + + allJobSupply.push(jobSupply); + } + + //Calculate Input/Needs Supply + for(const c in building.maintenance){ + const inputConsumption = building.maintenance[c] * game[b]; + let inputSupply = game[c]/inputConsumption; + + if(inputSupply > 1) inputSupply = 1; + if(inputSupply < 1) game[c+"_lack"] = true; + if(!inputSupply) inputSupply = 0; + + allInputSupply.push(inputSupply); + } + + if(allJobSupply.length == 0) allJobSupply.push(1); + if(allInputSupply.length == 0) allInputSupply.push(1); + + const jobSupply = average(allJobSupply); + const inputSupply = average(allInputSupply); + const productivityImpacts = game.impacts.hasOwnProperty(b+"_productivity") ? game.impacts[b+"_productivity"] : 1; + const productivity = (jobSupply * inputSupply * game.productivity) * productivityImpacts; + + //Discount Input/Needs Supply (based in productivity) + for(const c in building.maintenance){ + const inputConsumption = building.maintenance[c] * game[b] * productivity; + + resourceChange("consumption", c, building.name, inputConsumption); + } + + //Winter Needs + if(game.season == "winter" && building.hasOwnProperty("winter_needs")){ + for(const c in building.winter_needs){ + const wNeedConsumption = building.winter_needs[c] * game[b]; + + resourceChange("consumption", c, building.name, wNeedConsumption); + } + } + + //Production + for(const p in building.production){ + const prod = building.production[p] * game[b] * productivity; + + resourceChange("production", p, building.name, prod); + } + } +} + +export function buildBuilding(id){ + if(!game.gameStarted) return; + if(game.gamePaused){ + pauseError(); + return; + } + + const building = buildingsData[id]; + + for(const n in building.build){ + if(game[n] < building.build[n]) + return; + } + + game[id]++; + + for(const n in building.build){ + game[n] -= building.build[n]; + } + + buildingHTML(id); + updateMapItemsScale(); + updateDataInfo(); + jobs(); +} + +let constructInPause = false; +function pauseError(){ + if(!constructInPause){ + Swal.fire({ + text: "O jogo está pausado, você não pode construir.", + confirmButtonText: "Ok", + }) + + constructInPause = true; + setTimeout(()=>{constructInPause = false}, 60000); + } +} + +export function destroyBuilding(id, qty){ + destroyBuildingHTML(id, qty); + + game[id] -= qty; + + const building = buildingsData[id]; + for(const n in building.build){ + game[n] += building.build[n]*0.5; + } + + updateDataInfo(); + jobs(); +} diff --git a/Games/Town_Rise_Game/js/events.js b/Games/Town_Rise_Game/js/events.js new file mode 100644 index 0000000000..d5c5ed234f --- /dev/null +++ b/Games/Town_Rise_Game/js/events.js @@ -0,0 +1,70 @@ +import { rand } from "./funcs.js"; +import { game } from "../data/gameData.js" +import { pauseGame, playGame } from "./gameTime.js"; +import { modifiersUI } from "./ui/ui.js"; + +import { eventsData } from "../data/eventsData.js"; +import { modifiersData } from "../data/modifiersData.js"; + +export function events(){ + newEvents(); + runEvents(); + + updateModifiers(); +} + +function newEvents(){ + if(game.totalDays <= 90) return; + + for(const e in eventsData){ + const evt = eventsData[e]; + + if(rand(0,evt.rareness) == 0){ + if(evt.hasOwnProperty("modifier") && game.modifiers[e]) continue; + if(evt.hasOwnProperty("condition") && !evt.condition()) continue; + + evt.onTrigger(); + + pauseGame(); + + Swal.fire({ + title: evt.title, + html: evt.message, + width: "70%", + height: "100%", + imageUrl: "./img/events/"+e+".webp", + imageHeight: 250, + allowOutsideClick: false, + }).then(() => { + playGame(); + }); + + if(evt.hasOwnProperty("modifier")){ + game.modifiers[evt.modifier] = modifiersData[evt.modifier].duration; + } + + break; //Only one event per day + } + } +} + +function runEvents(){ + for(const e in game.activeEvents){ + const evt = game.activeEvents[e]; + + evt.update(); + } +} + +function updateModifiers(){ + for(const m in game.modifiers){ + game.modifiers[m]--; + modifiersData[m].effect(); + + if(game.modifiers[m] == 0){ + delete game.modifiers[m]; + } + } + + modifiersUI(); +} \ No newline at end of file diff --git a/Games/Town_Rise_Game/js/game.js b/Games/Town_Rise_Game/js/game.js new file mode 100644 index 0000000000..d799911f39 --- /dev/null +++ b/Games/Town_Rise_Game/js/game.js @@ -0,0 +1,128 @@ +import { rand, shuffleArr, preloadImage } from "./funcs.js"; +import { soundStart, soundtrack } from "./sound.js"; +import { resourcesUI,professionsUI } from "./ui/ui.js"; +import { savedGamesHTML } from "./ui/load-saveUI.js"; +import { newWeather } from "./weather.js"; +import { advanceDay } from "./time/day.js"; +import { popUpdate } from "./ui/popUI.js"; +import { game } from "../data/gameData.js"; +import { resetResource, foodCalc, gameTick, happinessCalc, productivityCalc } from "./gameTick.js"; +import { eventsData } from "../data/eventsData.js"; +import { resources } from "../data/resourcesData.js"; +import { buildingsData } from "../data/buildingsData.js"; +import { popsData } from "../data/popsData.js"; +import { armyData } from "../data/armyData.js"; +import { combat } from "./army.js"; + +function gameBootstrap(){ + if(localStorage.getItem("mv-game-version") != document.getElementById("game-version").innerText){ + localStorage.setItem("mv-highscore", "0"); + localStorage.setItem("mv-game-version", document.getElementById("game-version").innerText); + } + + for(const k in buildingsData){ + game[k] = 0; + + preloadImage("./img/buildings/"+k+".png"); + } + for(const k in resources){ + game[k] = 0; + resetResource(k); + + preloadImage("./img/icons/"+k+".png"); + } + for(const k in popsData){ + game[k] = 0; + game[k+"_jobs"] = 0; + } + for(const k in armyData){ + game[k] = 0; + } + for(const k in eventsData){ + if(eventsData[k].image) + preloadImage("./img/events/"+k+".webp"); + } + + game.fruit = 50; + game.wood = 20; + game.stone = 10; + game.clothes = 50; + game.tools = 50; + game.ale = 10; + + game.idle = 10; + + //####################################################### + + happinessCalc(); + foodCalc(); + productivityCalc(); + + //####################################################### + + window.setTimeout(soundtrack, rand(1500,5000)); + soundStart(); + resourcesUI(); + professionsUI(); + savedGamesHTML(); + shuffleArr(eventsData); + + setInterval(popUpdate, 100); + + combat(); +}gameBootstrap(); + + +export function gameStartItems(){ + if(game.gameDifficulty == "easy"){ + game.lumbermill = 1; + game.cropField = 2; + game.house = 2; + game.meat = 50; + } +} + +export function checkGameOver(){ + if(!game.population || game.gameOver){ + game.gameOver = true; + + checkHighScore(game.score); + + if(game.gameSurrender) + document.location.reload(true); + else{ + Swal.fire({ + title: "Sua vila acabou :(", + text: "Pontuação: "+game.score, + }); + } + + document.getElementById("options").classList.add("hidden"); + document.getElementById("restart").classList.remove("hidden"); + document.getElementById("pause").classList.add("hidden"); + document.getElementById("1x").classList.add("hidden"); + document.getElementById("5x").classList.add("hidden"); + document.getElementById("10x").classList.add("hidden"); + } +} + +function checkHighScore(value){ + let highscore = localStorage.getItem("mv-highscore"); + if(highscore == null) highscore = 0; + + if(value > highscore){ + localStorage.setItem("mv-highscore", value.toString()); + } +} + +export function newTurn(){ + checkGameOver(); + + advanceDay(); + newWeather(); + + gameTick(); + + if(!game.gameOver && !game.gamePaused) + game.gameTick = window.setTimeout(newTurn, game.gameSpeed); +} \ No newline at end of file diff --git a/Games/Town_Rise_Game/js/gameTime.js b/Games/Town_Rise_Game/js/gameTime.js new file mode 100644 index 0000000000..be3220a30c --- /dev/null +++ b/Games/Town_Rise_Game/js/gameTime.js @@ -0,0 +1,42 @@ +import { game } from "../data/gameData.js" +import { newTurn } from "./game.js"; + +let lastGameSpeed; + +export function setGameSpeed(speed){ + lastGameSpeed = speed; + + if(speed == "1x") game.gameSpeed = 1000; + else if(speed == "5x") game.gameSpeed = 350; + else if(speed == "10x") game.gameSpeed = 75; + else{ + lastGameSpeed = "1x"; + speed = "1x"; + game.gameSpeed = 1000; + } + + clearTimeout(game.gameTick); + game.gamePaused = false; + game.gameTick = setTimeout(newTurn, game.gameSpeed); + speedBtnsClassReset(); + document.getElementById(speed).classList.add("btn-active"); +} + +export function pauseGame(){ + clearTimeout(game.gameTick); + speedBtnsClassReset(); + game.gamePaused = true; + document.getElementById("pause").classList.add("btn-active"); +} + +export function playGame(){ + clearTimeout(game.gameTick); + setGameSpeed(lastGameSpeed); +} + +function speedBtnsClassReset(){ + document.getElementById("pause").classList.remove("btn-active"); + document.getElementById("1x").classList.remove("btn-active"); + document.getElementById("5x").classList.remove("btn-active"); + document.getElementById("10x").classList.remove("btn-active"); +} \ No newline at end of file diff --git a/Games/Town_Rise_Game/js/handleInput.js b/Games/Town_Rise_Game/js/handleInput.js new file mode 100644 index 0000000000..8136321cc6 --- /dev/null +++ b/Games/Town_Rise_Game/js/handleInput.js @@ -0,0 +1,145 @@ +import { checkGameOver, gameStartItems } from "./game.js"; +import { game } from "../data/gameData.js"; +import { deleteGame, loadGame, saveGame } from "./load-save.js"; +import { setGameSpeed, pauseGame } from "./gameTime.js"; + +import { popBootstrap } from "./ui/popUI.js"; +import { updateDataInfo } from "./ui/ui.js"; +import { selectGameDifficultyUI, gameOptionsUI } from "./ui/options.js"; +import { buildingsBootstrap, updateMapItemsScale } from "./ui/buildingsUI.js"; + +import { jobs } from "./jobs.js"; +import { buildBuilding, destroyBuilding } from "./buildings.js"; + +import { buildingsData } from "../data/buildingsData.js"; +import { populationStart } from "./population.js"; + +//Cancel reload of the page +window.addEventListener("beforeunload", function (event) { + if(!game.gameOver) + event.returnValue = "\o/"; +}); + +window.onresize = e => { + document.querySelector("body").style.height = window.innerHeight-20+"px"; +}; + +window.onclick = e => { + //Buildings + const b = e.target.id.replace(/^add-/, ""); + if(buildingsData.hasOwnProperty(b)){ + buildBuilding(b); + } + if(game.destroyBuildingCheck){ + if(e.target.parentNode.classList.contains("map-item")){ + const building = e.target.parentNode.classList[3].substring(4); + destroyBuilding(building, 1); + } + } + + if(e.target.id == "load-village"){ + document.getElementById("load-game").classList.add("hidden"); + loadGame(document.getElementById("village-to-load").value); + startSequence("load-game"); + } + if(e.target.id == "delete-village"){ + Swal.fire({ + title: "Deseja mesmo Deletar?", + icon: "warning", + allowOutsideClick: false, + allowEscapeKey: false, + showCancelButton: true, + confirmButtonColor: "#d33", + confirmButtonText: "Deletar", + cancelButtonText: "Voltar", + }).then((result) => { + if(result.isConfirmed){ + deleteGame(document.getElementById("village-to-load").value); + } + }); + } + if(e.target.id == "surrender"){ + Swal.fire({ + title: "Deseja mesmo Desistir?", + icon: "warning", + allowOutsideClick: false, + allowEscapeKey: false, + showCancelButton: true, + confirmButtonColor: "#d33", + confirmButtonText: "Desistir", + cancelButtonText: "Voltar", + }).then((result) => { + if(result.isConfirmed){ + game.gameOver = true; + game.gameSurrender = true; + checkGameOver(); + } + }); + } + if(e.target.id == "start"){ + startSequence("new-game"); + } + if(e.target.id == "load"){ + document.getElementById("start-game").classList.add("hidden"); + document.getElementById("load-game").classList.remove("hidden"); + } + if(e.target.id == "options"){ + gameOptionsUI(); + } + if(e.target.id == "back-to-start"){ + document.getElementById("start-game").classList.remove("hidden"); + document.getElementById("load-game").classList.add("hidden"); + } + if(e.target.id == "restart"){ + document.location.reload(true); + } + if(e.target.id == "pause"){ + pauseGame(); + } + if(e.target.id == "1x"){ + setGameSpeed("1x"); + } + if(e.target.id == "5x"){ + setGameSpeed("5x"); + } + if(e.target.id == "10x"){ + setGameSpeed("10x"); + } + if(e.target.id == "save-game"){ + saveGame(); + } +} + +for(let i = 0; i < document.querySelectorAll(".professions-slider").length; i++){ + document.querySelectorAll(".professions-slider")[i].addEventListener("input", () => { + updateDataInfo(); + jobs(); + }); +} + +async function startSequence(type){ + if(type == "new-game") + await selectGameDifficultyUI(); + + gameStartItems(); + buildingsBootstrap(); + updateDataInfo(); + popBootstrap(); + populationStart(); + updateMapItemsScale(); + + game.gameStarted = true; + game.gamePaused = true; + + document.getElementById("start-game").classList.add("hidden"); + document.getElementById("game-version").remove(); + document.getElementById("pause").classList.add("btn-active"); + document.getElementById("buildings-menu").classList.remove("hidden"); + document.getElementById("pause").classList.remove("hidden"); + document.getElementById("1x").classList.remove("hidden"); + document.getElementById("5x").classList.remove("hidden"); + document.getElementById("10x").classList.remove("hidden"); + document.getElementById("left-section").style.display = "flex"; + document.getElementById("info-section").style.display = "flex"; + document.getElementById("map").style.display = "flex"; +} \ No newline at end of file diff --git a/Games/Town_Rise_Game/js/jobs.js b/Games/Town_Rise_Game/js/jobs.js new file mode 100644 index 0000000000..b9d1ed22ae --- /dev/null +++ b/Games/Town_Rise_Game/js/jobs.js @@ -0,0 +1,20 @@ +import { buildingsData } from "../data/buildingsData.js"; +import { popsData } from "../data/popsData.js"; +import { game } from "../data/gameData.js"; + +export function jobs(){ + for(const p in popsData){ + if(p == "idle") continue; + + game[p+"_jobs"] = 0; + } + + for(const b in buildingsData){ + if(buildingsData[b].hasOwnProperty("jobs")){ + for(const j in buildingsData[b].jobs){ + const jobs = buildingsData[b].jobs[j] * game[b]; + game[j+"_jobs"] += jobs; + } + } + } +} \ No newline at end of file diff --git a/Games/Town_Rise_Game/js/load-save.js b/Games/Town_Rise_Game/js/load-save.js new file mode 100644 index 0000000000..e33e90a04d --- /dev/null +++ b/Games/Town_Rise_Game/js/load-save.js @@ -0,0 +1,90 @@ +import { game } from "../data/gameData.js"; +import { popsData } from "../data/popsData.js"; +import { savedGamesHTML } from "./ui/load-saveUI.js"; +import { updateDataInfo } from "./ui/ui.js"; + +export async function saveGame(){ + if(game.villageName == ""){ + const { value: name } = await Swal.fire({ + title: "Dê um nome para a vila", + allowOutsideClick: false, + allowEscapeKey: false, + showCancelButton: true, + input: "text", + inputValidator: (value) => { + if(!value) return "Digite um nome!"; + } + }); + + if(name) game.villageName = name; + } + + let villagesBackup = JSON.parse(localStorage.getItem("mv-saved-villages")); + let villages = villagesBackup; + + if(villages != null){ + for(let i = 0; i < villages.length; i++){ + if(villages[i].villageName == game.villageName) + villages.splice(i--, 1); + } + + villages.push(game); + } + else + villages = [game]; + + try{ + if(!game.villageName) throw "error"; + + localStorage.setItem("mv-saved-villages", JSON.stringify(villages)); + + Swal.fire({ + icon: "success", + title: "Salvo com sucesso!", + showConfirmButton: false, + timer: 1000 + }); + }catch(e){ + localStorage.setItem("mv-saved-villages", JSON.stringify(villagesBackup)); + + Swal.fire({ + icon: "error", + title: "Oops...", + text: "Erro ao salvar" + }); + } +} + +export function loadGame(name){ + let villages = JSON.parse(localStorage.getItem("mv-saved-villages")); + + for(let i = 0; i < villages.length; i++){ + const element = villages[i]; + + if(element.villageName == name){ + Object.keys(game).forEach((key, index) => { + game[key] = element[key]; + }); + } + } + + for(const j in popsData){ + if(j == "idle") continue; + document.getElementById(j+"-input").value = game[j]; + } +} + +export function deleteGame(name){ + let villages = JSON.parse(localStorage.getItem("mv-saved-villages")); + let newVillages = []; + + for(let i = 0; i < villages.length; i++){ + if(villages[i].villageName != name) + newVillages.push(villages[i]); + } + + villages = newVillages; + localStorage.setItem("mv-saved-villages", JSON.stringify(villages)); + + savedGamesHTML(); +} \ No newline at end of file diff --git a/Games/Town_Rise_Game/js/resources.js b/Games/Town_Rise_Game/js/resources.js new file mode 100644 index 0000000000..024f85cf9c --- /dev/null +++ b/Games/Town_Rise_Game/js/resources.js @@ -0,0 +1,16 @@ +import { game } from "../data/gameData.js" + +export function resourceChange(type, id, name, value){ + if(type == "consumption"){ + if(game[id+"_consumption"].hasOwnProperty(name)) + game[id+"_consumption"][name] += value; + else + game[id+"_consumption"][name] = value; + } + else if(type == "production"){ + if(game[id+"_production"].hasOwnProperty(name)) + game[id+"_production"][name] += value; + else + game[id+"_production"][name] = value; + } +} \ No newline at end of file diff --git a/Games/Town_Rise_Game/style.css b/Games/Town_Rise_Game/style.css new file mode 100644 index 0000000000..0821e3bced --- /dev/null +++ b/Games/Town_Rise_Game/style.css @@ -0,0 +1,443 @@ +* { + --body-bg-base: #6E9A76; + --body-bg-gradient1: #4ca2cd; + --body-bg-gradient2: #67B26F; + --container-bg: #f0f0f0; + --btn-bg: #04AA6D; + --btn-bg-hover: #005e3b; + + --dark-border: #333; +} +#combat { + background-color: #00000099; + position: fixed; + z-index: 1060; + top: 0; + right: 0; + bottom: 0; + left: 0; + box-sizing: border-box; + height: 100%; + overflow-x: hidden; + transition: all 0.5s; +} + +#combat-container { + margin: auto; + background-color: #f0f0f0; + height: 75%; + width: 75%; + min-width: 300px; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + border: 1px solid #111; + border-radius: 1em; + background-image: url("../img/grass.webp"); + background-repeat: repeat; +} + +#combat-info { + background-color: #f0f0f0; + border-bottom: 1px solid #111; + border-radius: 1em 1em 0 0; + display: flex; + justify-content: space-between; + text-align: center; +} + +#combat-info > div { + padding: 0.5em; + width: 50%; +} + +#combat-info > div > table > tbody > tr > td:nth-child(1){ + text-align: end; +} +#combat-info table { + margin: auto; +} + +#combat-info p { + padding: 2px; + font-size: 14px; +} +#combat-info h1 { + margin: 0; + margin-bottom: 0.25em; + font-size: 18px; +} + +#combat-map { + display: flex; + padding: 1em 0.5em; + border-radius: 0 0 1em 1em; + justify-content: space-between; + height: max-content; +} + +#combat-map > div { + margin: auto; + transition: all 1s; + display: flex; + flex-direction: row-reverse; + align-items: center; +} + +#combat-map > div > div { + margin: 0.5em; +} + +.combat-unity{ + margin: 0.1em; +} + +.combat-unity img{ + filter: drop-shadow(0px 0px 1px black); +} + +.attack-allies { + transform: translateX(50px); +} + +.attack-enemies { + transform: translateX(-50px); +} + +#log { + display: block; + font-size: 12px; + overflow-y: scroll; + height: 100px; + width: 100%; +} + +.pop { + opacity: 0; + filter: drop-shadow(2px 2px 2px var(--dark-border)); + left: 50%; + -webkit-transition : opacity 1s ease-out; + transition : opacity 1s ease-out; +} +.pop-live { + opacity: 1; +} +.pop-die { + opacity: 0; +} +#map-section { + width: 57%; + -webkit-user-select: none; /* Safari */ + -ms-user-select: none; /* IE 10 and IE 11 */ + user-select: none; /* Standard syntax */ +} + +#map { + --marginWidth: 0px; + --marginHeight: 0px; + --sm_img_size: 48px; + --md_img_size: 64px; + --lg_img_size: 72px; + + border: 0; + height: 100%; + min-height: 650px; + justify-items: center; + flex-direction: column; + flex-wrap: wrap; + align-content: center; + justify-content: space-evenly; + align-items: center; + background-color: transparent; + background-image: url("../img/background.webp"); + background-repeat: space; + background-size: cover; + background-position-x: center; + -webkit-transition: 2s -webkit-filter linear; + -moz-transition: 2s -moz-filter linear; + -moz-transition: 2s filter linear; + -ms-transition: 2s -ms-filter linear; + -o-transition: 2s -o-filter linear; + transition: 2s filter linear, 2s -webkit-filter linear; + image-rendering: pixelated; + image-rendering: -moz-crisp-edges; + image-rendering: crisp-edges; +} + +.map-winter { + filter: grayscale(0.8); +} + +.map-autumn { + filter: saturate(150%) hue-rotate(320deg); +} + +.map-summer { + filter: saturate(150%) contrast(120%); +} + +.map-div { + margin: 1em; + display: flex; + flex-direction: row; + flex-wrap: wrap; + position: relative; +} +.map-div:first-child { + margin-top: 45px; +} + +#map-city { + top: 42%; +} +#map-farms { + top: 33%; +} +#map-manufactories { + top: -6%; +} + + +.map-item { + filter: drop-shadow(2px 2px 2px #333); + margin: var(--marginHeight) var(--marginWidth); + line-height: 0; +} + +.map-item-sm img { + height: var(--sm_img_size); + width: var(--sm_img_size); +} + +.map-item-md img { + height: var(--md_img_size); + width: var(--md_img_size); +} + +.map-item-lg img { + height: var(--lg_img_size); + width: var(--lg_img_size); +} + +@media only screen and (max-width: 960px) { + #map { + min-height: 300px; + } +} +.menu{ + position: fixed; + top: 50%; + left: 50%; + -webkit-transform: translate(-50%, -50%); + transform: translate(-50%, -50%); + + width: 50%; + border: 3px solid green; + border-radius: 0.5em; + box-shadow: 0px 0px 5px 1px black; + padding: 10px; + align-items: center; + justify-content: center; +} +.menu img{ + width: 100px; + margin-bottom: 5px; +} +.menu p{ + font-size: 18px; + margin: 5px; + line-height: 2; +} +.menu input{ + font-size: 16px; + padding: 20px; + margin: 10px; + width: 200px; +} +.menu div{ + display: inline-flex; + flex-wrap: wrap; + justify-content: center; +} + +#village-to-load{ + width: 200px; +} + +#delete-village{ + width: 100px; + padding: 10px; + background-color: brown; + color: white; + border: 1px solid #333; +} + +#buildings-menu p{ + font-size: 16px; + padding: 5px; + font-weight: bold; + text-align: center; +} + +.building-menu{ + font-size: 12px; +} +.building-menu-tooltip{ + text-align: center; +} +.building-menu-tooltip button{ + padding: 15px 10px; +} + +@media only screen and (max-width: 960px) { + .menu { + width: 75%; + } +} +#pops { + padding: 5px; + -webkit-user-select: none; /* Safari */ + -ms-user-select: none; /* IE 10 and IE 11 */ + user-select: none; /* Standard syntax */ +} +#pops table{ + text-align: center; +} +#pops img { + width: 24px; + height: 24px; + object-fit: contain; + filter: drop-shadow(1px 1px 1px black); +} +#pops > table > tbody > tr > td:nth-child(2) { + text-align: end; +} +#pops > table > tbody > tr > td:nth-child(4) { + min-width: 45px; +} +#pops input { + width: 90%; + min-width: 50px; +} + +.professions-slider { + -webkit-appearance: none; + appearance: none; + height: 10px; + background: #d3d3d3; + outline: none; + opacity: 1; + -webkit-transition: .2s; + transition: opacity .2s; +} +.professions-slider:hover { + opacity: 1.5; +} +.professions-slider:disabled { + appearance: inherit; + opacity: 0.4; +} + +.professions-slider::-webkit-slider-thumb { + -webkit-appearance: none; + appearance: none; + width: 15px; + height: 25px; + background: #005e3b; +} + +.professions-slider::-moz-range-thumb { + width: 25px; + height: 25px; + background: #005e3b; +} +.progress-bar-background { + width: 100%; + margin-right: 10px; + height: max-content; + border: 2px solid #222; + border-radius: 4px; + background-color: lightgrey; + position: relative; +} + +.progress-bar { + width: 100%; + height: 100%; + border-radius: 2px; + background-color: #ffd900; + border: 1px solid #222; + margin: -1px; + -webkit-transition : width 2s ease; + transition : width 2s ease; +} + +.progress-bar div { + width: 100%; + font-size: small; + font-weight: bold; + text-align: center; +} +.building-tippy{ + min-width: 200px; + padding: 10px; +} +.building-tippy ul{ + padding: 0; + list-style-type: none; + margin: 0; +} +.building-tippy li{ + padding-left: 1em; + margin: 0; +} +.building-tippy li::marker{ + padding-left: 0; +} +.building-tippy p{ + text-align: start; + width: 100%; + margin: 0; + font-weight: normal; +} + +.tippy-box[data-theme~="townrise"] { + background-color: #00472D; + color: white; + border: 1px solid black; + padding: 5px 10px; + margin: 0; + box-shadow: 0px 0px 5px #111; + font-family: "Roboto", sans-serif; + letter-spacing: 0.5px; +} + +.tippy-box[data-theme~="townrise"] b { + letter-spacing: 1px; +} + +.tippy-box[data-theme~="townrise"] h1{ + margin-top: 0; + margin-bottom: 10px; + letter-spacing: 2px; + font-size: 1.1em; + text-align: center; +} + +.tippy-box[data-theme~="townrise"][data-placement^="top"] > .tippy-arrow::before { + border-top-color: #000; + margin: -1px; +} +.tippy-box[data-theme~="townrise"][data-placement^="bottom"] > .tippy-arrow::before { + border-bottom-color: #000; + margin: -1px; +} +.tippy-box[data-theme~="townrise"][data-placement^="left"] > .tippy-arrow::before { + border-left-color: #000; + margin: -1px; +} +.tippy-box[data-theme~="townrise"][data-placement^="right"] > .tippy-arrow::before { + border-right-color: #000; + margin: -1px; +} \ No newline at end of file diff --git a/Games/keySymphony/index1.html b/Games/keySymphony/index1.html new file mode 100644 index 0000000000..8805824656 --- /dev/null +++ b/Games/keySymphony/index1.html @@ -0,0 +1,46 @@ + + + + + + KeySymphony + + + + +
    +
    +

    + KeySymphony +

    +
    + Sound +
    + +
    + Show Keys +
    +
    +
      +
    • a
    • +
    • w
    • +
    • s
    • +
    • e
    • +
    • d
    • +
    • f
    • +
    • t
    • +
    • g
    • +
    • y
    • +
    • h
    • +
    • u
    • +
    • j
    • +
    • k
    • +
    • o
    • +
    • l
    • +
    • p
    • +
    • ;
    • + +
    +
    + + \ No newline at end of file diff --git a/Games/keySymphony/index1.js b/Games/keySymphony/index1.js new file mode 100644 index 0000000000..2247b0cc99 --- /dev/null +++ b/Games/keySymphony/index1.js @@ -0,0 +1,43 @@ +document.addEventListener("DOMContentLoaded", () => { + const pianoKeys = document.querySelectorAll(".Piano .key"), + volumeSlider = document.querySelector(".sound input"), + keyCheckbox = document.querySelector(".keys-checkbox input"); + + let allKeys = [], + audio = new Audio(); + + const playTune = (key) => { + audio.src = `tunes/${key}.wav`; + audio.play(); + + const clickedKey = document.querySelector(`[data-key="${key}"]`); + if (clickedKey) { + clickedKey.classList.add("active"); + setTimeout(() => { + clickedKey.classList.remove("active"); + }, 160); + } + }; + + const handleVolume = (e) => { + audio.volume = e.target.value / 100; + }; + + const showHideKeys = () => { + pianoKeys.forEach(key => key.classList.toggle("hide")); + }; + + pianoKeys.forEach(key => { + allKeys.push(key.dataset.key); + // Calling playTune function with passing data-key value as an argument + key.addEventListener("click", () => playTune(key.dataset.key)); + }); + + const pressedKey = (e) => { + if (allKeys.includes(e.key)) playTune(e.key); + }; + + keyCheckbox.addEventListener("click", showHideKeys); + volumeSlider.addEventListener("input", handleVolume); + document.addEventListener("keydown", pressedKey); +}); diff --git a/Games/keySymphony/style1.css b/Games/keySymphony/style1.css new file mode 100644 index 0000000000..158e467767 --- /dev/null +++ b/Games/keySymphony/style1.css @@ -0,0 +1,186 @@ + +@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap'); + +*{ + margin: 0; + padding: 0; + box-sizing: border-box; + font-family:'Poppins',sans-serif; +} +body{ +display: flex; + align-items: center; + justify-content: center; + min-height: 100vh; + background-color: rgb(207, 232, 255); +} +.wrapper{ + border-radius: 20px; + width:795px; + background-color: black; + padding: 32px 40px; + +} +.wrapper header{ + color: rgb(255, 255, 222); + display: flex; + align-items: center; + justify-content: center; + justify-content: space-between; +} +header h2{ + font-size:35px; +} +header .column{ + display: flex; + justify-content: center; + align-items: center; +} +header .column span{ + font-weight: 420; + font-size: 18px; + margin-right:15px; +} +.sound input{ + accent-color: #c3c018; +} +.keys-checkbox input{ + height:35px ; + width:65px; + cursor:pointer; + border-radius:30px ; + background: #118df3; + appearance: none; + outline:none; + position: relative; +} +.keys-checkbox input::before{ + content: ""; + border-radius: inherit; + position: absolute; + background-color: rgb(137, 239, 217); + width: 25px; + height: 25px; + top:50%; + left: 5px; + transform: translateY(-50%); + transition: all 0.2s ease; +} +.keys-checkbox input:checked::before{ + left:35px; + background-color: antiquewhite; +} +.Piano{ + display: flex; + margin-top: 40px; + /* padding: 20px 10px; */ + justify-content: center; + list-style: none; +} +.Piano .key{ + list-style:none; + /* color: rgb(143, 130, 112); */ + text-transform: uppercase; + cursor: pointer; + user-select: none; + position: relative; +} +.Piano .white{ + width:80px; + height:230px; + border: 1px solid black; + background: linear-gradient(#fff 96%,#eee 4%); + border-radius: 9px; + +} +.Piano .white:active{ + box-shadow:inset -5px 5px 20px rgba(0,0,0,0.2); + background-color: linear-gradient(to bottom, #fff 0%, #eee 100%); +} +.Piano .black{ + width:44px; + height:140px; + /* border: 1px solid black; */ + background: linear-gradient(#333 ,#000 ); + border-radius: 0 0 5px 5px; + z-index: 2; + margin: 0 -22px 0 -22px; +} +.Piano .black:active{ + box-shadow:inset -5px -10px 10px rgba(255,255,255,0.2); + background-color: linear-gradient(to bottom, #000 , #434343); +} +.Piano span{ + position: absolute; + bottom: 20px; + width: 100%; + font-size: 1.15rem; + text-align: center; +} +.Piano .key span { + position: absolute; + bottom: 20px; + width: 100%; + color: #A2A2A2; + font-size: 1.13rem; + text-align: center; + } + .Piano .key.hide span { + display: none; + } + .Piano .black span { + bottom: 13px; + color: #888888; + } +.Piano .key{ + list-style: none; + color: rgba(174, 174, 174, 0.856); +} +.Piano .key.hide span { + display: none; + } + .Piano .black span { + bottom: 13px; + color: #888888; + } + @media screen and (max-width: 815px) { + .wrapper { + padding: 25px; + } + header { + flex-direction: column; + } + header :where(h2, .column) { + margin-bottom: 13px; + } + .sound input { + max-width: 100px; + } + .Piano { + margin-top: 20px; + } + .Piano .key:where(:nth-child(9), :nth-child(10)) { + display: none; + } + .Piano .black { + height: 100px; + width: 40px; + margin: 0 -20px 0 -20px; + } + .Piano .white { + height: 180px; + width: 60px; + } + } + @media screen and (max-width: 615px) { + .Piano .key:nth-child(13), + .Piano .key:nth-child(14), + .Piano .key:nth-child(15), + .Piano .key:nth-child(16), + .Piano .key :nth-child(17) { + display: none; + } + .Piano .white { + width: 50px; + } + } \ No newline at end of file diff --git a/Games/keySymphony/tunes/;.wav b/Games/keySymphony/tunes/;.wav new file mode 100644 index 0000000000..a71fe4e48e Binary files /dev/null and b/Games/keySymphony/tunes/;.wav differ diff --git a/Games/keySymphony/tunes/a.wav b/Games/keySymphony/tunes/a.wav new file mode 100644 index 0000000000..fa6e07a38d Binary files /dev/null and b/Games/keySymphony/tunes/a.wav differ diff --git a/Games/keySymphony/tunes/d.wav b/Games/keySymphony/tunes/d.wav new file mode 100644 index 0000000000..7377899844 Binary files /dev/null and b/Games/keySymphony/tunes/d.wav differ diff --git a/Games/keySymphony/tunes/e.wav b/Games/keySymphony/tunes/e.wav new file mode 100644 index 0000000000..1325049800 Binary files /dev/null and b/Games/keySymphony/tunes/e.wav differ diff --git a/Games/keySymphony/tunes/f.wav b/Games/keySymphony/tunes/f.wav new file mode 100644 index 0000000000..31aa67be88 Binary files /dev/null and b/Games/keySymphony/tunes/f.wav differ diff --git a/Games/keySymphony/tunes/g.wav b/Games/keySymphony/tunes/g.wav new file mode 100644 index 0000000000..bd0e58c44b Binary files /dev/null and b/Games/keySymphony/tunes/g.wav differ diff --git a/Games/keySymphony/tunes/h.wav b/Games/keySymphony/tunes/h.wav new file mode 100644 index 0000000000..921b7d5e3f Binary files /dev/null and b/Games/keySymphony/tunes/h.wav differ diff --git a/Games/keySymphony/tunes/j.wav b/Games/keySymphony/tunes/j.wav new file mode 100644 index 0000000000..747367fe86 Binary files /dev/null and b/Games/keySymphony/tunes/j.wav differ diff --git a/Games/keySymphony/tunes/k.wav b/Games/keySymphony/tunes/k.wav new file mode 100644 index 0000000000..52598b1a6a Binary files /dev/null and b/Games/keySymphony/tunes/k.wav differ diff --git a/Games/keySymphony/tunes/l.wav b/Games/keySymphony/tunes/l.wav new file mode 100644 index 0000000000..95baa0b64e Binary files /dev/null and b/Games/keySymphony/tunes/l.wav differ diff --git a/Games/keySymphony/tunes/o.wav b/Games/keySymphony/tunes/o.wav new file mode 100644 index 0000000000..853e92da4b Binary files /dev/null and b/Games/keySymphony/tunes/o.wav differ diff --git a/Games/keySymphony/tunes/p.wav b/Games/keySymphony/tunes/p.wav new file mode 100644 index 0000000000..d97f784fb3 Binary files /dev/null and b/Games/keySymphony/tunes/p.wav differ diff --git a/Games/keySymphony/tunes/s.wav b/Games/keySymphony/tunes/s.wav new file mode 100644 index 0000000000..4d53816b8c Binary files /dev/null and b/Games/keySymphony/tunes/s.wav differ diff --git a/Games/keySymphony/tunes/t.wav b/Games/keySymphony/tunes/t.wav new file mode 100644 index 0000000000..1e50ef5c81 Binary files /dev/null and b/Games/keySymphony/tunes/t.wav differ diff --git a/Games/keySymphony/tunes/u.wav b/Games/keySymphony/tunes/u.wav new file mode 100644 index 0000000000..505f00e54a Binary files /dev/null and b/Games/keySymphony/tunes/u.wav differ diff --git a/Games/keySymphony/tunes/w.wav b/Games/keySymphony/tunes/w.wav new file mode 100644 index 0000000000..2a160b5594 Binary files /dev/null and b/Games/keySymphony/tunes/w.wav differ diff --git a/Games/keySymphony/tunes/y.wav b/Games/keySymphony/tunes/y.wav new file mode 100644 index 0000000000..e4caa7049b Binary files /dev/null and b/Games/keySymphony/tunes/y.wav differ diff --git a/Games/whack a mole/README.md b/Games/whack a mole/README.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Games/whack a mole/index.html b/Games/whack a mole/index.html new file mode 100644 index 0000000000..07da5a375d --- /dev/null +++ b/Games/whack a mole/index.html @@ -0,0 +1,27 @@ + + + + + + Whack-a-Mole + + + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    Score: 0
    +
    Time: 30
    +
    + + + diff --git a/Games/whack a mole/script.js b/Games/whack a mole/script.js new file mode 100644 index 0000000000..dff1080a87 --- /dev/null +++ b/Games/whack a mole/script.js @@ -0,0 +1,47 @@ +let score = 0; +let timeLeft = 30; +let timerId; +let moleTimerId; +const scoreDisplay = document.getElementById('score'); +const timerDisplay = document.getElementById('timer'); +const holes = document.querySelectorAll('.hole'); + +function randomHole() { + const index = Math.floor(Math.random() * holes.length); + return holes[index]; +} + +function showMole() { + const hole = randomHole(); + const mole = document.createElement('div'); + mole.classList.add('mole'); + hole.appendChild(mole); + + mole.addEventListener('click', () => { + score++; + scoreDisplay.textContent = `Score: ${score}`; + hole.removeChild(mole); + }); + + setTimeout(() => { + if (hole.contains(mole)) { + hole.removeChild(mole); + } + }, 1000); +} + +function startGame() { + timerId = setInterval(() => { + timeLeft--; + timerDisplay.textContent = `Time: ${timeLeft}`; + if (timeLeft === 0) { + clearInterval(timerId); + clearInterval(moleTimerId); + alert(`Game Over! Your score is ${score}`); + } + }, 1000); + + moleTimerId = setInterval(showMole, 800); +} + +startGame(); diff --git a/Games/whack a mole/styles.css b/Games/whack a mole/styles.css new file mode 100644 index 0000000000..c7ced20014 --- /dev/null +++ b/Games/whack a mole/styles.css @@ -0,0 +1,47 @@ +body { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + height: 100vh; + margin: 0; + background-color: #f0f0f0; + font-family: Arial, sans-serif; +} + +#game-container { + display: grid; + grid-template-columns: repeat(3, 100px); + grid-template-rows: repeat(3, 100px); + gap: 10px; + margin-bottom: 20px; +} + +.hole { + width: 100px; + height: 100px; + background-color: #8B4513; + position: relative; + cursor: pointer; +} + +.mole { + width: 60px; + height: 60px; + background-color: #000; + border-radius: 50%; + position: absolute; + top: 20px; + left: 20px; +} + +#scoreboard { + display: flex; + justify-content: space-between; + width: 300px; + font-size: 24px; +} + +#score, #timer { + margin: 0; +} diff --git a/README.md b/README.md index 603e538341..1365eaf7f3 100644 --- a/README.md +++ b/README.md @@ -107,419 +107,6 @@ This repository also provides one such platforms where contributers come over an -| Game | Game | Game | Game | Game | -| ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------- | -| [Master Typing](https://github.com/kunjgit/GameZone/tree/main/Games/Master_Typing) | [Treasure Hunt](https://github.com/Antiquely3059/GameZone/tree/main/Games/Treasure%20Hunt) | [Virtual Pet](https://github.com/Antiquely3059/GameZone/tree/main/Games/Virtual_Pet) | [MazeRunner](https://github.com/kunjgit/GameZone/tree/main/Games/MazeRunner) | [Ping_Pong_Singleplayer](https://github.com/kunjgit/GameZone/tree/main/Games/Ping_Pong_Singleplayer) | | -| [Tilting Maze](https://github.com/kunjgit/GameZone/tree/main/Games/Tilting_Maze) | [Simon Game Challenge](https://github.com/kunjgit/GameZone/tree/main/Games/Simon_Game_Challenge) | [Snake Game](https://github.com/kunjgit/GameZone/tree/main/Games/Snake_Game) | [Dino Runner Game](https://github.com/kunjgit/GameZone/tree/main/Games/Dino_Runner_Game) | -| [Whack a Mole](https://github.com/kunjgit/GameZone/tree/main/Games/Whack_a_Mole) | [Doraemon Jump](https://github.com/kunjgit/GameZone/tree/main/Games/Doraemon_Jump) | [Black Jack](https://github.com/kunjgit/GameZone/tree/main/Games/Black_Jack) | [Memory Game](https://github.com/kunjgit/GameZone/tree/main/Games/Memory_Game) | [Word Guessing Game](https://github.com/kunjgit/GameZone/tree/main/Games/Word_Guessing_Game) | -| [Ludo Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ludo_Game) | [Piano Game](https://github.com/kunjgit/GameZone/tree/main/Games/Piano) | [Atari Breakout](https://github.com/kunjgit/GameZone/tree/main/Games/Atari_Breakout) | [Dinosaur Game](https://github.com/kunjgit/GameZone/tree/main/Games/Chrome_Dinosaur_Game) | [Guess The Colour by RGB Game](https://github.com/kunjgit/GameZone/tree/main/Games/Colour_Guessing_Game) | -| [Guess The Number](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_The_Number) | [Race car game](https://github.com/kunjgit/GameZone/tree/main/Games/race_car) | [Aim Training](https://github.com/DP-NOTHING/GameZone/tree/contri/Games/Aim_Training) | [Alien Shooter](https://github.com/kunjgit/GameZone/tree/main/Games/Alien_Shooters) | [Fruit Ninja](https://github.com/kunjgit/GameZone/tree/main/Games/Fruit_Ninja) | -| [Doodle Jump](https://github.com/kunjgit/GameZone/tree/main/Games/Doodle_Jump) | [Alphabet Game](https://github.com/kunjgit/GameZone/tree/main/Games/Alphabet) | [Candy Crush](https://github.com/kunjgit/GameZone/tree/main/Games/Candy_Crush) | [Word Association Game](https://github.com/kunjgit/GameZone/tree/main/Games/Word_Association_Game) | [Tic Tac Toe](https://github.com/kunjgit/GameZone/tree/main/Games/Tic_Tac_Toe) | -| [Flappy Bird Game](https://github.com/kunjgit/GameZone/tree/main/Games/Flappy_Bird) | [Trivia It](https://hithub.com/kunjgit/GameZone/tree/main/Games/Trivia_It) | [Minesweeper](https://github.com/kunjgit/GameZone/tree/main/Games/Minesweeper) | [Dice ShowDown Game](https://github.com/Himanshu07-debug/GameZone/tree/main/Games/Dice_Showdown_Game) | [Pac Man Game](https://github.com/kunjgit/GameZone/tree/main/Games/Pac_Man_Game) | -| [Brick Breaker Game](https://github.com/kunjgit/GameZone/tree/main/Games/Brick_Breaker) | [Magic Square Game](https://github.com/kunjgit/GameZone/tree/main/Games/Magic_Square) | [Fight Game](https://github.com/kunjgit/GameZone/tree/main/Games/Fight_Game) | [Lighthouse Game](https://github.com/kunjgit/GameZone/tree/main/Games/Lighthouse) | [Lights Out Game](https://github.com/kunjgit/GameZone/tree/main/Games/Lights_Out) | -| [Word Scramble Game](https://github.com/kunjgit/GameZone/tree/main/Games/Word_Scramble_Game) | [Tetris](https://github.com/kunjgit/GameZone/tree/main/Games/Tetris) | [Interactive Quizzing Application](https://github.com/kunjgit/GameZone/tree/main/Games/Interactive_Quizzing) | [Planet Defense Game](https://github.com/kunjgit/GameZone/tree/main/Games/Planet_Defense) | [Rabbit Rush Game](https://github.com/kunjgit/GameZone/tree/main/Games/Rabbit_Rush) | -| [Wordle](https://github.com/kunjgit/GameZone/tree/main/Games/Wordle) | [Roll Race Game](https://github.com/kunjgit/GameZone/tree/main/Games/Roll_Race) | [Menja Game](https://github.com/kunjgit/GameZone/tree/main/Games/Menja) | [Typing Speed Test Game](https://github.com/kunjgit/GameZone/tree/main/Games/Typing_Speed_Test_Game) | [Tile Game](https://github.com/kunjgit/GameZone/tree/main/Games/Tile_Game) | -| [Stick Hero Game](https://github.com/kunjgit/GameZone/tree/main/Games/Stick_Hero_Game) | [Starwars Character Game](https://github.com/kunjgit/GameZone/tree/main/Games/Starwars_Character_Game) | [Traffic Run](https://github.com/kunjgit/GameZone/tree/main/Games/Traffic_Run) | [Love Result Predictor](https://github.com/kunjgit/GameZone/tree/main/Games/Love_Result_Predictor) | [Tower Defense](https://github.com/kunjgit/GameZone/tree/main/Games/Tower_Defense) | -[Menja_block_breaker](https://github.com/kunjgit/GameZone/tree/main/Games/Menja_block_breaker) | -| [Bird Game](https://github.com/kunjgit/GameZone/tree/main/Games/Bird_game) | [Bubble Blast Game](https://github.com/kunjgit/GameZone/tree/main/Games/Bubble_Blast_Game) | [Emoji Charades](https://github.com/kunjgit/GameZone/tree/main/Games/Emoji_Charades) | [Drum And Kit](https://github.com/kunjgit/GameZone/tree/main/Games/Drum_Kit_Game) | [Rock Paper Scissors](https://github.com/kunjgit/GameZone/tree/main/Games/Rock_Paper_Scissors) | -| [Frogger](https://github.com/kunjgit/GameZone/tree/main/Games/Frogger) | [!morethan5 ](https://github.com/kunjgit/GameZone/tree/main/Games/Not_morethan5) | [Unruly Tower](https://github.com/kunjgit/GameZone/tree/main/Games/Unruly_Tower) | [Maze Game](https://github.com/kunjgit/GameZone/tree/main/Games/MazeGame) | [Connect4](https://github.com/kunjgit/GameZone/tree/main/Games/Connect4) | -| [Spelling_Bee](https://github.com/kunjgit/GameZone/tree/main/Games/Spelling_Bee) | [2048](https://github.com/kunjgit/GameZone/tree/main/Games/2048) | [Spin the Wheel](https://github.com/kunjgit/GameZone/tree/main/Games/Spin_the_wheel) | [Breakout](https://github.com/kunjgit/GameZone/tree/main/Games/Breakout) | [Tower Blocks](https://github.com/kunjgit/GameZone/tree/main/Games/Tower_Blocks) | -| [Platform Game](https://github.com/kunjgit/GameZone/tree/main/Games/Platform_Game) | [Red Light Green Light](https://github.com/kunjgit/GameZone/tree/main/Games/Red_Light_Green_Light) | [Squash your Enemy](https://github.com/kunjgit/GameZone/tree/main/Games/Squashing_your_Enemy) | [Avax Gods](https://github.com/kunjgit/GameZone/tree/main/Games/Avax_gods) | [Flip Card Game](https://github.com/kunjgit/GameZone/tree/main/Games/Flip_Card_Game) | -| [Bingo Game](https://github.com/kunjgit/GameZone/tree/main/Games/Bingo_Game) | [Fifteen Puzzle Game](https://github.com/kunjgit/GameZone/tree/main/Games/Fifteen_Puzzle_Game) | [Stack_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Stack_Game) | [Block.io_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Block.io) | [Country_Guesser_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Country_Guesser_Game) | -| [Touch_The_Ball_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Touch_The_Ball) | [Sudoku](https://github.com/kunjgit/GameZone/tree/main/Games/Sudoku) | [Mini Golf](https://github.com/kunjgit/GameZone/tree/main/Games/Mini_Golf) | [Rubik's solver](https://github.com/kunjgit/GameZone/tree/main/Games/Rubik's_solver) | [Shoot_The_Balloon](https://github.com/kunjgit/GameZone/tree/main/Games/Shoot_The_Balloon) | -| [Dont_Die_To_Ghosts](https://github.com/kunjgit/GameZone/tree/main/Games/Dont_Die_To_Ghosts) | [SciFi Alchemy](https://github.com/kunjgit/GameZone/tree/main/Games/SciFi_Alchemy) | [Packabunchas](https://github.com/kunjgit/GameZone/tree/main/Games/Packabunchas) | [Cast and Catch](https://github.com/Sheetal-05/GameZone/tree/main/Games/Cast_and_Catch) | [Track Not Found](https://github.com/kunjgit/GameZone/tree/main/Games/Track_Not_Found) | -| [Love Calculator Game](https://github.com/kunjgit/GameZone/tree/main/Games/Love_Calci) | [Planet Game](https://github.com/kunjgit/GameZone/tree/main/Games/Planet_Game) | [Snake Ladder](https://github.com/kunjgit/GameZone/tree/main/Games/Snake_Ladder) | [Among Us Game](https://github.com/kunjgit/GameZone/tree/main/Games/Among_Us_Game) | [Pokedex Game](https://github.com/kunjgit/GameZone/tree/main/Games/Pokedex) | -| [Pacific Air Battle](https://github.com/kunjgit/GameZone/tree/main/Games/Pacific_Air_Battle) | [Dante](https://github.com/kunjgit/GameZone/tree/main/Games/Dante) | [Ping Pong Multiplayer](https://github.com/kunjgit/GameZone/tree/main/Games/Ping_Pong_Multiplayer) | [Sonic The Hedgehog](https://github.com/kunjgit/GameZone/tree/main/Games/Sonic_The_Hedgehog) | [World Of Emojis](https://github.com/kunjgit/GameZone/tree/main/Games/World_Of_Emojis) | -| [Ball Fall Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_Fall_Game) | [Pinball](https://github.com/kunjgit/GameZone/tree/main/Games/Pinball) | [Duck_Hunting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Duck_Hunting_Game) | [Color Turner](https://github.com/kunjgit/GameZone/tree/main/Games/Color_Turner) | [Catch the Bunny](https://github.com/kunjgit/GameZone/tree/main/Games/Catch_the_Bunny) | -| [Catch me game](https://github.com/kunjgit/GameZone/tree/main/Games/Catch_me_game) | [Blank Detective](https://github.com/kunjgit/GameZone/tree/main/Games/Blanks_Detective) | [Falling Blocks](https://github.com/kunjgit/GameZone/tree/main/Games/Falling_Blocks) | [Movie Guessing Game](https://github.com/kunjgit/GameZone/tree/main/Games/Movie_Guessing_Game) | [Wildcard Bonanza](https://github.com/kunjgit/GameZone/tree/main/Games/Wildcard_Bonanza) | -| [The Last Spartan](https://github.com/kunjgit/GameZone/tree/main/Games/The_Last_Spartan) | [Space Exploration](https://github.com/kunjgit/GameZone/tree/main/Games/Space_Exploration) | [Bow Arrow Game](https://github.com/kunjgit/GameZone/tree/main/Games/Bow_Arrow) | [I Want To Google The Game](https://github.com/kunjgit/GameZone/tree/main/Games/I_Want_To_Google_The_Game) | [Space Gun](https://github.com/kunjgit/GameZone/tree/main/Games/Space_Gun) | -| [Space Huggers](https://github.com/kunjgit/GameZone/tree/main/Games/Space_Huggers) | [Spaceship Escort](https://github.com/kunjgit/GameZone/tree/main/Games/Spaceship_Escort) | [Space Defence](https://github.com/kunjgit/GameZone/tree/main/Games/Space_Defence) | [Glitch Buster](https://github.com/kunjgit/GameZone/tree/main/Games/Glitch_Buster) | [3D Box Game](https://github.com/kunjgit/GameZone/tree/main/Games/3d_Box_Game) | -| [Escape](https://github.com/kunjgit/GameZone/tree/main/Games/Escape) | [Retro Dungeon Puzzle](https://github.com/kunjgit/GameZone/tree/main/Games/Retro_Dungeon_Puzzle) | [Immunity Collapse](https://github.com/kunjgit/GameZone/tree/main/Games/Immunity_Collapse) | [Hunt Your Card](https://github.com/kunjgit/GameZone/tree/main/Games/Hunt_Your_Card) | [Tenacity](https://github.com/kunjgit/GameZone/tree/main/Games/Tenacity) | -| [Emoji Puzzle Game](https://github.com/kunjgit/GameZone/tree/main/Games/Emoji_Puzzle_Game) | [Back To Space](https://github.com/kunjgit/GameZone/tree/main/Games/Back_To_Space) | [Snooze](https://github.com/kunjgit/GameZone/tree/main/Games/Snooze) | [Galaxy Rider](https://github.com/kunjgit/GameZone/tree/main/Games/Galaxy_Rider) | [Squared Lines](https://github.com/kunjgit/GameZone/tree/main/Games/Squared_Lines) | -| [Space War](https://github.com/kunjgit/GameZone/tree/main/Games/Space_War) | [Sciara of Colors](https://github.com/kunjgit/GameZone/tree/main/Games/Sciara_Of_Colors) | [JunoJs](https://github.com/kunjgit/GameZone/tree/main/Games/JunoJs) | [Fall Down](https://github.com/kunjgit/GameZone/tree/main/Games/Fall_Down) | [Cat Goric](https://github.com/kunjgit/GameZone/tree/main/Games/Cat_Goric) | -| [Cable Maze](https://github.com/kunjgit/GameZone/tree/main/Games/Cable_Maze) | [Spaceducts](https://github.com/kunjgit/GameZone/tree/main/Games/Spaceducts) | [Zurbo](https://github.com/kunjgit/GameZone/tree/main/Games/Zurbo) | [Blast Zone](https://github.com/kunjgit/GameZone/tree/main/Games/BlastZone) | [Free Bird](https://github.com/kunjgit/GameZone/tree/main/Games/Free_Bird) | -| [Maximise Boxes](https://github.com/kunjgit/GameZone/tree/main/Games/MaximiseBoxes) | [Slide Puzzle](https://github.com/kunjgit/GameZone/tree/main/Games/Slide_Puzzle) | [Diamond Run](https://github.com/kunjgit/GameZone/tree/main/Games/Diamond_Run) | [Everyones Sky](https://github.com/kunjgit/GameZone/tree/main/Games/Everyones_Sky) | [Line Of Fire](https://github.com/kunjgit/GameZone/tree/main/Games/Line_Of_Fire) | -| [1024 Moves](https://github.com/kunjgit/GameZone/tree/main/Games/1024_Moves) | [Save The Forest](https://github.com/kunjgit/GameZone/tree/main/Games/Save_The_Forest) | [Dragon World Game](https://github.com/kunjgit/GameZone/tree/main/Games/Dragon_World_Game) | [DuckHunt](https://github.com/kunjgit/GameZone/tree/main/Games/DuckHunt) | [Plankman](https://github.com/kunjgit/GameZone/tree/main/Games/Plankman) | -| [Hold The Cloud](https://github.com/kunjgit/GameZone/tree/main/Games/Hold_The_Cloud) | [Labyrinth](https://github.com/kunjgit/GameZone/tree/main/Games/Labyrinth) | [RIP](https://github.com/kunjgit/GameZone/tree/main/Games/RIP) | [Risky Nav](https://github.com/kunjgit/GameZone/tree/main/Games/Risky_Nav) | [Pixels From Space](https://github.com/kunjgit/GameZone/tree/main/Games/Pixels_From_Space) | -| [Poker_Dice](https://github.com/kunjgit/GameZone/tree/main/Games/Poker_Dice) | [Unlock_The_Lock](https://github.com/kunjgit/GameZone/tree/main/Games/Unlock_The_Lock) | [Gnomedom](https://github.com/kunjgit/GameZone/tree/main/Games/Gnomedom) | [Lost In The Maze 3D](https://github.com/kunjgit/GameZone/tree/main/Games/Lost_In_The_Maze_3D) | [PONG BALL](https://github.com/kunjgit/GameZone/tree/main/Games/Pong_Ball) | -| [Projectile Motion Game](https://github.com/kunjgit/GameZone/tree/main/Games/Projectile_Motion_Game) | [Swift](https://github.com/kunjgit/GameZone/tree/main/Games/Swift) | [Spacepi](https://github.com/kunjgit/GameZone/tree/main/Games/Spacepi) | [Destroyer](https://github.com/kunjgit/GameZone/tree/main/Games/Destroyer) | [Terror_Seventy](https://github.com/kunjgit/GameZone/tree/main/Games/Terror_Seventy) | -| [Humming](https://github.com/kunjgit/GameZone/tree/main/Games/Humming) | [Word Search Puzzle](https://github.com/kunjgit/GameZone/tree/main/Games/Word_search_puzzle) | [Ballarena](https://github.com/kunjgit/GameZone/tree/main/Games/Ballarena) | [Beyonder](https://github.com/kunjgit/GameZone/tree/main/Games/Beyonder) | [Shpere](https://github.com/kunjgit/GameZone/tree/main/Games/Shpere) | -| [Short Circuit](https://github.com/kunjgit/GameZone/tree/main/Games/Short_Circuit) | [Johnny Smiter](https://github.com/kunjgit/GameZone/tree/main/Games/Johnny_Smiter) | [Rectangular](https://github.com/kunjgit/GameZone/tree/main/Games/Rectangular) | [Canon Defense](https://github.com/kunjgit/GameZone/tree/main/Games/Canon_Defense) | [Trashem](https://github.com/kunjgit/GameZone/tree/main/Games/Trashem) | -| [Chess](https://github.com/SoarinSkySagar/GameZone-GSSoC23/tree/main/Games/CHESS) | [Get The Pigeon](https://github.com/kunjgit/GameZone/tree/main/Games/Get_The_Pigeon) | [Uxu](https://github.com/kunjgit/GameZone/tree/main/Games/Uxu) | [Soul Jumper](https://github.com/kunjgit/GameZone/tree/main/Games/Soul_Jumper) | [Infernal Throne](https://github.com/kunjgit/GameZone/tree/main/Games/Infernal_Throne) | -| [Dead Again](https://github.com/kunjgit/GameZone/tree/main/Games/Dead_Again) | [Norman The Necromancer](https://github.com/kunjgit/GameZone/tree/main/Games/Norman_The_Necromancer) | [Shape Blocks](https://github.com/kunjgit/GameZone/tree/main/Games/Shape_Blocks) | [Goal_Rush](https://github.com/kunjgit/GameZone/tree/main/Games/Goal_Rush) | [Charon Jr](https://github.com/kunjgit/GameZone/tree/main/Games/Charon_Jr) | -| [Color Shifter](https://github.com/kunjgit/GameZone/tree/main/Games/Color_Shifter) | [Oh, flip](https://github.com/kunjgit/GameZone/tree/main/Games/oh_flip) | [Snake Feeder Game](https://github.com/kunjgit/GameZone/tree/main/Games/Snake_Feeder_Game) | [LOSSST](https://github.com/kunjgit/GameZone/tree/main/Games/LOSSST) | [HangMan](https://github.com/kunjgit/GameZone/tree/main/Games/HangMan) | -| [Bad_Luck_Brian](https://github.com/kunjgit/GameZone/tree/main/Games/Bad_Luck_Brian) | [Bad_Depot](https://github.com/kunjgit/GameZone/tree/main/Games/Bad_Depot) | [Achluophobia](https://github.com/kunjgit/GameZone/tree/main/Games/Achluophobia) | [Timber_Terry](https://github.com/kunjgit/GameZone/tree/main/Games/Timber_Terry) | [Earth_Destroyer](https://github.com/kunjgit/GameZone/tree/main/Games/Earth_Destroyer) | -| [Lonely Phantom](https://github.com/kunjgit/GameZone/tree/main/Games/Lonely_Phantom) | [Ghost Surf](https://github.com/kunjgit/GameZone/tree/main/Games/Ghost_Surf) | [Sucker](https://github.com/kunjgit/GameZone/tree/main/Games/Sucker) | [Sorades](https://github.com/kunjgit/GameZone/tree/main/Games/Sorades) | [Thirteen](https://github.com/kunjgit/GameZone/tree/main/Games/Thirteen) | -| [The Raising Fighting Spirits](https://github.com/kunjgit/GameZone/tree/main/Games/The_Raising_Fighting_Spirits) | [Green Mahjong](https://github.com/kunjgit/GameZone/tree/main/Games/Green_Mahjong) | [Drag And Drop Puzzle Game](https://github.com/kunjgit/GameZone/tree/main/Games/Drag_And_Drop_Puzzle) | [Music Guess Game](https://github.com/kunjgit/GameZone/tree/main/Games/Music_Guess_Game) | [Tower Of Hanoi](https://github.com/kunjgit/GameZone/tree/main/Games/Tower_Of_Hanoi) | -| [Mastermind_Mania](https://github.com/kunjgit/GameZone/tree/main/Games/Mastermind_Mania) | [Ludo_4_Player](https://github.com/kunjgit/GameZone/tree/main/Games/Ludo_4_Player) | [AirBalloon](https://github.com/kunjgit/GameZone/tree/main/Games/AirBalloon) | [Space Invaders](https://github.com/kunjgit/GameZone/tree/main/Games/Space_Invaders) | [Cut the Rope](https://github.com/kunjgit/GameZone/tree/main/Games/Cut_the_rope) | -| [Caesar&Cipher](https://github.com/kunjgit/GameZone/tree/main/Games/Caesar_Cipher) | [Monster_Maker](https://github.com/kunjgit/GameZone/tree/main/Games/Monster_Maker) | [Stolen Sword](https://github.com/kunjgit/GameZone/tree/main/Games/Stolen_Sword) | [Mastermind](https://github.com/kunjgit/GameZone/tree/main/Games/Mastermind) | [Highway 404](https://github.com/kunjgit/GameZone/tree/main/Games/Highway_404) | -| [BullseyeGame](https://github.com/kunjgit/GameZone/tree/main/Games/BullseyeGame) | [Crossword Game](https://github.com/kunjgit/GameZone/tree/main/Games/Crossword_Game) | [Guess the Correct Logo](https://github.com/shruti-2412/GameZone/tree/main/Games/Guess_The_Correct_Logo) | [Painting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Painting_Game) | [Platform_game_engine](https://github.com/kunjgit/GameZone/tree/main/Games/Platform_game_engine) | -| [Doppelkopf](https://github.com/kunjgit/GameZone/tree/main/Games/Doppelkopf) | [quiz_game](https://github.com/kunjgit/GameZone/tree/main/Games/quiz_game) | [Island Survival](https://github.com/kunjgit/GameZone/tree/main/Games/Island_Survival) | [Linkup Game](https://github.com/kunjgit/GameZone/tree/main/Games/linkup) | [Trivia_Card](https://github.com/kunjgit/GameZone/tree/main/Games/Trivia_Card) | -| [Insect Catch Game](https://github.com/kunjgit/GameZone/tree/main/Games/Insect_Catch_Game) | [Carnival_game](https://github.com/kunjgit/GameZone/tree/main/Games/Carnival_game) | [Make Me Laugh](https://github.com/kunjgit/GameZone/tree/main/Games/Make_Me_Laugh) | [Avoider_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Avoider_Game) | [Dungeon_Crawler](https://github.com/kunjgit/GameZone/tree/main/Games/Dungeon_Crawler) | -| [snake_water_gun](https://github.com/kunjgit/GameZone/tree/main/Games/snake_water_gun) | [Run and Jump](https://github.com/kunjgit/GameZone/tree/main/Games/Run_and_Jump) | [AI CHESS Game](https://github.com/kunjgit/GameZone/tree/main/Games/AI_CHESS_Game) | [Fruit_Catching](https://github.com/kunjgit/GameZone/tree/main/Games/Fruit_Catching) | [Bulls eye](https://github.com/kunjgit/GameZone/tree/main/Games/Bulls_eye) | -| [Crystals_Collecter](https://github.com/kunjgit/GameZone/tree/main/Games/Crystals_Collecter) | [Dots and Boxes Game](https://github.com/kunjgit/GameZone/tree/main/Games/Dots_and_Boxes_Game) | [Infinite Runner Game](https://github.com/kunjgit/GameZone/tree/main/Games/Infinite_Runner_Game) | [Mario_Matching](https://github.com/kunjgit/GameZone/tree/main/Games/mario_matching_game) | [Hand_Cricket](https://github.com/kunjgit/GameZone/tree/main/Games/Hand_Cricket) | -| [Crossword_Puzzle](https://github.com/kunjgit/GameZone/tree/main/Games/Crossword_Puzzle) | [Pixel_Painter](https://github.com/kunjgit/GameZone/tree/main/Games/Pixel_Painter) | [Riddle_Room](https://github.com/kunjgit/GameZone/tree/main/Games/Riddle_Room) | [ArmorAlley](https://github.com/kunjgit/GameZone/tree/main/Games/ArmorAlley) | [Color_switcher](https://github.com/kunjgit/GameZone/tree/main/Games/Color_switcher) | -| [Maze of Cables](https://github.com/VSatwika/GameZonefork/tree/Maze_of_Cables/Games/Maze_of_Cables) | [Escape Room](https://github.com/kunjgit/GameZone/tree/main/Games/Escape_room) | [Super_mario_run](https://github.com/kunjgit/GameZone/tree/main/Games/Super_mario_run) | [Doodle_Draw](https://github.com/kunjgit/GameZone/tree/main/Games/Doodle_Draw) | [Arcade_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Arcade_Game) | -| [Slice Storm](https://github.com/VSatwika/GameZonefork/tree/Slice_Storm/Games/Slice_Storm) | [CodePen_SImulator](https://github.com/kunjgit/GameZone/tree/main/Games/CodePen_Simulator) | [Piano_Tiles](https://github.com/kunjgit/GameZone/tree/main/Games/PianoTiles_Game) | [CareTaker](https://github.com/kunjgit/GameZone/tree/main/Games/CareTaker) | [UNO](https://github.com/kunjgit/GameZone/tree/main/Games/UNO) | -| [Remeber the color](https://github.com/kunjgit/GameZone/tree/main/Games/Remember_the_color) | [Guess The Random Shape](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_The_Random_Shape) | [Save Doraemon](https://github.com/kunjgit/GameZone/tree/main/Games/Save_Doraemon) | [Animal_Match_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Animal_Match_Game) | [Hextris](https://github.com/kunjgit/GameZone/tree/main/Games/Hextris) | -| [MrFakeGame](https://github.com/kunjgit/GameZone/tree/main/Games/MrFakeGame) | [Checkers](https://github.com/kunjgit/GameZone/tree/main/Games/Checkers) | [Roulette](https://github.com/kunjgit/GameZone/tree/main/Games/Roulette) | [Aero Acrobat](https://github.com/kunjgit/GameZone/tree/main/Games/Aero_Acrobat) | [Adventure_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Adventure_Game) | -| [Pumpkin_Pursuit](https://github.com/kunjgit/GameZone/tree/main/Games/Pumpkin_Pursuit) | [Corona Shooter](https://github.com/kunjgit/GameZone/tree/main/Games/Corona_Shooter) | [Pokemon Ball Finder](https://github.com/kunjgit/GameZone/tree/main/Games/Pokemon_Ball_Finder) | [Basketball](https://github.com/kunjgit/GameZone/tree/main/Games/Basketball) | [Wault_master](https://github.com/kunjgit/GameZone/tree/main/Games/Wault_master) | -| [Reaction TIme](https://github.com/kunjgit/GameZone/tree/main/Games/Reaction_Time) | [Flag Guess Game](https://github.com/kunjgit/GameZone/tree/main/Games/Flag_Guess_Game) | [Cross_The_Road](https://github.com/kunjgit/GameZone/tree/main/Games/Cross_The_Road) | [Highway Race - Barrel Dodge](https://github.com/kunjgit/GameZone/tree/main/Games/Highway_Race) | [Bit_Maze_Platformer_Maze](https://github.com/kunjgit/GameZone/tree/main/Games/Bit_Maze_Platformer_Maze) | -| [Math Game](https://github.com/kunjgit/GameZone/tree/main/Games/Math_Game) | [Space Drifter](https://github.com/kunjgit/GameZone/tree/main/Games/space_drifter) | [Observe the Cloud](https://github.com/kunjgit/GameZone/tree/main/Games/Observe%20the%20Cloud) | [Cosmic_Coin_Blaster](https://github.com/kunjgit/GameZone/tree/main/Games/Cosmic_Coin_Blaster) | [Circus Charly](https://github.com/kunjgit/GameZone/tree/main/Games/Circus_Charly) | -| [Pikachu_Volleyball](https://github.com/kunjgit/GameZone/tree/main/Games/Pikachu_Volleyball) | [Trex_Run](https://github.com/akankshachanana1/GameZone/tree/Added/Games/Trex_Run) | [Crack_The_Code](https://github.com/kunjgit/GameZone/tree/main/Games/Crack_The_Code) | [Skeleathon](https://github.com/kunjgit/GameZone/tree/main/Games/Skeleathon) | [Shadow_PokeGuess](https://github.com/kunjgit/GameZone/tree/main/Games/Shadow_PokeGuess) | -| [Brain Color Mastermind](https://github.com/kunjgit/GameZone/tree/main/Games/Brain_Color_Mastermind) | [Lizard Spock Game](https://github.com/kunjgit/GameZone/tree/main/Games/Lizard_Spock_Game) | [Angry Boars](https://github.com/kunjgit/GameZone/tree/main/Games/Angry_Boars) | [Alphabet Learning Game](https://github.com/kunjgit/GameZone/tree/main/Games/Alphabet_Learning_Game) | [Country_Guesser_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Country_Guesser_Game) | -| [Poke_Guess_Blitz](https://github.com/kunjgit/GameZone/tree/main/Games/Poke_Guess_Blitz) | [Spider Man Go](https://github.com/kunjgit/GameZone/tree/main/Games/Spider_Man_Go) | [Foosball](https://github.com/kunjgit/GameZone/tree/main/Games/Foosball) | [Triangle_Back_to_Home](https://github.com/kunjgit/GameZone/tree/main/Games/Triangle_Back_To_Home) | [Alphabet Learning Game](https://github.com/kunjgit/GameZone/tree/lizard-game/Games/Alphabet_Learning_Game) | -| [Poke_Guess_Blitz](https://github.com/kunjgit/GameZone/tree/main/Games/Poke_Guess_Blitz) | [Spider Man Go](https://github.com/kunjgit/GameZone/tree/lizard-game/Games/Spider_Man_Go) | [Foosball](https://github.com/kunjgit/GameZone/tree/main/Games/Foosball) | [Triangle_Back_to_Home](https://github.com/kunjgit/GameZone/tree/main/Games/Triangle_Back_To_Home) | [Death by Hamster](https://github.com/kunjgit/GameZone/tree/main/Games/Death_by_Hamster) | -| [Tenzies](https://github.com/kunjgit/GameZone/tree/main/Games/Tenzies) | [Target_Torrent](https://github.com/kunjgit/GameZone/tree/main/Games/Target_Torrent) | [Reversi](https://github.com/kunjgit/GameZone/tree/main/Games/Reversi) | [reaction_teaser](https://github.com/kunjgit/GameZone/pull/2134/files) | [Scribble](https://github.com/kunjgit/GameZone/tree/main/Games/Scribble) | -| [Brain Burst Game](https://github.com/kunjgit/GameZone/tree/main/Games/Brain_Burst_Game) | [StickTheSticker](https://github.com/kunjgit/GameZone/tree/main/Games/StickTheSticker) | [Meme_Battle_Game](https://github.com/sahaycodes/GameZone/tree/meme/Games/Meme_Battle_Game) | [Match_Color_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Match_Color_Game) | [Bow_And_Arrow](https://github.com/kunjgit/GameZone/tree/main/Games/Bow_And_Arrow) | -| [Beyblade](https://github.com/kunjgit/GameZone/tree/main/Games/Beyblade) | [The labyrinth of death](https://github.com/sahaycodes/GameZone/tree/meme/Games/The_labyrinth_of_death) | [2D BreakOut](https://github.com/kunjgit/GameZone/tree/main/Games/2D_Breakout) | [Battleship](https://github.com/kunjgit/GameZone/tree/main/Games/Battleship) | [Baseball](https://github.com/kunjgit/GameZone/tree/main/Games/Baseball) | -| [Save Princess](https://github.com/kunjgit/GameZone/tree/main/Games/Save_Princess) | [RoadFighter](https://github.com/kunjgit/GameZone/tree/main/Games/RoadFighter) | [Guitar Game](https://github.com/kunjgit/GameZone/tree/main/Games/Guitar_Game) | [Solitaire](https://github.com/kunjgit/GameZone/tree/main/Games/Solitaire) | [Lady Tiger Hunter](https://github.com/kunjgit/GameZone/tree/main/Games/Lady_Tiger_Hunter) | -| [Stone Paper Scissor](https://github.com/kunjgit/GameZone/tree/main/Games/Stone_paper_scissor) | [Flashlight_Pointer_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Flashlight_Pointer_Game) | [Pig game](https://github.com/KanchanBora/GameZone/tree/main/Games/Pig_game) | [Asteroids 3D](https://github.com/kunjgit/GameZone/tree/main/Games/Asteroids_3D) | [Lamb Lane](https://github.com/sahaycodes/GameZone/tree/meme/Games/Lamb_Lane) | -| [Dinoffline](https://github.com/kunjgit/GameZone/tree/main/Games/Dinoffline) | [Maths Sprint Game](https://github.com/kunjgit/GameZone/tree/main/Games/Maths_Sprint_Game) | [Etch a Sketch](https://github.com/kunjgit/GameZone/tree/main/Games/Etch_a_Sketch) | [QuizzApp](https://github.com/kunjgit/GameZone/tree/main/Games/QuizzApp) | [Chess Game](https://github.com/kunjgit/GameZone/tree/main/Games/Chess_Game) | -| [Which Color](https://github.com/sahaycodes/GameZone/tree/main/Games/Which_Color) | [Snail_Game](https://github.com/sahaycodes/GameZone/tree/meme/Games/Snail_Game) | [Solitaire](https://github.com/kunjgit/GameZone/tree/main/Games/Solitaire_up) | [Slime Attack](https://github.com/apu52/GameZone/tree/Slime-Attack-game/Games/Slime_attack_game) | [Star_Trek_Trivia](https://github.com/kunjgit/GameZone/tree/starTrek-trivia/Games/Star_Trek_Trivia) | -| [Pokemon_Card_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Pokemon_Card_Game) | [Digit Dilemma](https://github.com/kunjgit/GameZone/tree/main/Games/Digit_Dilemma) | [Tennis](https://github.com/kunjgit/GameZone/tree/main/Games/Tennis) | [Illusion](https://github.com/kunjgit/GameZone/tree/main/Games/Illusion) | [Block Buster](https://github.com/sahaycodes/GameZone/tree/meme/Games/Block_Buster) | -| [Guess_The_Ball](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_The_Ball) | [Doremon Puzzle](https://github.com/kunjgit/GameZone/tree/main/Games/Doremon_Puzzle) | [Guess The Celebrity](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_The_Celeb) | [Rock_Paper_Scissors_Lizard_Spock](https://github.com/kunjgit/GameZone/tree/main/Rock_Paper_Scissors_Lizard_Spock) | [Elemental Riddles](https://github.com/kunjgit/GameZone/tree/main/Elemental_Riddles) | -| [Falling_Ball](https://github.com/kunjgit/GameZone/tree/main/Games/Falling_Ball) | [Hit Target](https://github.com/kunjgit/GameZone/tree/main/Games/Hit_Target) | [Archery](https://github.com/kunjgit/GameZone/tree/main/Games/Archery) | [color_switch_challenger](https://github.com/kunjgit/GameZone/tree/main/color_switch_challenger) | [Puzzle_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Puzzle_Game) | -| [Quizify](https://github.com/kunjgit/GameZone/tree/main/Quizify) | [word blitz](https://github.com/kunjgit/GameZone/tree/main/word_blitz) | [color_switch_challenger](https://github.com/kunjgit/GameZone/tree/main/color_switch_challenger) | [Puzzle_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Puzzle_Game) | [Quizify](https://github.com/kunjgit/GameZone/tree/main/Quizify) | -| [word blitz](https://github.com/kunjgit/GameZone/tree/main/word_blitz) | [Code Cracker](https://github.com/kunjgit/GameZone/tree/main/Code_Cracker) | [Know Your Country](https://github.com/kunjgit/GameZone/tree/main/Games/Know_Your_Country) | [Musical_Floor](https://github.com/kunjgit/GameZone/tree/main/Games/Musical_Floor) | [Sky_Dodge](https://github.com/kunjgit/GameZone/tree/main/Sky_Dodge) | -| [Swap Card Game](https://github.com/kunjgit/GameZone/tree/main/Games/Swap-Card-Game) | [Memorization_card](https://github.com/kunjgit/GameZone/tree/main/Games/Memorization_card) | [Smashing_Blocks](https://github.com/kunjgit/GameZone/tree/main/Games/Smashing_Blocks) | [Response_Reaction](https://github.com/kunjgit/GameZone/tree/main/Games/Response_Reaction) | [Truth and Dare](https://github.com/kunjgit/GameZone/tree/main/Games/Truth_And_Dare) | -| [Rotating_Elements](https://github.com/tanujbordikar/GameZone/tree/Rotating_Elements) | [Chopsticks](https://github.com/kunjgit/GameZone/tree/main/Games/Chopsticks) | [Anime Clicker](https://github.com/kunjgit/GameZone/tree/main/Games/Anime_Clicker) | [3D Snake](https://github.com/kunjgit/GameZone/tree/main/Games/3d_Snake) | [Rocket_Showdown](https://github.com/tanujbordikar/GameZone/tree/Rocket_Showdown) | -| [Find Extra Cube](https://github.com/kunjgit/GameZone/tree/main/Games/Find_Extra_Cube) | [PathPlex](https://github.com/kunjgit/GameZone/tree/main/Games/Pathplex) | [CSS Select](https://github.com/kunjgit/GameZone/tree/main/Games/CSS_Select) | [Squid](https://github.com/kunjgit/GameZone/tree/main/Games/Squid_Game) | [CSS Crossword](https://github.com/kunjgit/GameZone/tree/main/Games/CSS_Crossword) | -| [CSS Select](https://github.com/kunjgit/GameZone/tree/main/Games/CSS_Select) | [Squid](https://github.com/kunjgit/GameZone/tree/main/Games/Squid_Game) | [Flip Coin](https://github.com/kunjgit/GameZone/tree/main/Games/Flip_Coin) | [Witty Word Quest](https://github.com/kunjgit/GameZone/tree/main/Games/witty_word_quest) | [Typing Game](https://github.com/Ishan-77/GameZone/tree/main/Games/Typing_Game) | -| [numeral-whiz](https://github.com/Ishan-77/GameZone/tree/main/Games/numeral-whiz) | [candy_match](https://github.com/kunjgit/GameZone/tree/main/Games/Candy_Match_Saga) | [Crossy_Road](https://github.com/tanujbordikar/GameZone/tree/Crossy_Road) | [HueHero](https://github.com/kunjgit/GameZone/tree/main/Games/HueHero) | [Puzzel_Winner](https://github.com/kunjgit/GameZone/tree/main/Games/Puzzel_Winner) | -| [Emoji_Intruder](https://github.com/kunjgit/GameZone/tree/main/Games/Emoji_Intruder) | [Guess The Weapon](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_The_Weapon) | [Guess Who](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_Who) | [Pop My Balloon](https://github.com/kunjgit/GameZone/tree/main/Games/Pop_My_Balloon) | [Color_Blast](https://github.com/kunjgit/GameZone/tree/main/Games/Color_Blast) | -| [Maze_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Maze_Game) | [Coloron](https://github.com/kunjgit/GameZone/tree/main/Games/Coloron). | -| [Black_jackk](https://github.com/kunjgit/GameZone/tree/main/Games/Black_jackk) -| [Emoji_Intruder](https://github.com/kunjgit/GameZone/tree/main/Games/Emoji_Intruder) | [Guess The Weapon](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_The_Weapon) | [Guess Who](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_Who) | | | -| [Emoji_Intruder](https://github.com/kunjgit/GameZone/tree/main/Games/Emoji_Intruder) | [Guess The Weapon](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_The_Weapon) | [Guess Who](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_Who) | [Pop My Balloon](https://github.com/kunjgit/GameZone/tree/main/Games/Pop_My_Balloon) | | -| [Maze_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Maze_Game) | [Earth_Guardian](https://github.com/kunjgit/GameZone/tree/main/Games/Earth_Guardian) | [Earth_Guardian](https://github.com/kunjgit/GameZone/tree/main/Games/Earth_Guardian) | [HTML5_Controller_Tester](https://github.com/kunjgit/GameZone/tree/main/Games/HTML5_Controller_Tester) -| [escaperoom](https://github.com/kunjgit/GameZone/tree/main/Games/escaperoom) -| [Ball_Shooting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_Shooting_Game) | [HTML5_Controller_Tester](https://github.com/kunjgit/GameZone/tree/main/Games/HTML5_Controller_Tester) -| [numeral-whiz](https://github.com/Ishan-77/GameZone/tree/main/Games/numeral-whiz) | [candy_match](https://github.com/kunjgit/GameZone/tree/main/Games/Candy_Match_Saga) | [Crossy_Road](https://github.com/tanujbordikar/GameZone/tree/Crossy_Road) | [HueHero](https://github.com/kunjgit/GameZone/tree/main/Games/HueHero) | [Puzzel_Winner](https://github.com/kunjgit/GameZone/tree/main/Games/Puzzel_Winner) | -| [Emoji_Intruder](https://github.com/kunjgit/GameZone/tree/main/Games/Emoji_Intruder) | [Guess The Weapon](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_The_Weapon) | [Guess Who](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_Who) | [Pop My Balloon](https://github.com/kunjgit/GameZone/tree/main/Games/Pop_My_Balloon) | [Tower Stack](https://github.com/kunjgit/GameZone/tree/main/Games/Tower_Stack) | -| [Maze_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Maze_Game) | [TriHand_Tactics](https://github.com/kunjgit/GameZone/tree/main/Games/TriHand_Tactics) | [Earth_Guardian](https://github.com/kunjgit/GameZone/tree/main/Games/Earth_Guardian) | [Ball_Shooting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_Shooting_Game) | -| [Ball_Shooting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_Shooting_Game) | [CatchTheBall](https://github.com/kunjgit/GameZone/tree/main/Games/CatchTheBall) | -| [Ball_Shooting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_Shooting_Game) | [DoraemonRun ](https://github.com/kunjgit/GameZone/tree/main/Games/DoraemonRun) | -| [Memory_Cards_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Memory_Cards_Game) | -| [Typing_Speed_Test2](https://github.com/kunjgit/GameZone/tree/main/Games/Typing_Speed_Test2) | [Tic Tac Toe Responsive ](https://github.com/kunjgit/GameZone/tree/main/Games/Tic_tac_toe_responsive) | [Minesweeper Easy ](https://github.com/kunjgit/GameZone/tree/main/Games/MineSweeper_Easy) | [Pong](https://github.com/kunjgit/GameZone/tree/main/Games/Pong) | -| [Technical_Mind_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Technical_Mind_Game) | -[Slide_Master_Puzzle](https://github.com/kunjgit/GameZone/tree/Main/Games/Slide_Master_Puzz)| | -| [Ball_Shooting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_Shooting_Game) | [Letter_Sleuth](https://github.com/swetha5157/GameZone/tree/main/Games/Letter_Sleuth) -| [Rock_paper_scissor](https://github.com/kunjgit/GameZone/tree/main/Games/Rock_paper_scissor) | -| [City_Builder_Game](https://github.com/kunjgit/GameZone/tree/main/Games/City_Builder_Game) | -[Mancala_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Mancala_Game) | -[Knife_hit](https://github.com/kunjgit/GameZone/tree/main/Games/Knife_hit) | -| [Dice_Roller](https://github.com/kunjgit/GameZone/tree/main/Games/Dice_Roller) | [Chrome_Dino_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Chrome_Dino_Game) | -| [Rock_paper_scissor](https://github.com/kunjgit/GameZone/tree/main/Games/Rock_paper_scissor) | -| [City_Builder_Game](https://github.com/kunjgit/GameZone/tree/main/Games/City_Builder_Game) | -| [Pokemon_Stats_Card](https://github.com/kunjgit/GameZone/tree/main/Games/Pokemon_Stats_Card) | -| [Steampunk_FlappyBird](https://github.com/kunjgit/GameZone/tree/main/Games/Steampunk_FlappyBird) | -| [Catch_The_Circle](https://github.com/kunjgit/GameZone/tree/main/Games/Catch_The_Circle) | -| [Automated_rock_paper_scissor](https://github.com/kunjgit/GameZone/tree/main/Games/automated_rock_paper_scissor) | -| [Maze_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Maze_Game) | [Astronaut_runner](https://github.com/tanishkaa08/GameZone/tree/main/Games/Astronaunt_runner) | -[16_Puzzle](https://github.com/kunjgit/GameZone/tree/main/Games/16_Puzzle) | -| [Rock_paper_scissor](https://github.com/kunjgit/GameZone/tree/main/Games/Rock_paper_scissor) | -| [City_Builder_Game](https://github.com/kunjgit/GameZone/tree/main/Games/City_Builder_Game) | -| [Dice_Roller](https://github.com/kunjgit/GameZone/tree/main/Games/Dice_Roller) | [Bear Hunter Ninja](https://github.com/Niyatizzz/GameZone/tree/main/Games/Bear_Hunter_Ninja) | -| [Rock_paper_scissor](https://github.com/kunjgit/GameZone/tree/main/Games/Rock_paper_scissor) | -| [City_Builder_Game](https://github.com/kunjgit/GameZone/tree/main/Games/City_Builder_Game) | -| [Pokemon_Stats_Card](https://github.com/kunjgit/GameZone/tree/main/Games/Pokemon_Stats_Card) | -| [Steampunk_FlappyBird](https://github.com/kunjgit/GameZone/tree/main/Games/Steampunk_FlappyBird) | -| [Catch_The_Circle](https://github.com/kunjgit/GameZone/tree/main/Games/Catch_The_Circle) | -| [Automated_rock_paper_scissor](https://github.com/kunjgit/GameZone/tree/main/Games/automated_rock_paper_scissor) | -| [Maze_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Maze_Game) | [Astronaut_runner](https://github.com/tanishkaa08/GameZone/tree/main/Games/Astronaunt_runner) | -| [16_Puzzle](https://github.com/kunjgit/GameZone/tree/main/Games/16_Puzzle) | -| [Musical_Memory](https://github.com/kunjgit/GameZone/tree/main/Games/Musical_Memory) | -|[Quick_Click](https://github.com/kunjgit/GameZone/tree/main/Games/Quick_Click) | -| [Dragon_Tower](https://github.com/kunjgit/GameZone/tree/main/Games/Dragon_Tower) | -| [Hover_Board_Effect](https://github.com/kunjgit/GameZone/tree/main/Games/Hover_Board_Effect) | -[Mancala_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Mancala_Game) | -| [Dice_Roller](https://github.com/kunjgit/GameZone/tree/main/Games/Dice_Roller) | [Bear Hunter Ninja](https://github.com/Niyatizzz/GameZone/tree/main/Games/Bear_Hunter_Ninja) | -| [Rock_paper_scissor](https://github.com/kunjgit/GameZone/tree/main/Games/Rock_paper_scissor) | -| [City_Builder_Game](https://github.com/kunjgit/GameZone/tree/main/Games/City_Builder_Game) | -| [Chrome_Dino_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Chrome_Dino_Game) | -| [Pokemon_Stats_Card](https://github.com/kunjgit/GameZone/tree/main/Games/Pokemon_Stats_Card) | -| [Steampunk_FlappyBird](https://github.com/kunjgit/GameZone/tree/main/Games/Steampunk_FlappyBird) | -| [Catch_The_Circle](https://github.com/kunjgit/GameZone/tree/main/Games/Catch_The_Circle) | -| [Automated_rock_paper_scissor](https://github.com/kunjgit/GameZone/tree/main/Games/automated_rock_paper_scissor) | -| [Maze_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Maze_Game) | [Astronaut_runner](https://github.com/tanishkaa08/GameZone/tree/main/Games/Astronaunt_runner) | -| [16_Puzzle](https://github.com/kunjgit/GameZone/tree/main/Games/16_Puzzle) | -| [Dragon_Tower](https://github.com/kunjgit/GameZone/tree/main/Games/Dragon_Tower) | -| [Hover_Board_Effect](https://github.com/kunjgit/GameZone/tree/main/Games/Hover_Board_Effect) | -| [escaperoom](https://github.com/kunjgit/GameZone/tree/main/Games/escaperoom) | -| [Ball_Shooting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_Shooting_Game) | [HTML5_Controller_Tester](https://github.com/kunjgit/GameZone/tree/main/Games/HTML5_Controller_Tester) | -| [numeral-whiz](https://github.com/Ishan-77/GameZone/tree/main/Games/numeral-whiz) | [candy_match](https://github.com/kunjgit/GameZone/tree/main/Games/Candy_Match_Saga) | -| [Crossy_Road](https://github.com/tanujbordikar/GameZone/tree/Crossy_Road) | [HueHero](https://github.com/kunjgit/GameZone/tree/main/Games/HueHero) | -| [Puzzel_Winner](https://github.com/kunjgit/GameZone/tree/main/Games/Puzzel_Winner) | -| [Emoji_Intruder](https://github.com/kunjgit/GameZone/tree/main/Games/Emoji_Intruder) | [Guess The Weapon](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_The_Weapon) | -| [Guess Who](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_Who) | [Pop My Balloon](https://github.com/kunjgit/GameZone/tree/main/Games/Pop_My_Balloon) | -| [Tower Stack](https://github.com/kunjgit/GameZone/tree/main/Games/Tower_Stack) | -| [TriHand_Tactics](https://github.com/kunjgit/GameZone/tree/main/Games/TriHand_Tactics) | -| [Earth_Guardian](https://github.com/kunjgit/GameZone/tree/main/Games/Earth_Guardian) | -| [CatchTheBall](https://github.com/kunjgit/GameZone/tree/main/Games/CatchTheBall) | -| [Candy_Crush_Saga](https://github.com/kunjgit/GameZone/tree/main/Games/Candy_Crush_Saga) | -| [numeral-whiz](https://github.com/Ishan-77/GameZone/tree/main/Games/numeral-whiz) | [candy_match](https://github.com/kunjgit/GameZone/tree/main/Games/Candy_Match_Saga) | [Crossy_Road](https://github.com/tanujbordikar/GameZone/tree/Crossy_Road) | [HueHero](https://github.com/kunjgit/GameZone/tree/main/Games/HueHero) | [Puzzel_Winner](https://github.com/kunjgit/GameZone/tree/main/Games/Puzzel_Winner) | -| [Emoji_Intruder](https://github.com/kunjgit/GameZone/tree/main/Games/Emoji_Intruder) | [Guess The Weapon](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_The_Weapon) | [Guess Who](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_Who) | [Pop My Balloon](https://github.com/kunjgit/GameZone/tree/main/Games/Pop_My_Balloon) | [Tower Stack](https://github.com/kunjgit/GameZone/tree/main/Games/Tower_Stack) | -| [Maze_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Maze_Game) | [TriHand_Tactics](https://github.com/kunjgit/GameZone/tree/main/Games/TriHand_Tactics) | [Earth_Guardian](https://github.com/kunjgit/GameZone/tree/main/Games/Earth_Guardian) | [Ball_Shooting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_Shooting_Game) | -| [Ball_Shooting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_Shooting_Game) | [CatchTheBall](https://github.com/kunjgit/GameZone/tree/main/Games/CatchTheBall) | - [Candy_Crush_Saga](https://github.com/kunjgit/GameZone/tree/main/Games/Candy_Crush_Saga) | - [Colour_Generator_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Colour_Generator_Game) | -| [Rock_paper_scissor](https://github.com/kunjgit/GameZone/tree/main/Games/Rock_paper_scissor) | -| [City_Builder_Game](https://github.com/kunjgit/GameZone/tree/main/Games/City_Builder_Game) | -[Mancala_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Mancala_Game) | -|[2048_win](https://github.com/kunjgit/GameZone/tree/main/Games/2048_win) | -| [Dice_Roller](https://github.com/kunjgit/GameZone/tree/main/Games/Dice_Roller) | [Chrome_Dino_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Chrome_Dino_Game) | -| [Rock_paper_scissor](https://github.com/kunjgit/GameZone/tree/main/Games/Rock_paper_scissor) | -| [City_Builder_Game](https://github.com/kunjgit/GameZone/tree/main/Games/City_Builder_Game) | -| [Catch_The_Circle](https://github.com/kunjgit/GameZone/tree/main/Games/Catch_The_Circle) | -| [Shrek_Vs_Wild](https://github.com/kunjgit/GameZone/tree/main/Games/Shrek_Vs_Wild) | -| [ShroomKnight](https://github.com/kunjgit/GameZone/tree/main/Games/ShroomKnight) | - -| [Balloon_Buster](https://github.com/kunjgit/GameZone/tree/main/Games/Balloon_Buster) | -| [Pokemon_Stats_Card](https://github.com/kunjgit/GameZone/tree/main/Games/Pokemon_Stats_Card) | -| [Steampunk_FlappyBird](https://github.com/kunjgit/GameZone/tree/main/Games/Steampunk_FlappyBird) | -| [Catch_The_Circle](https://github.com/kunjgit/GameZone/tree/main/Games/Catch_The_Circle) | | -| [path_finder](https://github.com/kunjgit/GameZone/tree/main/Games/path_finder) | -| [Shrek_Vs_Wild](https://github.com/kunjgit/GameZone/tree/main/Games/Shrek_Vs_Wild) | -| [Dragon_Tower](https://github.com/kunjgit/GameZone/tree/main/Games/Dragon_Tower) | -| [Guess_num](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_num) | -| [QuickFingers](https://github.com/kunjgit/GameZone/tree/main/Games/QuickFingers) | -| [Physics_Quizz](https://github.com/kunjgit/GameZone/tree/main/Games/Physics_Quizz) | -| [Tiny_Fishing](https://github.com/kunjgit/GameZone/tree/main/Games/Tiny_Fishing) | - -| [Hover_Board_Effect](https://github.com/kunjgit/GameZone/tree/main/Games/Hover_Board_Effect) | - -| [namefate](https://github.com/kunjgit/GameZone/tree/main/Games/namefate) | -| [Fruit_Catching_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Fruit_Catching_Game) | -| [color_matching_application](https://github.com/kunjgit/GameZone/tree/main/Games/color_matching_application) | -| [Pictionary_Game](https://github.com/Jagpreet153/GameZone/tree/main/Games/Pictionary_Game) | -| [Anagram_Checker_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Anagram_Checker_Game) | -| [HitYourFriend](https://github.com/kunjgit/GameZone/tree/main/Games/HitYourFriend) | -| [Random_joke_Generator](https://github.com/Jagpreet153/GameZone/tree/main/Games/Random_joke_Generator) | -| [Arkanoid_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Arkanoid_Game) | -| [Catch_Stars](https://github.com/Kunjgit/GameZone/tree/main/Games/Catch_Stars) | -| [Color Matcher](https://github.com/1911aditi/GameZone/tree/1a4f3847e11bb13b1aca4652a87868c9bc467a93/Games/color%20matcher)                | -| [LaserDarts] (https://github.com/Jagpreet153/GameZone/tree/main/Games/LaserDarts) -| [Block Building](https://github.com/kunjgit/GameZone/tree/main/Games/Block_Building) | -| [Flames Game](https://github.com/kunjgit/GameZone/tree/main/Games/Flames_Game)| -| [NewsJunction](https://github.com/kunjgit/GameZone/tree/main/Games/NewsJunction) | -|[Ping_Pong_Singleplayer](https://github.com/kunjgit/GameZone/tree/main/Games/Ping_Pong_Singleplayer) | -| [MazeRunner](https://github.com/kunjgit/GameZone/tree/main/Games/MazeRunner) | -| [Emoji_slot_machine] (https://github.com/kunjgit/GameZone/tree/main/Games/Emoji_slot_machine) -| [NewsJunction](https://github.com/kunjgit/GameZone/tree/main/Games/NewsJunction) -| [Pixel Painter](https://github.com/kunjgit/GameZone/tree/main/Games/pixel_painter) | -| [Guess_The_Song](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_The_Song) | [Reverse Memory](https://github.com/MuraliDharan7/GameZone/tree/reverse-memory-game/Games/Reverse%20Memory) -| [NewsJunction](https://github.com/kunjgit/GameZone/tree/main/Games/NewsJunction) | -| [Recognizing_Figures](https://github.com/kunjgit/GameZone/tree/main/Games/Recognizing_Figures) | - -| [WordScramble](https://github.com/kunjgit/GameZone/tree/main/Games/wordScramble) - -[Roll_The_Dice](https://github.com/kunjgit/GameZone/tree/main/Games/Roll_The_Dice) | -| [Black_jackk](https://github.com/kunjgit/GameZone/tree/main/Games/Black_jackk) | -| [Recognizing_Figures](https://github.com/kunjgit/GameZone/tree/main/Games/Recognizing_Figures) | [Screen Pet Game](https://github.com/kunjgit/GameZone/tree/main/Games/Screen-Pet-Game) | -| [Sudoku_light_theme](https://github.com/kunjgit/GameZone/tree/main/Games/Sudoku_light_theme) | -| [Find_the_ball](https://github.com/kunjgit/GameZone/tree/main/Games/Find_the_ball) | -| [Color The Page](https://github.com/kunjgit/GameZone/tree/main/Games/Color_The_Page)| -|[Building Blocks Game](https://github.com/kunjgit/GameZone/tree/main/Games/Building_Block_Game)| -|[Cartoon character guessing game](https://github.com/kunjgit/GameZone/tree/main/Games/Cartoon_Character_Guessing_Game)| -|[Carrom Board Game](https://github.com/kunjgit/GameZone/tree/main/Games/carrom)| -| [Number_Recall_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Number_Recall_Game) | -| [Hit_the_hamster] (https://github.com/kunjgit/GameZone/tree/main/Games/Hit_the_hamster) | -| [Forest_Guardian](https://github.com/kunjgit/GameZone/tree/main/Games/Forst_Guardian) | -| [Sudoku_light_theme](https://github.com/kunjgit/GameZone/tree/main/Games/Sudoku_light_theme) | -| [Find_the_ball](https://github.com/kunjgit/GameZone/tree/main/Games/Find_the_ball) | -|[Color The Page](https://github.com/kunjgit/GameZone/tree/main/Games/Color_The_Page)| -|[AquaSort_Game](https://github.com/kunjgit/GameZone/tree/main/Games/AquaSort_Game) | -|[Chess_Game_computer](https://github.com/kunjgit/GameZone/tree/main/Games/Chess_Game_computer) | -|[Turn_on_the_light](https://github.com/kunjgit/GameZone/tree/main/Games/Turn_on_the_light) | -| [Tic-Tac-Toe Game](https://github.com/kunjgit/GameZone/tree/main/Games/Tic-Tac-Toe) | -| [Rapid_click_frenzy](https://github.com/kunjgit/GameZone/tree/main/Games/Rapid_click_frenzy) | -|[Dsa_quiz_game](https://github.com/kunjgit/GameZone/tree/main/Games/Dsa_quiz_game) | -| [Rapid_click_frenzy](https://github.com/kunjgit/GameZone/tree/main/Games/Rapid_click_frenzy) | -| [Gravity_Simulation_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Gravity_Simulation_Game) | -| [Anagarm-Word-Game](https://github.com/kunjgit/GameZone/tree/main/Games/Anagarm-Word-Game) | -| [Brick Buster Game](https://github.com/kunjgit/GameZone/tree/main/Games/Brick Buster) | -| [Rapid_click_frenzy](https://github.com/kunjgit/GameZone/tree/main/Games/Rapid_click_frenzy) -|[Penguins Cant Fly](https://github.com/Will2Jacks/GameZoneForked/tree/Task/Games/Penguins_Cant_Fly)| -|[GoFish](https://github.com/kunjgit/GameZone/tree/main/Games/GoFish)| -| [Taash_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Taash_Game)| - -| [Intellect Quest](https://github.com/Will2Jacks/GameZoneForked/tree/Task/Games/Intellect_Quest) | -| [Number_Guessing_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Number_Guessing_Game) | -| [Modulo_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Modulo_Game) | - - - -
    -
    - -
    -

    Page with Curl Contributing Guideline

    -
    -
    - - - -- Read our [CONTRIBUTING GUIDELINE](./.github/CONTRIBUTING_GUIDELINE.md) to get all details about contributing to **GameZone** -- Learn all about development process and all information you need to contribute to our project -- If you are having the basic queries make sure you checkout resources there - -
    - - - -
    -

    Handshake Code of Conduct

    -
    -
    - -- Please note that this project is released with [CODE OF CONDUCT](./.github/CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms. - -
    - -## License - -[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) - -Terms and conditions for use, reproduction and distribution are under the [Apache-2.0 License](https://opensource.org/license/apache-2-0/). - - - -
    -
    - -
    - -
    -
    -
    - -
    -

    Red Heart Contributors

    -
    -
    - -- This project thanking all the contributors for having your valuable contribution to our project -- Make sure you show some love by giving ⭐ to our repository - -
    - -
    - - - -
    -
    -

    Back to top

    -

    -Video GameGameZone

    - - - -
    -
    - -

    This open source repository contains a collection of games built on basic tech stacks in web development. Use your creativity, build your own game and contribute to the repository by making a PR 🎮 -
    -Make sure you star the repository and show your love to us💗 -
    -Also join the discord server for GameZone and start collaborating with others 🚀 -
    -
    -
    -

    - -## Why to Open Source - -Contributing in open source increases your opportunities to work with different projects and mentors, getting to know various insights and ideas. It is a platform where contributors grow together with a construvtive and a positive attitude. -This repository also provides one such platforms where contributers come over and put their ideas of new games and make our website as interactive as much they can! - -[![Discord](https://img.shields.io/badge/Discord-%235865F2.svg?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/fgwk4XZfxG) - -![GitHub issues](https://img.shields.io/github/issues/kunjgit/GameZone) -![GitHub forks](https://img.shields.io/github/forks/kunjgit/GameZone) -![GitHub pull requests](https://img.shields.io/github/issues-pr/kunjgit/GameZone) -![GitHub Repo stars](https://img.shields.io/github/stars/kunjgit/GameZone?style=social) -![GitHub contributors](https://img.shields.io/github/contributors/kunjgit/GameZone) -![Website](https://img.shields.io/website?down_color=red&down_message=offline&up_color=blue&up_message=online&url=https%3A%2F%2Fkunjgit.github.io%2FGameZone%2F) - -

    - -

    -
    - - - -
    -
    -

    High VoltageTech Stack

    - -
    -
    -
    -

    -

    - - - - - -
    -

    -
    -
    - -
    - - - -
    -

    Rocket Let's get started

    - -
    - - - -- Fork the repository -- Clone this repository `git clone "url of the repo"` - -* Raise and issue to add new game or to enhancement for a game (Have a look at few things you have to take care during raising issue ) - - - Select appropriate issue template - - Make sure your idea is unique and interesting 🚀 - - * Don't alter the issue title. You are supposed to write your issue name after that only. - - `[Issue Title]: Your Issue` make sure you just add your issue name - - ex .`[New game]: Super Mario` - - - Make sure you select the program in which you are participating 🔥 - -- Wait till you have been assigned the issue -- After you have been assigned the issue start working on the code -- Create your new branch using `git checkout -b ` - -* Having your code into the repository - - Make your game folder into `Games` folder by the naming convention mentioned in [CONTRIBUTING GUIDELINE](./.github/CONTRIBUTING_GUIDELINE.md) - - Add your code files (index.html,style.css,script.js) in your game folder - - Create `README.md` file in your folder and add all the functionalities and how you can play that game in that README file , also include screenshots of working game , video of a game explaining (if required). - - To create `Your_Folder/README.md ` checkout the template [GAME README TEMPLATE](./Games/FOLDER_README_TEMPLATE.md) - - Now take one good screenshot of your game that you want to display it on our website and add into `assets/images` (follow the naming convention .png or .jpeg or .jpg) - - add your folders link and name in main README.md (the one you are reading currently) - -- Push your changes to Github using `git push origin ` -- Submit your changes for review by creating PR -- And you are done ! -- I will review your code and I will merge your code to the main branch of this repository and you will notified for the same -- If you having queries in basic flow of github learn it from [CONTRIBUTING GUIDELINE](./.github/CONTRIBUTING_GUIDELINE.md) - -
    -

    Robot Games

    -
    - -
    - -
    - | Game | Game | Game | Game | Game | | ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------- | --- | | [Master Typing](https://github.com/kunjgit/GameZone/tree/main/Games/Master_Typing) | [Treasure Hunt](https://github.com/Antiquely3059/GameZone/tree/main/Games/Treasure%20Hunt) | [Virtual Pet](https://github.com/Antiquely3059/GameZone/tree/main/Games/Virtual_Pet) | [MazeRunner](https://github.com/kunjgit/GameZone/tree/main/Games/MazeRunner) | [Ping_Pong_Singleplayer](https://github.com/kunjgit/GameZone/tree/main/Games/Ping_Pong_Singleplayer) | | @@ -604,7 +191,7 @@ This repository also provides one such platforms where contributers come over an | [Emoji_Intruder](https://github.com/kunjgit/GameZone/tree/main/Games/Emoji_Intruder) | [Guess The Weapon](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_The_Weapon) | [Guess Who](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_Who) | [Pop My Balloon](https://github.com/kunjgit/GameZone/tree/main/Games/Pop_My_Balloon) | [Color_Blast](https://github.com/kunjgit/GameZone/tree/main/Games/Color_Blast) | | [Wordling](https://github.com/kunjgit/GameZone/tree/main/Games/Wordling) | [HTML5_Controller_Tester](https://github.com/kunjgit/GameZone/tree/main/Games/HTML5_Controller_Tester) -| [Maze_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Maze_Game) | [Coloron](https://github.com/kunjgit/GameZone/tree/main/Games/Coloron). | +| [Maze_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Maze_Game) | [Coloron](https://github.com/kunjgit/GameZone/tree/main/Games/Coloron). | [Spirograph](https://github.com/kunjgit/GameZone/tree/main/Games/Spirograph) | | [Black_jackk](https://github.com/kunjgit/GameZone/tree/main/Games/Black_jackk) | [Audio_Wordle](https://github.com/kunjgit/GameZone/tree/main/Games/Audio_Wordle) | [Earth_Guardian](https://github.com/kunjgit/GameZone/tree/main/Games/Earth_Guardian) | | [escaperoom](https://github.com/kunjgit/GameZone/tree/main/Games/escaperoom) @@ -614,6 +201,7 @@ This repository also provides one such platforms where contributers come over an | [Maze_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Maze_Game) | [TriHand_Tactics](https://github.com/kunjgit/GameZone/tree/main/Games/TriHand_Tactics) | [Earth_Guardian](https://github.com/kunjgit/GameZone/tree/main/Games/Earth_Guardian) | [Ball_Shooting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_Shooting_Game) | | [Ball_Shooting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_Shooting_Game) | [CatchTheBall](https://github.com/kunjgit/GameZone/tree/main/Games/CatchTheBall) | | [CopyCat](https://github.com/kunjgit/GameZone/tree/main/Games/CopyCat) | +| [Cross_The_River_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Cross_The_River_Game) | [DoraemonRun ](https://github.com/kunjgit/GameZone/tree/main/Games/DoraemonRun) | | [Memory_Cards_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Memory_Cards_Game) | | [Typing_Speed_Test2](https://github.com/kunjgit/GameZone/tree/main/Games/Typing_Speed_Test2) | [Tic Tac Toe Responsive ](https://github.com/kunjgit/GameZone/tree/main/Games/Tic_tac_toe_responsive) | [Minesweeper Easy ](https://github.com/kunjgit/GameZone/tree/main/Games/MineSweeper_Easy) | @@ -660,6 +248,7 @@ This repository also provides one such platforms where contributers come over an | [Automated_rock_paper_scissor](https://github.com/kunjgit/GameZone/tree/main/Games/automated_rock_paper_scissor) | | [Maze_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Maze_Game) | [Astronaut_runner](https://github.com/tanishkaa08/GameZone/tree/main/Games/Astronaunt_runner) | | [16_Puzzle](https://github.com/kunjgit/GameZone/tree/main/Games/16_Puzzle) | +| [Catch_The_Falling_Object](https://github.com/kunjgit/GameZone/tree/main/Games/Catch_The_Falling_Object) | | [Dragon_Tower](https://github.com/kunjgit/GameZone/tree/main/Games/Dragon_Tower) | | [Hover_Board_Effect](https://github.com/kunjgit/GameZone/tree/main/Games/Hover_Board_Effect) | | [escaperoom](https://github.com/kunjgit/GameZone/tree/main/Games/escaperoom) | @@ -701,9 +290,7 @@ This repository also provides one such platforms where contributers come over an | [Physics_Quizz](https://github.com/kunjgit/GameZone/tree/main/Games/Physics_Quizz) | | [Tiny_Fishing](https://github.com/kunjgit/GameZone/tree/main/Games/Tiny_Fishing) | | [Etch_a_Sketch_2](https://github.com/kunjgit/GameZone/tree/main/Games/Etch_a_Sketch_2) | - | [Hover_Board_Effect](https://github.com/kunjgit/GameZone/tree/main/Games/Hover_Board_Effect) | - | [namefate](https://github.com/kunjgit/GameZone/tree/main/Games/namefate) | | [Fruit_Catching_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Fruit_Catching_Game) | | [color_matching_application](https://github.com/kunjgit/GameZone/tree/main/Games/color_matching_application) | @@ -733,6 +320,7 @@ This repository also provides one such platforms where contributers come over an | [Recognizing_Figures](https://github.com/kunjgit/GameZone/tree/main/Games/Recognizing_Figures) | [Screen Pet Game](https://github.com/kunjgit/GameZone/tree/main/Games/Screen-Pet-Game) | | [Sudoku_light_theme](https://github.com/kunjgit/GameZone/tree/main/Games/Sudoku_light_theme) | | [Find_the_ball](https://github.com/kunjgit/GameZone/tree/main/Games/Find_the_ball) | + | [Color The Page](https://github.com/kunjgit/GameZone/tree/main/Games/Color_The_Page)| |[Building Blocks Game](https://github.com/kunjgit/GameZone/tree/main/Games/Building_Block_Game)| |[Cartoon character guessing game](https://github.com/kunjgit/GameZone/tree/main/Games/Cartoon_Character_Guessing_Game)| @@ -744,6 +332,11 @@ This repository also provides one such platforms where contributers come over an | [Sudoku_light_theme](https://github.com/kunjgit/GameZone/tree/main/Games/Sudoku_light_theme) | | [Find_the_ball](https://github.com/kunjgit/GameZone/tree/main/Games/Find_the_ball) | |[Color The Page](https://github.com/kunjgit/GameZone/tree/main/Games/Color_The_Page)| +|[AquaSort_Game](https://github.com/kunjgit/GameZone/tree/main/Games/AquaSort_Game) | +| [Snake](https://github.com/kunjgit/GameZone/tree/main/Games/snake)                | +| [whack a mole](https://github.com/kunjgit/GameZone/tree/main/Games/whack%20a%20mole) | +|[AquaSort_Game](https://github.com/kunjgit/GameZone/tree/main/Games/AquaSort_Game) | +| [Snake](https://github.com/kunjgit/GameZone/tree/main/Games/snake)                | | [Dice_Game] (https://github.com/shivan2004/GameZone/tree/main/Games/Dice_Game)| |[HitOrMiss](https://github.com/kunjgit/GameZone/tree/main/Games/HitOrMiss)| |[Lunar Lander](https://github.com/kunjgit/GameZone/tree/main/Games/Lunar_Lander)| @@ -763,6 +356,7 @@ This repository also provides one such platforms where contributers come over an | [Gravity_Simulation_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Gravity_Simulation_Game) | [Anagarm-Word-Game](https://github.com/kunjgit/GameZone/tree/main/Games/Anagarm-Word-Game) | | [Brick Buster Game](https://github.com/kunjgit/GameZone/tree/main/Games/Brick Buster) | +| [SnakeBites](https://github.com/kunjgit/GameZone/tree/main/Games/SnakeBites) | | [Rapid_click_frenzy](https://github.com/kunjgit/GameZone/tree/main/Games/Rapid_click_frenzy) | [Alphabet-and-Vowels](https://github.com/kunjgit/GameZone/tree/main/Games/Alphabet-and-Vowels) | | [Brick Buster Game](https://github.com/kunjgit/GameZone/tree/main/Games/Brick%20Buster) | @@ -783,23 +377,29 @@ This repository also provides one such platforms where contributers come over an | [Helicopter_Game](https://github.com/kinjgit/GameZone/tree/main/Games/Helicopter_Game) | | [Bouncing Ball Game](https://github.com/kunjgit/GameZone/tree/main/Games/Bouncing_Ball_Game) | |[Harmony_Mixer](https://github.com/kunjgit/GameZone/tree/main/Games/Harmony_Mixer)| +|[Car_Racing_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Car_Racing_Game)| +|[KeySymphony](https://github.com/kunjgit/GameZone/tree/main/Games/KeySymphony)| |[Math_Race_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Math_Race_Game)| | [Bunny is Lost](https://github.com/kunjgit/GameZone/tree/main/Games/Bunny_is_Lost)| |[Steam_Punk](https://github.com/kunjgit/GameZone/tree/main/Games/Steam_Punk)| |[Tower Defence Game](https://github.com/Will2Jacks/GameZoneForked/tree/Task/Games/Tower_Defence_Game)| -<<<<<<< HEAD - -======= +|[Mario Matching Game](https://github.com/ananyag309/GameZone_ggsoc/tree/main/Games/MarioMatchingGame)| +|[Dot_Dash](https://github.com/kunjgit/GameZone/tree/main/Games/Dot_Dash)| |[Ghost Busting Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ghost_busting_game)| |[Wheel_of_fortune](https://github.com/Will2Jacks/GameZoneForked/tree/Task/Games/Wheel_of_fortune)| |[Dot_Box_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Dot_Box_Game)| | [Cosmic_Blast](https://github.com/kunjgit/GameZone/tree/main/Games/Cosmic_Blast) | |[Mole](https://github.com/taneeshaa15/GameZone/tree/main/Games/Mole)| +|[Spell Bee](https://github.com/kunjgit/GameZone/tree/main/Games/Spell_Bee)| +| [Go-fish-master](https://github.com/kunjgit/GameZone/tree/main/Games/Go-fish-master) | |[Pottery-Game](https://github.com/kunjgit/GameZone/tree/main/Games/Pottery-Game)| ->>>>>>> c24ab932e1702441882a65b80d713ea232e18c46 - - + | [Ganesh_QR_Maker](https://github.com/kunjgit/GameZone/tree/main/Games/Ganesh_QR_Maker) | |[Wheel_of_Fortunes](https://github.com/Saipradyumnagoud/GameZone/tree/main/Games/Wheel_of_Fortunes)| +|[Tic-tac-toe](https://github.com/Saipradyumnagoud/GameZone/tree/main/Games/Tic-tac-toe)| +|[Quest_For_Riches](https://github.com/kunjgit/GameZone/tree/main/Games/Quest_For_Riches)| +| [IKnowYou-Mind-Reading-Game](https://github.com/kunjgit/GameZone/tree/main/Games/IKnowYou-Mind-Reading-Game) | +| [Tic_Tac_Toe_Neon](https://github.com/kunjgit/GameZone/tree/main/Games/Tic_Tac_Toe_Neon) | +
    diff --git a/assets/css/navbar.css b/assets/css/navbar.css index 6ceb109a76..d473859e64 100644 --- a/assets/css/navbar.css +++ b/assets/css/navbar.css @@ -93,4 +93,63 @@ text-decoration: none; display: flex; } -} \ No newline at end of file +} + + +.navbarr { + display: flex; + justify-content: space-between; + align-items: center; + padding: 1rem 2rem; + background: linear-gradient(rgb(236, 145, 145),rgb(189, 239, 189),rgb(161, 161, 209),rgb(220, 220, 159)); +} + +.logox { + font-size: 1.5rem; + font-weight: bolder; + color: rgb(17, 4, 4); +} + +.nav-linkss { + display: flex; + list-style: none; + margin: 0; + padding: 0; + font-weight: bold; +} + +.nav-linkss li { + margin-right: 4rem; +} + + +.nav-linkss a { + text-decoration: none; + color: #333; +} + +.nav-linkss a:hover{ + color: aqua; + text-decoration: underline; +} + + + +/* Media Queries for responsiveness */ + +@media screen and (max-width: 768px) { + .navbar { + flex-direction: column; + align-items: center; + } + + .nav-links { + flex-direction: column; + margin-top: 1rem; + } + + .nav-links li { + margin-right: 0; + margin-bottom: 1rem; + } +} diff --git a/assets/css/style.css b/assets/css/style.css index 1cd45e7057..5a052c19d0 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -2815,7 +2815,7 @@ textarea.form-input::-webkit-resizer { .heading { margin-top: -2%; font: 5.5vw/1 "Agency FB", Times, serif; - font-size: 5.5vw; + font-size: 9.5vw; display: flex; align-items: center; justify-content: center; diff --git a/assets/images/Alien_Invasion.png b/assets/images/Alien_Invasion.png new file mode 100644 index 0000000000..8629cd684e Binary files /dev/null and b/assets/images/Alien_Invasion.png differ diff --git a/assets/images/Bubbles.jpg b/assets/images/Bubbles.jpg new file mode 100644 index 0000000000..3f07d23270 Binary files /dev/null and b/assets/images/Bubbles.jpg differ diff --git a/assets/images/Car_Racing_Game.png b/assets/images/Car_Racing_Game.png new file mode 100644 index 0000000000..fba0a97e03 Binary files /dev/null and b/assets/images/Car_Racing_Game.png differ diff --git a/assets/images/Catch_the_falling_object-1.png b/assets/images/Catch_the_falling_object-1.png new file mode 100644 index 0000000000..7e77b978cb Binary files /dev/null and b/assets/images/Catch_the_falling_object-1.png differ diff --git a/assets/images/Catch_the_falling_object_2.png b/assets/images/Catch_the_falling_object_2.png new file mode 100644 index 0000000000..98d3854531 Binary files /dev/null and b/assets/images/Catch_the_falling_object_2.png differ diff --git a/assets/images/Color_Swap.png b/assets/images/Color_Swap.png new file mode 100644 index 0000000000..73ad166589 Binary files /dev/null and b/assets/images/Color_Swap.png differ diff --git a/assets/images/Cross_The_River.png b/assets/images/Cross_The_River.png new file mode 100644 index 0000000000..dacabcd527 Binary files /dev/null and b/assets/images/Cross_The_River.png differ diff --git a/assets/images/Cross_The_River.webp b/assets/images/Cross_The_River.webp new file mode 100644 index 0000000000..efd3966230 Binary files /dev/null and b/assets/images/Cross_The_River.webp differ diff --git a/assets/images/Dot_Dash.png b/assets/images/Dot_Dash.png new file mode 100644 index 0000000000..1d09883db4 Binary files /dev/null and b/assets/images/Dot_Dash.png differ diff --git a/assets/images/Fidget.png b/assets/images/Fidget.png new file mode 100644 index 0000000000..1f825166d8 Binary files /dev/null and b/assets/images/Fidget.png differ diff --git a/assets/images/Ganesh QR Maker'.png b/assets/images/Ganesh QR Maker'.png new file mode 100644 index 0000000000..f48474a799 Binary files /dev/null and b/assets/images/Ganesh QR Maker'.png differ diff --git a/assets/images/Go-fish-master.png b/assets/images/Go-fish-master.png new file mode 100644 index 0000000000..c8aa8e9b2d Binary files /dev/null and b/assets/images/Go-fish-master.png differ diff --git a/assets/images/Gobblet.png b/assets/images/Gobblet.png new file mode 100644 index 0000000000..b48cf2f787 Binary files /dev/null and b/assets/images/Gobblet.png differ diff --git a/assets/images/Gobblet.webp b/assets/images/Gobblet.webp new file mode 100644 index 0000000000..f8e2b03dbf Binary files /dev/null and b/assets/images/Gobblet.webp differ diff --git a/assets/images/IKnowYou-Mind-Reading-Game.png b/assets/images/IKnowYou-Mind-Reading-Game.png new file mode 100644 index 0000000000..2a127b4335 Binary files /dev/null and b/assets/images/IKnowYou-Mind-Reading-Game.png differ diff --git a/assets/images/KeySymphony.png b/assets/images/KeySymphony.png new file mode 100644 index 0000000000..31bf050d89 Binary files /dev/null and b/assets/images/KeySymphony.png differ diff --git a/assets/images/KeySymphony2.png b/assets/images/KeySymphony2.png new file mode 100644 index 0000000000..0a1cad69cb Binary files /dev/null and b/assets/images/KeySymphony2.png differ diff --git a/assets/images/Mamba_Mayhem.png b/assets/images/Mamba_Mayhem.png new file mode 100644 index 0000000000..30340ca1ee Binary files /dev/null and b/assets/images/Mamba_Mayhem.png differ diff --git a/assets/images/Mario Matching Game (1).jpg b/assets/images/Mario Matching Game (1).jpg new file mode 100644 index 0000000000..51c56edd3d Binary files /dev/null and b/assets/images/Mario Matching Game (1).jpg differ diff --git a/assets/images/Mario Matching Game (2).jpg b/assets/images/Mario Matching Game (2).jpg new file mode 100644 index 0000000000..db8ce9cc8e Binary files /dev/null and b/assets/images/Mario Matching Game (2).jpg differ diff --git a/assets/images/Mario Matching Game (3).jpg b/assets/images/Mario Matching Game (3).jpg new file mode 100644 index 0000000000..97cd791cf2 Binary files /dev/null and b/assets/images/Mario Matching Game (3).jpg differ diff --git a/assets/images/Quest_For_Riches.png b/assets/images/Quest_For_Riches.png new file mode 100644 index 0000000000..4fd8bbf2dd Binary files /dev/null and b/assets/images/Quest_For_Riches.png differ diff --git a/assets/images/Sliding_Game.png b/assets/images/Sliding_Game.png new file mode 100644 index 0000000000..d007f76594 Binary files /dev/null and b/assets/images/Sliding_Game.png differ diff --git a/assets/images/Snake-game.png b/assets/images/Snake-game.png new file mode 100644 index 0000000000..e93bab58e4 Binary files /dev/null and b/assets/images/Snake-game.png differ diff --git a/assets/images/Spirograph.png b/assets/images/Spirograph.png new file mode 100644 index 0000000000..3bb8ff547b Binary files /dev/null and b/assets/images/Spirograph.png differ diff --git a/assets/images/Tic-tac-toe.png b/assets/images/Tic-tac-toe.png new file mode 100644 index 0000000000..1cb5ce4ba2 Binary files /dev/null and b/assets/images/Tic-tac-toe.png differ diff --git a/assets/images/Tic_Tac_Toe_Neon.JPG b/assets/images/Tic_Tac_Toe_Neon.JPG new file mode 100644 index 0000000000..0bd5567f8e Binary files /dev/null and b/assets/images/Tic_Tac_Toe_Neon.JPG differ diff --git a/assets/images/TownRise-game.png b/assets/images/TownRise-game.png new file mode 100644 index 0000000000..79da84823d Binary files /dev/null and b/assets/images/TownRise-game.png differ diff --git a/assets/images/spell_bee.png b/assets/images/spell_bee.png new file mode 100644 index 0000000000..87720cc939 Binary files /dev/null and b/assets/images/spell_bee.png differ diff --git a/assets/images/whack a mole.png b/assets/images/whack a mole.png new file mode 100644 index 0000000000..eac5dc4bc4 Binary files /dev/null and b/assets/images/whack a mole.png differ diff --git a/assets/index_old.html b/assets/index_old.html index d497b1c084..86512320e9 100644 --- a/assets/index_old.html +++ b/assets/index_old.html @@ -2729,6 +2729,28 @@

    +
  • + + +
    +
    + Eye +
    + + SnakeBites +
    + +

    141.Snake_Bites🔗

    + +

    Snake Bites

    + + +
  • + +
  • diff --git a/assets/js/gamesData.json b/assets/js/gamesData.json index c2ed72ed82..f2067cd250 100644 --- a/assets/js/gamesData.json +++ b/assets/js/gamesData.json @@ -2000,6 +2000,136 @@ "thumbnailUrl": "Dot_Connect.png" }, + +"396":{ + "gameTitle": "path finder puzzle", + "gameUrl": "path_finder", + "thumbnailUrl": "pathfinder.png" +}, +"414":{ + "gameTitle": "NameFate", + "gameUrl": "namefate", + "thumbnailUrl": "namefate.png" +} +, +"500":{ + "gameTitle": "Menja block breaker", + "gameUrl": "Menja_block_breaker", + "thumbnailUrl": "menja_Block_breaker.png" +}, +"393":{ + + "gameTitle": "Pop My Balloon", + "gameUrl": "Pop_My_Balloon", + "thumbnailUrl": "Pop_My_Balloon.png" + +}, +"397":{ + "gameTitle": "Tower Stack", + "gameUrl": "Tower_Stack", + "thumbnailUrl": "Tower_Stack.png" + +}, +"395":{ + + "gameTitle": "Virtual Pet Game", + "gameUrl": "Virtual_Pet_Game", + "thumbnailUrl": "Virtual_Pet_Game.png" + + "gameTitle": "path finder puzzle", + "gameUrl": "path_finder", + "thumbnailUrl": "pathfinder.png" +}, +"411":{ "gameTitle": "Tiny Fishing", +"gameUrl": "Tiny_Fishing", +"thumbnailUrl": "Tiny_Fishing.png" +}, +"398":{ +"410":{ + "gameTitle": "Shrek Vs Wild", + "gameUrl": "Shrek_Vs_Wild", + "thumbnailUrl": "Shrek_Vs_Wild.png" +}, +"409":{ + "gameTitle": "Hover_Board_Effect", + "gameUrl": "Hover_Board_Effect", + "thumbnailUrl": "Hover_Board_Effect.png" +}, +"405":{ + "gameTitle": "Candy_Crush_Saga", + "gameUrl": "Candy_Crush_Saga", + "thumbnailUrl": "Candy_Crush_Saga.png" +},"419":{ + + "gameTitle": "16_Puzzle", + "gameUrl": "16_Puzzle", + "thumbnailUrl": "16_Puzzle.png" +}, +"420":{ + "gameTitle" : "Colour_Generator_Game", + "gameUrl": "Colour_Generator_Game", + "thumbnailUrl": "Colour_Generator_Game.png" + }, +"406":{ + "gameTitle": "Knife_hit", + "gameUrl": "Knife_hit", + "thumbnailUrl": "Knife_hit.png" +},"415":{ + "gameTitle": "Anagram_Checker_Game", + "gameUrl": "Anagram_Checker_Game", + "thumbnailUrl": "Anagram_Checker_Game.png" + +}, +"407":{ + "gameTitle": "Screen_Pet_Game", + "gameUrl": "Screen_Pet_Game", + "thumbnailUrl": "Screen_Pet_Game.png" + +},"416":{ + + + "gameTitle": "rapid_click_frenzy", + "gameUrl": "rapid_click_frenzy", + "thumbnailUrl": "rapidgame.png" + + + +} + ,"408":{ + "gameTitle": "Pen_Pointer_Fight", + "gameUrl": "PenPointerFight", + "thumbnailUrl": "PenPointerFight.png" + }, +"409":{ + "gameTitle": "Guess_The_Song", + "gameUrl": "Guess_The_Song", + "thumbnailUrl": "Guess_The_Song.png" +} + +},"418":{ + "gameTitle": "Brick Buster", + "gameUrl": "Brick Buster", + "thumbnailUrl": "Brick.png" + } + + + +},"410":{ + "gameTitle": "Brick Buster", + "gameUrl": "Brick Buster", + "thumbnailUrl": "Brick.png" + }, + "419":{ + "gameTitle": "Soccer", + "gameUrl": "Soccer", + "thumbnailUrl": "Soccer" +}, +"411":{"gameTitle": "Pen_Pointer_Fight", +"gameUrl": "PenPointerFight", +"thumbnailUrl": "PenPointerFight.png" +}, + + "398": { "gameTitle": "path finder puzzle", "gameUrl": "path_finder", @@ -2101,6 +2231,7 @@ "thumbnailUrl": "MathQuiz.png" }, "418":{ + "gameTitle": "MathQuiz", "gameUrl": "MathQuiz", "thumbnailUrl": "MathQuiz.png" @@ -2110,15 +2241,15 @@ "gameUrl":"puzzle-game", "thumbnailUrl":"puzzle-game.png" }, - -"419":{ -"gameTitle": "Pottery", -"gameUrl": "Pottery-Game", -"thumbnailUrl": "Pottery.png" -}, "421":{ "gameTitle": "ShroomKnight", "gameUrl": "ShroomKnight", "thumbnailUrl": "ShroomKnight.png" -} +}, +"421":{ + "gameTitle":"Fidget_Spinner_Game", + "gameUrl":"Fidget_Spinner_Game", + "thumbnailUrl":"Fidget.png" +}, + } diff --git a/assets/whack a mole.png b/assets/whack a mole.png new file mode 100644 index 0000000000..eac5dc4bc4 Binary files /dev/null and b/assets/whack a mole.png differ diff --git a/index.html b/index.html index 3bfd9ce5ee..e4a160a127 100644 --- a/index.html +++ b/index.html @@ -92,6 +92,18 @@ } + + + + + + +