diff --git a/.github/labeler-config.yml b/.github/labeler-config.yml deleted file mode 100644 index 2ba61325d0..0000000000 --- a/.github/labeler-config.yml +++ /dev/null @@ -1,55 +0,0 @@ -filters: - - label: 'new feature' - regexs: - - /\bfeat\b/ - - /feature/i - events: [pull_request] - targets: [title] - - - label: 'documentation' - regexs: - - /docs/i - events: [pull_request] - targets: [title] - - - label: 'documentation' - regexs: - - /readme/i - events: [pull_request] - targets: [title] - - - label: 'bug' - regexs: - - /bug/i - events: [pull_request] - targets: [title] - - label: 'bug' - regexs: - - /fix/i - events: [pull_request] - targets: [title] - - - label: 'chore' - regexs: - - /description/i - events: [pull_request] - targets: [title] - - - label: 'chore' - regexs: - - /chore/i - events: [pull_request] - targets: [title] - - - label: 'New Game 🎮' - regexs: - - /game/i - events: [pull_request] - targets: [title] - - - label: 'goal: refactor' - regexs: - - /\brefactor\b/ - - /refactor/i - events: [pull_request] - targets: [title] diff --git a/.github/workflows/add-labels-pr.yml b/.github/workflows/add-labels-pr.yml deleted file mode 100644 index 92188d3b53..0000000000 --- a/.github/workflows/add-labels-pr.yml +++ /dev/null @@ -1,24 +0,0 @@ -# reference: https://github.com/hoho4190/issue-pr-labeler -name: PR Labeler - -on: - pull_request_target: - types: - - opened - - reopened - -jobs: - main: - runs-on: ubuntu-latest - - permissions: - contents: read # to read configuration yml file - pull-requests: write # to add labels to pull requests - - steps: - - name: Run PR Labeler - uses: hoho4190/issue-pr-labeler@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - config-file-name: labeler-config.yml - # disable-bot: true # this will prevent issues, PRs created by bots diff --git a/.github/workflows/annoucement.yml b/.github/workflows/annoucement.yml index 2563efd3e2..a41367f5ed 100644 --- a/.github/workflows/annoucement.yml +++ b/.github/workflows/annoucement.yml @@ -20,6 +20,7 @@ jobs: with: github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} script: | + const hackwithus = `\n @${context.payload.sender.login} here, \n Hope you are enjoying this hacktober 😀 \n We are excited to share that we are opening issue from our side where you will be going to add games on our website 🚀 \n Work on this [issue](https://github.com/kunjgit/GameZone/issues/2944) đŸ”Ĩ \n and help us building GameZone 💗 \n if you still haven't joined us join us on ⁠[Discord](https://discord.gg/fgwk4XZfxG) \n See you soon 😊`; const commentBody = `\n @${context.payload.sender.login} here, \n We have this annoucement to make đŸ“ĸ!! \n đŸ’Ĩ Special Announcement: \nIt's the **Call to all the designers** đŸ”Ĩ 🎨 \nAs you all know that GameZone has crossed 100 games 💗 , it's time that we all come up together and make the UI even better!!\nWe are redesigning the thumbnails, make sure you come up with the aesthetic and cool ideas 🚀 !\nYou are supposed to share the 4 different templates that can be used. Make sure that the size is: **1280 px X 720 px.** \nThe frame should be such that there is only a single image of the game that's taking up the major portion of the frame. Any kind of text should not be there. \n **The design should be catchy and aesthetic!** đŸ”Ĩ \n\n **Note:** You are not supposed to create any issue right now for the same. \nYou have to share different designs right now in ⁠[Discord](https://discord.gg/fgwk4XZfxG) and Project Admin would be selecting one design and would be assigning the issue. After that only, you have to start working on it.`; const hacktoberfest = `\n @${context.payload.sender.login} here, \n Hope you are doing extremely well 😇 \n It's confirmed đŸĨŗ, GameZone is taking part in hacktoberfest and ready to have another đŸ’Ĩ \n Ready to have some amazing contributions once again also thank you for you support in GSSoC23 you have took us on top 5 ❤ī¸â€đŸ”Ĩ \n if you still haven't joined us join us on ⁠[Discord](https://discord.gg/fgwk4XZfxG) \n See you soon 😊`; @@ -40,7 +41,7 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, issue_number: issue.number, - body: `Hey @${opener} 👋!\n ${hacktoberfest}\n\n` + body: `Hey @${opener} 👋!\n ${hackwithus}\n\n` }); console.log(`Commented on issue #${issue.number}.`); diff --git a/Games/Alien_Shooters/assets/images/Screenshot 2023-10-02 000328.png b/Games/Alien_Shooters/assets/images/Screenshot 2023-10-02 000328.png new file mode 100644 index 0000000000..46fadc1d27 Binary files /dev/null and b/Games/Alien_Shooters/assets/images/Screenshot 2023-10-02 000328.png differ diff --git a/Games/Alien_Shooters/index.html b/Games/Alien_Shooters/index.html index c5009a8446..f0d19cd3cc 100644 --- a/Games/Alien_Shooters/index.html +++ b/Games/Alien_Shooters/index.html @@ -15,17 +15,28 @@
-

Alien Shooter

- +
+

Alien Shooter

+
+
+ + +
+
+

GAME OVER!!

+

your score: 0

+

press space to try again

+

press 'q' to quit

+
diff --git a/Games/Alien_Shooters/script.js b/Games/Alien_Shooters/script.js index fe66aba6a9..3c6fc06a12 100644 --- a/Games/Alien_Shooters/script.js +++ b/Games/Alien_Shooters/script.js @@ -9,16 +9,16 @@ let boardHeight = tileSize * rows; // 32 * 16 let context; //ship -let shipWidth = tileSize*2; +let shipWidth = tileSize * 2; let shipHeight = tileSize; -let shipX = tileSize * columns/2 - tileSize; -let shipY = tileSize * rows - tileSize*2; +let shipX = tileSize * columns / 2 - tileSize; +let shipY = tileSize * rows - tileSize * 2; let ship = { - x : shipX, - y : shipY, - width : shipWidth, - height : shipHeight + x: shipX, + y: shipY, + width: shipWidth, + height: shipHeight } let shipImg; @@ -26,7 +26,7 @@ let shipVelocityX = tileSize; //ship moving speed //aliens let alienArray = []; -let alienWidth = tileSize*2; +let alienWidth = tileSize * 2; let alienHeight = tileSize; let alienX = tileSize; let alienY = tileSize; @@ -41,10 +41,24 @@ let alienVelocityX = 1; //alien moving speed let bulletArray = []; let bulletVelocityY = -10; //bullet moving speed +//game variables let score = 0; let gameOver = false; +let gameStarted = false; -window.onload = function() { +function blink(blinktext) { + + + // Add a click event listener to the body of the document + document.body.addEventListener('click', () => { + // Remove the "blink" class to stop the animation + blinktext.classList.remove('blink'); + // Add a class to stop the blinking animation + blinktext.classList.add('stop-blinking'); + }) +} + +window.onload = function () { board = document.getElementById("board"); board.width = boardWidth; board.height = boardHeight; @@ -52,31 +66,36 @@ window.onload = function() { shipImg = new Image(); shipImg.src = "./assets/shooter.png"; - shipImg.onload = function() { + shipImg.onload = function () { context.drawImage(shipImg, ship.x, ship.y, ship.width, ship.height); } + const blinkText = document.querySelector("#blinktext") + blink(blinkText) - alienImg = new Image(); - generateAliens(); - createAliens(); + // check for mouse-click to start the game; + if (!gameStarted) { + document.body.addEventListener("click", main) - requestAnimationFrame(update); - document.addEventListener("keydown", moveShip); - document.addEventListener("keyup", shoot); + } } -function generateAliens(){ - var n = Math.floor(Math.random()*4); +function generateAliens() { + var n = Math.floor(Math.random() * 4); alienImg.src = "./assets/" + n + ".png"; } -function update() { +function update(e) { requestAnimationFrame(update); - if(gameOver){ - if(e.code == "Space"){ + if (gameOver) { + endscreen('block', score) + if (e.code == "Space") { resetGame(); } + if (e.code == 'KeyQ') { + gameStarted = false + location.reload() + } return; } @@ -94,7 +113,7 @@ function update() { //if alien touches the borders if (alien.x + alien.width >= board.width || alien.x <= 0) { alienVelocityX *= -1; - alien.x += alienVelocityX*2; + alien.x += alienVelocityX * 2; //move all aliens up by one row for (let j = 0; j < alienArray.length; j++) { @@ -105,9 +124,7 @@ function update() { if (alien.y >= ship.y) { gameOver = true; - context.fillStyle = "#F806CC"; - context.font = "30px 'Play'"; - context.fillText("Press 'Space' to Restart", 93, 250); + } } } @@ -116,7 +133,7 @@ function update() { for (let i = 0; i < bulletArray.length; i++) { let bullet = bulletArray[i]; bullet.y += bulletVelocityY; - context.fillStyle="white"; + context.fillStyle = "white"; context.fillRect(bullet.x, bullet.y, bullet.width, bullet.height); //bullet collision with aliens @@ -140,8 +157,8 @@ function update() { if (alienCount == 0) { //increase the number of aliens in columns and rows by 1 score += alienColumns * alienRows * 100; //bonus points :) - alienColumns = Math.min(alienColumns + 1, columns/2 -2); //cap at 16/2 -2 = 6 - alienRows = Math.min(alienRows + 1, rows-4); //cap at 16-4 = 12 + alienColumns = Math.min(alienColumns + 1, columns / 2 - 2); //cap at 16/2 -2 = 6 + alienRows = Math.min(alienRows + 1, rows - 4); //cap at 16-4 = 12 if (alienVelocityX > 0) { alienVelocityX += 0.2; //increase the alien movement speed towards the right } @@ -154,38 +171,47 @@ function update() { } //score - context.font = "23px 'Play' "; + if (!gameOver) { + context.font = "23px 'Play' "; context.fillStyle = "#FFED00"; - context.fillText("Score: ", 5, 20) - context.fillText(score, 75, 20); + context.fillText("Score: ", 5, 20) + context.fillText(score, 75, 20); + } } function moveShip(e) { - if(gameOver){ - if(e.code == "Space"){ + if (gameOver) { + if (e.code == "Space") { resetGame(); } return; } - if (e.code == "ArrowLeft" && ship.x - shipVelocityX >= 0) { + if ((e.code == "ArrowLeft" || e.code == "KeyA") && ship.x - shipVelocityX >= 0) { ship.x -= shipVelocityX; //move left one tile } - else if (e.code == "ArrowRight" && ship.x + shipVelocityX + ship.width <= board.width) { + else if ((e.code == "ArrowRight" || e.code == "KeyD") && ship.x + shipVelocityX + ship.width <= board.width) { ship.x += shipVelocityX; //move right one tile } } +function endscreen(display_value = 'none', score_txt) { + context.clearRect(0, 0, boardWidth, boardHeight) + document.querySelector(".endscreen").style.display = display_value + document.querySelector("#scorecnt").innerText = score_txt + +} + function createAliens() { for (let c = 0; c < alienColumns; c++) { for (let r = 0; r < alienRows; r++) { let alien = { - img : alienImg, - x : alienX + c*alienWidth, - y : alienY + r*alienHeight, - width : alienWidth, - height : alienHeight, - alive : true + img: alienImg, + x: alienX + c * alienWidth, + y: alienY + r * alienHeight, + width: alienWidth, + height: alienHeight, + alive: true } alienArray.push(alien); } @@ -194,8 +220,8 @@ function createAliens() { } function shoot(e) { - if(gameOver){ - if(e.code == "Space"){ + if (gameOver) { + if (e.code == "Space") { resetGame(); } return; @@ -204,11 +230,11 @@ function shoot(e) { if (e.code == "Space") { //shoot let bullet = { - x : ship.x + shipWidth*15/32, - y : ship.y, - width : tileSize/8, - height : tileSize/2, - used : false + x: ship.x + shipWidth * 15 / 32, + y: ship.y, + width: tileSize / 8, + height: tileSize / 2, + used: false } bulletArray.push(bullet); } @@ -216,20 +242,21 @@ function shoot(e) { function detectCollision(a, b) { return a.x < b.x + b.width && //a's top left doesn't reach b's top right - a.x + a.width > b.x && //a's top right passes b's top left - a.y < b.y + b.height && //a's top left doesn't reach b's bottom left - a.y + a.height > b.y; //a's bottom left passes b's top left + a.x + a.width > b.x && //a's top right passes b's top left + a.y < b.y + b.height && //a's top left doesn't reach b's bottom left + a.y + a.height > b.y; //a's bottom left passes b's top left } -function resetGame(){ +function resetGame() { score = 0; gameOver = false; + document.querySelector('.endscreen').style.display = 'none' ship = { - x : shipX, - y : shipY, - width : shipWidth, - height : shipHeight + x: shipX, + y: shipY, + width: shipWidth, + height: shipHeight } alienArray = []; @@ -238,4 +265,22 @@ function resetGame(){ generateAliens(); createAliens(); alienVelocityX = 1; +} +function main() { + gameStarted = true + let title = document.querySelector(".title") + let startscreen = document.querySelector(".startscreen") + title.style.display = 'none' + startscreen.style.display = 'none' + + document.body.removeEventListener('click', main)// removing the previously added + //event listener after the game started. + alienImg = new Image(); + generateAliens(); + createAliens(); + + requestAnimationFrame(update); + document.addEventListener("keydown", moveShip); + document.addEventListener("keydown", update); + document.addEventListener("keyup", shoot); } \ No newline at end of file diff --git a/Games/Alien_Shooters/style.css b/Games/Alien_Shooters/style.css index 17dbc2a744..00048db5e6 100644 --- a/Games/Alien_Shooters/style.css +++ b/Games/Alien_Shooters/style.css @@ -9,7 +9,9 @@ body { overflow: hidden; } -h1{ +.title{ + position: absolute; + margin-bottom: 600px; color: #00B7C2; } @@ -20,10 +22,43 @@ h1{ } ul{ + color: white; text-align: left; } li{ + margin: 1rem; +} + +.startscreen{ + position: absolute; + width: 700px; +} + + +.startscreen p{ + color: yellow; +} +.endscreen{ + position: absolute; + display: none; + color: white; + font-size: larger; +} +@keyframes blink { + 0% { opacity: 1; } + 50% { opacity: 0; } + 100% { opacity: 1; } +} + +/* Apply the animation to the

element */ +.blink { + animation: blink 1s infinite; /* Adjust the duration as needed */ +} + +/* Add a class to stop the animation */ +.stop-blinking { + animation: none; } \ No newline at end of file diff --git a/Games/HangMan/README.md b/Games/HangMan/README.md index 5b858528d0..7bd95a1434 100644 --- a/Games/HangMan/README.md +++ b/Games/HangMan/README.md @@ -1,27 +1,32 @@ -# **Game_Name** -HangMan ---- +# **Game_Name** + +## HangMan
## **Description 📃** + -A guessing game where you are supposed to guess the given word within the alloted number of lives. +A guessing game where you are supposed to guess the given word within the alloted number of lives. ## **functionalities 🎮** + --You begin the game and a pick a category.
+ +-You begin the game.
-A random word from the picked category in generated in a hidden way.
-The player can try to guess the word by guessing each letter.
+-The hint is given in some sentences the player have to gusses the word according to given HINT.
-The man hanging gets a new body part each time the player makes a wrong guess.
-The letter will be revealed at its supposed location when the player makes a right guess.

## **How to play? 🕹ī¸** + --Pick a category.
+ -Guess a letter.
-Keep guessing a letter that could be present in the word until you get the word right.
-For every wrong guess the stick figure gains a body part and the game is over when he gets a head, body and all four limbs.
@@ -31,6 +36,3 @@ A guessing game where you are supposed to guess the given word within the allote ## **Screenshots 📸**
- - -![HangMan](https://github.com/MrVisc/GameZone/assets/83546275/bf16fd32-6f96-43a9-988c-8d38b764fa3d) diff --git a/Games/HangMan/images/hangman-0.svg b/Games/HangMan/images/hangman-0.svg new file mode 100644 index 0000000000..4413c3726b --- /dev/null +++ b/Games/HangMan/images/hangman-0.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/Games/HangMan/images/hangman-1.svg b/Games/HangMan/images/hangman-1.svg new file mode 100644 index 0000000000..700cf11770 --- /dev/null +++ b/Games/HangMan/images/hangman-1.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Games/HangMan/images/hangman-2.svg b/Games/HangMan/images/hangman-2.svg new file mode 100644 index 0000000000..780d93b529 --- /dev/null +++ b/Games/HangMan/images/hangman-2.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/Games/HangMan/images/hangman-3.svg b/Games/HangMan/images/hangman-3.svg new file mode 100644 index 0000000000..f51cf84810 --- /dev/null +++ b/Games/HangMan/images/hangman-3.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/Games/HangMan/images/hangman-4.svg b/Games/HangMan/images/hangman-4.svg new file mode 100644 index 0000000000..1cc6ccfc52 --- /dev/null +++ b/Games/HangMan/images/hangman-4.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/Games/HangMan/images/hangman-5.svg b/Games/HangMan/images/hangman-5.svg new file mode 100644 index 0000000000..96158f996f --- /dev/null +++ b/Games/HangMan/images/hangman-5.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/Games/HangMan/images/hangman-6.svg b/Games/HangMan/images/hangman-6.svg new file mode 100644 index 0000000000..57d572126b --- /dev/null +++ b/Games/HangMan/images/hangman-6.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/Games/HangMan/images/lost.gif b/Games/HangMan/images/lost.gif new file mode 100644 index 0000000000..dc892b7d58 Binary files /dev/null and b/Games/HangMan/images/lost.gif differ diff --git a/Games/HangMan/images/victory.gif b/Games/HangMan/images/victory.gif new file mode 100644 index 0000000000..d33e5f8384 Binary files /dev/null and b/Games/HangMan/images/victory.gif differ diff --git a/Games/HangMan/index.html b/Games/HangMan/index.html index 263cf8d037..36768bb6f1 100644 --- a/Games/HangMan/index.html +++ b/Games/HangMan/index.html @@ -1,28 +1,35 @@ - - - Hangman - - - - - -

+ + + Hangman Game + + + + + +
+
+ gif +

Game Over!

+

The correct word was: rainbow

+ +
+
-
-
-
- -
-
- -
+
+ hangman-img +

Hangman Game

+
+
+ +

Hint:

+

Incorrect guesses:

+
+
- - - + \ No newline at end of file diff --git a/Games/HangMan/script.js b/Games/HangMan/script.js deleted file mode 100644 index 05b7dc3ea2..0000000000 --- a/Games/HangMan/script.js +++ /dev/null @@ -1,642 +0,0 @@ -//Initial References -const letterContainer = document.getElementById("letter-container"); -const optionsContainer = document.getElementById("options-container"); -const userInputSection = document.getElementById("user-input-section"); -const newGameContainer = document.getElementById("new-game-container"); -const newGameButton = document.getElementById("new-game-button"); -const canvas = document.getElementById("canvas"); -const resultText = document.getElementById("result-text"); - -//Options values for buttons -let options = { - fruits : [ - "Apple", - "Banana", - "Orange", - "Mango", - "Strawberry", - "Pineapple", - "Watermelon", - "Grapes", - "Lemon", - "Kiwi", - "Pear", - "Blueberry", - "Raspberry", - "Cherry", - "Peach", - "Plum", - "Avocado", - "Coconut", - "Papaya", - "Mandarin", - "Grapefruit", - "Lime", - "Blackberry", - "Cantaloupe", - "Apricot", - "Fig", - "Pomegranate", - "Cranberry", - "Pineapple", - "Raspberry", - "Mango", - "Kiwi", - "Cherry", - "Blueberry", - "Watermelon", - "Strawberry", - "Papaya", - "Passionfruit", - "Lemon", - "Lime", - "Grapefruit", - "Orange", - "Banana", - "Peach", - "Pear", - "Plum", - "Apple", - "Coconut", - "Avocado", - "Guava", - "Pineapple", - "Melon", - "Blackberry", - "Cranberry", - "Fig", - "Pomegranate", - "Date", - "Cantaloupe", - "Dragonfruit", - "Durian", - "Elderberry", - "Feijoa", - "Gooseberry", - "Honeydew", - "Jackfruit", - "Kiwano", - "Kumquat", - "Lychee", - "Mandarin", - "Nectarine", - "Olive", - "Pawpaw", - "Quince", - "Rambutan", - "Soursop", - "Tangerine", - "Ugli fruit", - "Vanilla bean", - "Walnut", - "Xigua", - "Yellow passionfruit", - "Zucchini", - "Ackee", - "Bilberry", - "Cactus fruit", - "Damson", - "Eggfruit", - "Feijoa", - "Gac", - "Horned melon", - "Imbe", - "Jabuticaba", - "Kaffir lime", - "Lulo", - "Mamey sapote", - "Nance", - "Ogeechee lime", - "Pitanga", - "Quandong", - "Rambutan", - "Salmonberry", - "Tamarillo", - "Ugni", - "Velvet apple", - "White currant", - "Yantok", - "Zig zag vine" - ], - - animals : [ - "Lion", - "Tiger", - "Elephant", - "Giraffe", - "Hippopotamus", - "Cheetah", - "Zebra", - "Kangaroo", - "Koala", - "Gorilla", - "Monkey", - "Panda", - "Leopard", - "Rhino", - "Horse", - "Cow", - "Sheep", - "Goat", - "Pig", - "Dog", - "Cat", - "Rabbit", - "Mouse", - "Squirrel", - "Hedgehog", - "Fox", - "Wolf", - "Bear", - "Deer", - "Raccoon", - "Skunk", - "Opossum", - "Otter", - "Seal", - "Walrus", - "Dolphin", - "Whale", - "Shark", - "Octopus", - "Squid", - "Jellyfish", - "Starfish", - "Turtle", - "Crocodile", - "Snake", - "Lizard", - "Frog", - "Toad", - "Newt", - "Chameleon", - "Tortoise", - "Flamingo", - "Pelican", - "Swan", - "Duck", - "Goose", - "Ostrich", - "Penguin", - "Eagle", - "Hawk", - "Owl", - "Parrot", - "Peacock", - "Sparrow", - "Robin", - "Hummingbird", - "Butterfly", - "Dragonfly", - "Bee", - "Ladybug", - "Ant", - "Grasshopper", - "Caterpillar", - "Snail", - "Spider", - "Centipede", - "Scorpion", - "Crab", - "Lobster", - "Shrimp", - "Starfish", - "Fish", - "Seahorse", - "Clownfish", - "Dolphin", - "Whale", - "Jellyfish", - "Seal", - "Walrus", - "Polar bear", - "Penguin", - "Koala", - "Kangaroo", - "Wombat", - "Platypus", - "Tasmanian devil", - "Emu", - "Kookaburra", - "Dingo", - "Cassowary", - "Sugar glider", - "Quokka", - "Numbat", - "Bilby", - "Echidna", - "Cockatoo", - "Koala", - "Tasmanian tiger", - "Wallaby", - "Dingo" - ], - - countries : [ - "Afghanistan", - "Albania", - "Algeria", - "Andorra", - "Angola", - "Antigua and Barbuda", - "Argentina", - "Armenia", - "Australia", - "Austria", - "Azerbaijan", - "Bahamas", - "Bahrain", - "Bangladesh", - "Barbados", - "Belarus", - "Belgium", - "Belize", - "Benin", - "Bhutan", - "Bolivia", - "Bosnia and Herzegovina", - "Botswana", - "Brazil", - "Brunei", - "Bulgaria", - "Burkina Faso", - "Burundi", - "Cabo Verde", - "Cambodia", - "Cameroon", - "Canada", - "Central African Republic", - "Chad", - "Chile", - "China", - "Colombia", - "Comoros", - "Congo", - "Costa Rica", - "Croatia", - "Cuba", - "Cyprus", - "Czechia", - "Denmark", - "Djibouti", - "Dominica", - "Dominican Republic", - "Ecuador", - "Egypt", - "El Salvador", - "Equatorial Guinea", - "Eritrea", - "Estonia", - "Eswatini", - "Ethiopia", - "Fiji", - "Finland", - "France", - "Gabon", - "Gambia", - "Georgia", - "Germany", - "Ghana", - "Greece", - "Grenada", - "Guatemala", - "Guinea", - "Guinea-Bissau", - "Guyana", - "Haiti", - "Honduras", - "Hungary", - "Iceland", - "India", - "Indonesia", - "Iran", - "Iraq", - "Ireland", - "Israel", - "Italy", - "Jamaica", - "Japan", - "Jordan", - "Kazakhstan", - "Kenya", - "Kiribati", - "Kuwait", - "Kyrgyzstan", - "Laos", - "Latvia", - "Lebanon", - "Lesotho", - "Liberia", - "Libya", - "Liechtenstein", - "Lithuania", - "Luxembourg", - "Madagascar", - "Malawi", - "Malaysia", - "Maldives", - "Mali", - "Malta", - "Marshall Islands", - "Mauritania", - "Mauritius", - "Mexico", - "Micronesia", - "Moldova", - "Monaco", - "Mongolia", - "Montenegro", - "Morocco", - "Mozambique", - "Myanmar", - "Namibia", - "Nauru", - "Nepal", - "Netherlands", - "New Zealand", - "Nicaragua", - "Niger", - "Nigeria", - "North Korea", - "North Macedonia", - "Norway", - "Oman", - "Pakistan", - "Palau", - "Palestine", - "Panama", - "Papua New Guinea", - "Paraguay", - "Peru", - "Philippines", - "Poland", - "Portugal", - "Qatar", - "Romania", - "Russia", - "Rwanda", - "Saint Kitts and Nevis", - "Saint Lucia", - "Saint Vincent and the Grenadines", - "Samoa", - "San Marino", - "Sao Tome and Principe", - "Saudi Arabia", - "Senegal", - "Serbia", - "Seychelles", - "Sierra Leone", - "Singapore", - "Slovakia", - "Slovenia", - "Solomon Islands", - "Somalia", - "South Africa", - "South Korea", - "South Sudan", - "Spain", - "Sri Lanka", - "Sudan", - "Suriname", - "Sweden", - "Switzerland", - "Syria", - "Taiwan", - "Tajikistan", - "Tanzania", - "Thailand", - "Timor-Leste", - "Togo", - "Tonga", - "Trinidad and Tobago", - "Tunisia", - "Turkey", - "Turkmenistan", - "Tuvalu", - "Uganda", - "Ukraine", - "United Arab Emirates", - "United Kingdom", - "United States of America", - "Uruguay", - "Uzbekistan", - "Vanuatu", - "Vatican City", - "Venezuela", - "Vietnam", - "Yemen", - "Zambia", - "Zimbabwe" - ], - -}; - -//count -let winCount = 0; -let count = 0; - -let chosenWord = ""; - -//Display option buttons -const displayOptions = () => { - optionsContainer.innerHTML += `

Please Select An Option

`; - let buttonCon = document.createElement("div"); - for (let value in options) { - buttonCon.innerHTML += ``; - } - optionsContainer.appendChild(buttonCon); -}; - -//Block all the Buttons -const blocker = () => { - let optionsButtons = document.querySelectorAll(".options"); - let letterButtons = document.querySelectorAll(".letters"); - //disable all options - optionsButtons.forEach((button) => { - button.disabled = true; - }); - - //disable all letters - letterButtons.forEach((button) => { - button.disabled.true; - }); - newGameContainer.classList.remove("hide"); -}; - -//Word Generator -const generateWord = (optionValue) => { - let optionsButtons = document.querySelectorAll(".options"); - //If optionValur matches the button innerText then highlight the button - optionsButtons.forEach((button) => { - if (button.innerText.toLowerCase() === optionValue) { - button.classList.add("active"); - } - button.disabled = true; - }); - - //initially hide letters, clear previous word - letterContainer.classList.remove("hide"); - userInputSection.innerText = ""; - - let optionArray = options[optionValue]; - //choose random word - chosenWord = optionArray[Math.floor(Math.random() * optionArray.length)]; - chosenWord = chosenWord.toUpperCase(); - - //replace every letter with span containing dash - let displayItem = chosenWord.replace(/./g, '_'); - - //Display each element as span - userInputSection.innerHTML = displayItem; -}; - -//Initial Function (Called when page loads/user presses new game) -const initializer = () => { - winCount = 0; - count = 0; - - //Initially erase all content and hide letteres and new game button - userInputSection.innerHTML = ""; - optionsContainer.innerHTML = ""; - letterContainer.classList.add("hide"); - newGameContainer.classList.add("hide"); - letterContainer.innerHTML = ""; - - //For creating letter buttons - for (let i = 65; i < 91; i++) { - let button = document.createElement("button"); - button.classList.add("letters"); - //Number to ASCII[A-Z] - button.innerText = String.fromCharCode(i); - //character button click - button.addEventListener("click", () => { - let charArray = chosenWord.split(""); - let dashes = document.getElementsByClassName("dashes"); - //if array contains clciked value replace the matched dash with letter else dram on canvas - if (charArray.includes(button.innerText)) { - charArray.forEach((char, index) => { - //if character in array is same as clicked button - if (char === button.innerText) { - //replace dash with letter - dashes[index].innerText = char; - //increment counter - winCount += 1; - //if winCount equals word lenfth - if (winCount == charArray.length) { - resultText.innerHTML = `

You Win!!

The word was ${chosenWord}

`; - //block all buttons - blocker(); - } - } - }); - } else { - //lose count - count += 1; - //for drawing man - drawMan(count); - //Count==6 because head,body,left arm, right arm,left leg,right leg - if (count == 6) { - resultText.innerHTML = `

You Lose!!

The word was ${chosenWord}

`; - blocker(); - } - } - //disable clicked button - button.disabled = true; - }); - letterContainer.append(button); - } - - displayOptions(); - //Call to canvasCreator (for clearing previous canvas and creating initial canvas) - let { initialDrawing } = canvasCreator(); - //initialDrawing would draw the frame - initialDrawing(); -}; - -//Canvas -const canvasCreator = () => { - let context = canvas.getContext("2d"); - context.beginPath(); - context.strokeStyle = "#000"; - context.lineWidth = 2; - - //For drawing lines - const drawLine = (fromX, fromY, toX, toY) => { - context.moveTo(fromX, fromY); - context.lineTo(toX, toY); - context.stroke(); - }; - - const head = () => { - context.beginPath(); - context.arc(70, 30, 10, 0, Math.PI * 2, true); - context.stroke(); - }; - - const body = () => { - drawLine(70, 40, 70, 80); - }; - - const leftArm = () => { - drawLine(70, 50, 50, 70); - }; - - const rightArm = () => { - drawLine(70, 50, 90, 70); - }; - - const leftLeg = () => { - drawLine(70, 80, 50, 110); - }; - - const rightLeg = () => { - drawLine(70, 80, 90, 110); - }; - - //initial frame - const initialDrawing = () => { - //clear canvas - context.clearRect(0, 0, context.canvas.width, context.canvas.height); - //bottom line - drawLine(10, 130, 130, 130); - //left line - drawLine(10, 10, 10, 131); - //top line - drawLine(10, 10, 70, 10); - //small top line - drawLine(70, 10, 70, 20); - }; - - return { initialDrawing, head, body, leftArm, rightArm, leftLeg, rightLeg }; -}; - -//draw the man -const drawMan = (count) => { - let { head, body, leftArm, rightArm, leftLeg, rightLeg } = canvasCreator(); - switch (count) { - case 1: - head(); - break; - case 2: - body(); - break; - case 3: - leftArm(); - break; - case 4: - rightArm(); - break; - case 5: - leftLeg(); - break; - case 6: - rightLeg(); - break; - default: - break; - } -}; - -//New Game -newGameButton.addEventListener("click", initializer); -window.onload = initializer; \ No newline at end of file diff --git a/Games/HangMan/scripts/script.js b/Games/HangMan/scripts/script.js new file mode 100644 index 0000000000..7a596c8614 --- /dev/null +++ b/Games/HangMan/scripts/script.js @@ -0,0 +1,73 @@ +const wordDisplay = document.querySelector(".word-display"); +const guessesText = document.querySelector(".guesses-text b"); +const keyboardDiv = document.querySelector(".keyboard"); +const hangmanImage = document.querySelector(".hangman-box img"); +const gameModal = document.querySelector(".game-modal"); +const playAgainBtn = gameModal.querySelector("button"); + +// Initializing game variables +let currentWord, correctLetters, wrongGuessCount; +const maxGuesses = 6; + +const resetGame = () => { + // Ressetting game variables and UI elements + correctLetters = []; + wrongGuessCount = 0; + hangmanImage.src = "images/hangman-0.svg"; + guessesText.innerText = `${wrongGuessCount} / ${maxGuesses}`; + wordDisplay.innerHTML = currentWord.split("").map(() => `
  • `).join(""); + keyboardDiv.querySelectorAll("button").forEach(btn => btn.disabled = false); + gameModal.classList.remove("show"); +} + +const getRandomWord = () => { + // Selecting a random word and hint from the wordList + const { word, hint } = wordList[Math.floor(Math.random() * wordList.length)]; + currentWord = word; // Making currentWord as random word + document.querySelector(".hint-text b").innerText = hint; + resetGame(); +} + +const gameOver = (isVictory) => { + // After game complete.. showing modal with relevant details + const modalText = isVictory ? `You found the word:` : 'The correct word was:'; + gameModal.querySelector("img").src = `images/${isVictory ? 'victory' : 'lost'}.gif`; + gameModal.querySelector("h4").innerText = isVictory ? 'Congrats!' : 'Game Over!'; + gameModal.querySelector("p").innerHTML = `${modalText} ${currentWord}`; + gameModal.classList.add("show"); +} + +const initGame = (button, clickedLetter) => { + // Checking if clickedLetter is exist on the currentWord + if(currentWord.includes(clickedLetter)) { + // Showing all correct letters on the word display + [...currentWord].forEach((letter, index) => { + if(letter === clickedLetter) { + correctLetters.push(letter); + wordDisplay.querySelectorAll("li")[index].innerText = letter; + wordDisplay.querySelectorAll("li")[index].classList.add("guessed"); + } + }); + } else { + // If clicked letter doesn't exist then update the wrongGuessCount and hangman image + wrongGuessCount++; + hangmanImage.src = `images/hangman-${wrongGuessCount}.svg`; + } + button.disabled = true; // Disabling the clicked button so user can't click again + guessesText.innerText = `${wrongGuessCount} / ${maxGuesses}`; + + // Calling gameOver function if any of these condition meets + if(wrongGuessCount === maxGuesses) return gameOver(false); + if(correctLetters.length === currentWord.length) return gameOver(true); +} + +// Creating keyboard buttons and adding event listeners +for (let i = 97; i <= 122; i++) { + const button = document.createElement("button"); + button.innerText = String.fromCharCode(i); + keyboardDiv.appendChild(button); + button.addEventListener("click", (e) => initGame(e.target, String.fromCharCode(i))); +} + +getRandomWord(); +playAgainBtn.addEventListener("click", getRandomWord); \ No newline at end of file diff --git a/Games/HangMan/scripts/word-list.js b/Games/HangMan/scripts/word-list.js new file mode 100644 index 0000000000..61107d9990 --- /dev/null +++ b/Games/HangMan/scripts/word-list.js @@ -0,0 +1,262 @@ +const wordList = [ + { + word: "guitar", + hint: "A musical instrument with strings." + }, + { + word: "oxygen", + hint: "A colorless, odorless gas essential for life." + }, + { + word: "mountain", + hint: "A large natural elevation of the Earth's surface." + }, + { + word: "painting", + hint: "An art form using colors on a surface to create images or expression." + }, + { + word: "astronomy", + hint: "The scientific study of celestial objects and phenomena." + }, + { + word: "football", + hint: "A popular sport played with a spherical ball." + }, + { + word: "chocolate", + hint: "A sweet treat made from cocoa beans." + }, + { + word: "butterfly", + hint: "An insect with colorful wings and a slender body." + }, + { + word: "history", + hint: "The study of past events and human civilization." + }, + { + word: "pizza", + hint: "A savory dish consisting of a round, flattened base with toppings." + }, + { + word: "jazz", + hint: "A genre of music characterized by improvisation and syncopation." + }, + { + word: "camera", + hint: "A device used to capture and record images or videos." + }, + { + word: "diamond", + hint: "A precious gemstone known for its brilliance and hardness." + }, + { + word: "adventure", + hint: "An exciting or daring experience." + }, + { + word: "science", + hint: "The systematic study of the structure and behavior of the physical and natural world." + }, + { + word: "bicycle", + hint: "A human-powered vehicle with two wheels." + }, + { + word: "sunset", + hint: "The daily disappearance of the sun below the horizon." + }, + { + word: "coffee", + hint: "A popular caffeinated beverage made from roasted coffee beans." + }, + { + word: "dance", + hint: "A rhythmic movement of the body often performed to music." + }, + { + word: "galaxy", + hint: "A vast system of stars, gas, and dust held together by gravity." + }, + { + word: "orchestra", + hint: "A large ensemble of musicians playing various instruments." + }, + { + word: "volcano", + hint: "A mountain or hill with a vent through which lava, rock fragments, hot vapor, and gas are ejected." + }, + { + word: "novel", + hint: "A long work of fiction, typically with a complex plot and characters." + }, + { + word: "sculpture", + hint: "A three-dimensional art form created by shaping or combining materials." + }, + { + word: "symphony", + hint: "A long musical composition for a full orchestra, typically in multiple movements." + }, + { + word: "architecture", + hint: "The art and science of designing and constructing buildings." + }, + { + word: "ballet", + hint: "A classical dance form characterized by precise and graceful movements." + }, + { + word: "astronaut", + hint: "A person trained to travel and work in space." + }, + { + word: "waterfall", + hint: "A cascade of water falling from a height." + }, + { + word: "technology", + hint: "The application of scientific knowledge for practical purposes." + }, + { + word: "rainbow", + hint: "A meteorological phenomenon that is caused by reflection, refraction, and dispersion of light." + }, + { + word: "universe", + hint: "All existing matter, space, and time as a whole." + }, + { + word: "piano", + hint: "A musical instrument played by pressing keys that cause hammers to strike strings." + }, + { + word: "vacation", + hint: "A period of time devoted to pleasure, rest, or relaxation." + }, + { + word: "rainforest", + hint: "A dense forest characterized by high rainfall and biodiversity." + }, + { + word: "theater", + hint: "A building or outdoor area in which plays, movies, or other performances are staged." + }, + { + word: "telephone", + hint: "A device used to transmit sound over long distances." + }, + { + word: "language", + hint: "A system of communication consisting of words, gestures, and syntax." + }, + { + word: "desert", + hint: "A barren or arid land with little or no precipitation." + }, + { + word: "sunflower", + hint: "A tall plant with a large yellow flower head." + }, + { + word: "fantasy", + hint: "A genre of imaginative fiction involving magic and supernatural elements." + }, + { + word: "telescope", + hint: "An optical instrument used to view distant objects in space." + }, + { + word: "breeze", + hint: "A gentle wind." + }, + { + word: "oasis", + hint: "A fertile spot in a desert where water is found." + }, + { + word: "photography", + hint: "The art, process, or practice of creating images by recording light or other electromagnetic radiation." + }, + { + word: "safari", + hint: "An expedition or journey, typically to observe wildlife in their natural habitat." + }, + { + word: "planet", + hint: "A celestial body that orbits a star and does not produce light of its own." + }, + { + word: "river", + hint: "A large natural stream of water flowing in a channel to the sea, a lake, or another such stream." + }, + { + word: "tropical", + hint: "Relating to or situated in the region between the Tropic of Cancer and the Tropic of Capricorn." + }, + { + word: "mysterious", + hint: "Difficult or impossible to understand, explain, or identify." + }, + { + word: "enigma", + hint: "Something that is mysterious, puzzling, or difficult to understand." + }, + { + word: "paradox", + hint: "A statement or situation that contradicts itself or defies intuition." + }, + { + word: "puzzle", + hint: "A game, toy, or problem designed to test ingenuity or knowledge." + }, + { + word: "whisper", + hint: "To speak very softly or quietly, often in a secretive manner." + }, + { + word: "shadow", + hint: "A dark area or shape produced by an object blocking the light." + }, + { + word: "secret", + hint: "Something kept hidden or unknown to others." + }, + { + word: "curiosity", + hint: "A strong desire to know or learn something." + }, + { + word: "unpredictable", + hint: "Not able to be foreseen or known beforehand; uncertain." + }, + { + word: "obfuscate", + hint: "To confuse or bewilder someone; to make something unclear or difficult to understand." + }, + { + word: "unveil", + hint: "To make known or reveal something previously secret or unknown." + }, + { + word: "illusion", + hint: "A false perception or belief; a deceptive appearance or impression." + }, + { + word: "moonlight", + hint: "The light from the moon." + }, + { + word: "vibrant", + hint: "Full of energy, brightness, and life." + }, + { + word: "nostalgia", + hint: "A sentimental longing or wistful affection for the past." + }, + { + word: "brilliant", + hint: "Exceptionally clever, talented, or impressive." + }, +]; \ No newline at end of file diff --git a/Games/HangMan/style.css b/Games/HangMan/style.css new file mode 100644 index 0000000000..43fb839510 --- /dev/null +++ b/Games/HangMan/style.css @@ -0,0 +1,187 @@ +/* Importing Google font - Open Sans */ +@import url("https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;500;600;700&display=swap"); +* { + margin: 0; + padding: 0; + box-sizing: border-box; + font-family: "Open Sans", sans-serif; +} +body { + display: flex; + padding: 0 10px; + align-items: center; + justify-content: center; + min-height: 100vh; + background: #5E63BA; +} +.container { + display: flex; + width: 850px; + gap: 70px; + padding: 60px 40px; + background: #fff; + border-radius: 10px; + align-items: flex-end; + justify-content: space-between; + box-shadow: 0 10px 20px rgba(0,0,0,0.1); +} +.hangman-box img { + user-select: none; + max-width: 270px; +} +.hangman-box h1 { + font-size: 1.45rem; + text-align: center; + margin-top: 20px; + text-transform: uppercase; +} +.game-box .word-display { + gap: 10px; + list-style: none; + display: flex; + flex-wrap: wrap; + justify-content: center; + align-items: center; +} +.word-display .letter { + width: 28px; + font-size: 2rem; + text-align: center; + font-weight: 600; + margin-bottom: 40px; + text-transform: uppercase; + border-bottom: 3px solid #000; +} +.word-display .letter.guessed { + margin: -40px 0 35px; + border-color: transparent; +} +.game-box h4 { + text-align: center; + font-size: 1.1rem; + font-weight: 500; + margin-bottom: 15px; +} +.game-box h4 b { + font-weight: 600; +} +.game-box .guesses-text b { + color: #ff0000; +} +.game-box .keyboard { + display: flex; + gap: 5px; + flex-wrap: wrap; + margin-top: 40px; + justify-content: center; +} +:where(.game-modal, .keyboard) button { + color: #fff; + border: none; + outline: none; + cursor: pointer; + font-size: 1rem; + font-weight: 600; + border-radius: 4px; + text-transform: uppercase; + background: #5E63BA; +} +.keyboard button { + padding: 7px; + width: calc(100% / 9 - 5px); +} +.keyboard button[disabled] { + pointer-events: none; + opacity: 0.6; +} +:where(.game-modal, .keyboard) button:hover { + background: #8286c9; +} +.game-modal { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + opacity: 0; + pointer-events: none; + background: rgba(0,0,0,0.6); + display: flex; + align-items: center; + justify-content: center; + z-index: 9999; + padding: 0 10px; + transition: opacity 0.4s ease; +} +.game-modal.show { + opacity: 1; + pointer-events: auto; + transition: opacity 0.4s 0.4s ease; +} +.game-modal .content { + padding: 30px; + max-width: 420px; + width: 100%; + border-radius: 10px; + background: #fff; + text-align: center; + box-shadow: 0 10px 20px rgba(0,0,0,0.1); +} +.game-modal img { + max-width: 130px; + margin-bottom: 20px; +} +.game-modal img[src="images/victory.gif"] { + margin-left: -10px; +} +.game-modal h4 { + font-size: 1.53rem; +} +.game-modal p { + font-size: 1.15rem; + margin: 15px 0 30px; + font-weight: 500; +} +.game-modal p b { + color: #5E63BA; + font-weight: 600; +} +.game-modal button { + padding: 12px 23px; +} + +@media (max-width: 782px) { + .container { + flex-direction: column; + padding: 30px 15px; + align-items: center; + } + .hangman-box img { + max-width: 200px; + } + .hangman-box h1 { + display: none; + } + .game-box h4 { + font-size: 1rem; + } + .word-display .letter { + margin-bottom: 35px; + font-size: 1.7rem; + } + .word-display .letter.guessed { + margin: -35px 0 25px; + } + .game-modal img { + max-width: 120px; + } + .game-modal h4 { + font-size: 1.45rem; + } + .game-modal p { + font-size: 1.1rem; + } + .game-modal button { + padding: 10px 18px; + } +} \ No newline at end of file diff --git a/Games/HangMan/styles.css b/Games/HangMan/styles.css deleted file mode 100644 index be29a4c698..0000000000 --- a/Games/HangMan/styles.css +++ /dev/null @@ -1,119 +0,0 @@ -* { - padding: 0; - margin: 0; - box-sizing: border-box; - font-family: "Poppins", sans-serif; -} -body { - background-color: #34167a; -} -.container { - font-size: 16px; - background-color: #ffffff; - width: 90vw; - max-width: 34em; - position: absolute; - transform: translate(-50%, -50%); - top: 50%; - left: 50%; - padding: 3em; - border-radius: 0.6em; - box-shadow: 0 1.2em 2.4em rgba(111, 85, 0, 0.25); -} -#options-container { - text-align: center; -} -#options-container div { - width: 100%; - display: flex; - justify-content: space-between; - margin: 1.2em 0 2.4em 0; -} -#options-container button { - padding: 0.6em 1.2em; - border: 3px solid #000000; - background-color: #ffffff; - color: #000000; - border-radius: 0.3em; - text-transform: capitalize; - cursor: pointer; -} -#options-container button:disabled { - border: 3px solid #808080; - color: #808080; - background-color: #efefef; -} -#options-container button.active { - background-color: #6e32e8; - border: 3px solid #000000; - color: #fff; -} -.letter-container { - width: 100%; - display: flex; - flex-wrap: wrap; - justify-content: center; - gap: 0.6em; -} -#letter-container button { - height: 2.4em; - width: 2.4em; - border-radius: 0.3em; - background-color: #ffffff; - cursor: pointer; -} -.new-game-popup { - background-color: #ffffff; - position: absolute; - left: 0; - top: 0; - height: 100%; - width: 100%; - display: flex; - align-items: center; - justify-content: center; - flex-direction: column; - border-radius: 0.6em; -} - -#user-input-section { - display: flex; - justify-content: center; - font-size: 1.8em; - margin: 0.6em 0 1.2em 0; -} -canvas { - display: block; - margin: auto; - border: 10px solid #064459; - border-radius: 10px; -} -.hide { - display: none; -} -#result-text h2 { - font-size: 1.8em; - text-align: center; -} -#result-text p { - font-size: 1.25em; - margin: 1em 0 2em 0; -} -#result-text span { - font-weight: 600; -} -#new-game-button { - font-size: 1.25em; - padding: 0.5em 1em; - background-color: #340d81; - border: 3px solid #000000; - color: #fff; - border-radius: 0.2em; - cursor: pointer; -} -.win-msg { - color: #350b7d; -} -.lose-msg { - color: #f92b2b; -} \ No newline at end of file diff --git a/Games/Puzzel_winner/README.md b/Games/Puzzel_winner/README.md new file mode 100644 index 0000000000..95ea896438 --- /dev/null +++ b/Games/Puzzel_winner/README.md @@ -0,0 +1,27 @@ +# **Game_Name** +Puzzel Winer +--- + +
    + +## **Description 📃** +In this game you can upload you image and play puzzle + + +
    + +## **Screenshots 📸** +![image](https://github.com/kunjgit/GameZone/assets/98798977/5012ff8b-b3dd-476e-a0db-71468106b35b) + + +
    + + + +
    + +## **Working video 📹** + + +https://github.com/kunjgit/GameZone/assets/98798977/2bc67ea6-9b93-4135-bed5-8297b417d4ff + diff --git a/Games/Puzzel_winner/art.jpg b/Games/Puzzel_winner/art.jpg new file mode 100644 index 0000000000..34bc11acdf Binary files /dev/null and b/Games/Puzzel_winner/art.jpg differ diff --git a/Games/Puzzel_winner/example.html b/Games/Puzzel_winner/example.html new file mode 100644 index 0000000000..d027871c40 --- /dev/null +++ b/Games/Puzzel_winner/example.html @@ -0,0 +1,38 @@ + + + + + + +
    + + + + diff --git a/Games/Puzzel_winner/fifteen_puzzle.js b/Games/Puzzel_winner/fifteen_puzzle.js new file mode 100644 index 0000000000..53fb6bfcc2 --- /dev/null +++ b/Games/Puzzel_winner/fifteen_puzzle.js @@ -0,0 +1,115 @@ +var p=setup.puzzle_fifteen,freeslot=[],size=[],m=[],o,f=document.getElementById("fifteen"); +ceation_slots(); +function ceation_slots(){ + size=[p.size[0]/(p.grid[0]+1),p.size[1]/(p.grid[1]+1)] + var c=(p.emptySlot)?p.emptySlot:(p.grid[1]+1)*(p.grid[0]+1); + f.style.width=p.size[0]+'px'; + f.style.height=p.size[1]+'px'; + f.style.position='relative'; + if(p.fill){fifteen_resize();window.addEventListener('resize',fifteen_resize,true);} + o=1; + for(var y=0;y<=p.grid[1];y++){ + for(var x=0;x<=p.grid[0];x++){ + if(o!=c){ + if(!m[y]){m[y]=[]};m[y][x]=o; + var e=document.createElement("div"); + e.id="slot"+o; + e.setAttribute("onclick","move_slot("+o+")"); + e.className="slot"; + if(p.number){e.innerHTML=o} + e.style="background-image:url("+p.art.url+");background-size:"+((p.art.ratio)? p.size[0]+"px auto":"auto "+p.size[1]+"px")+";background-position:-"+(size[0]*x)+"px -"+(size[1]*y)+"px ;width:"+size[0]+"px;height:"+size[1]+"px;top:"+(size[1]*y)+"px;left:"+(size[0]*x)+"px;position:absolute;"+((p.style)?p.style:"") + if(p.time){e.style.transitionDuration=p.time+"s"} + f.appendChild(e);o++; + }else{m[y][x]=0;freeslot=[y,x];o++;} + } + }stir_slots(); +} +function stir_slots(){ + for(var y=0;y1){ + a=[freeslot[0]+(-1+Math.round(Math.random()*2)),freeslot[1]]; + if(a[0]<0){a[0]=a[0]+2}else if(a[0]>p.grid[1]){a[0]=a[0]-2} + }else{ + a=[freeslot[0],freeslot[1]+(-1+Math.round(Math.random()*2))]; + if(a[1]<0){a[1]=a[1]+2}else if(a[1]>p.grid[0]){a[1]=a[1]-2} + } + var s=[m[freeslot[0]][freeslot[1]],m[a[0]][a[1]]] + m[freeslot[0]][freeslot[1]]=s[1];m[a[0]][a[1]]=s[0] + freeslot=[a[0],a[1]] + } + for(var y=0;y<=p.grid[1];y++){ + for(var x=0;x<=p.grid[0];x++){ + if(m[y][x]){ + var e=document.getElementById("slot"+m[y][x]) + e.style.left=(x*size[0])+"px"; + e.style.top =(y*size[1])+"px"; + } + } + } +} +function move_slot(s) { + var z=0,e,a=[],k,j; + function move(y,x,h,w){ + j=m[y][x] + e=document.getElementById("slot"+j); + e.style.left=((x+w)*size[0])+"px"; + e.style.top =((y+h)*size[1])+"px"; + m[y][x]=k;k=j; + } + for(var y=0;ya[1]){for(z=0;za[0]){for(z=0;z{ alert('win') },((p.time)?p.time*1000:0));} // <-- alert('win') script that runs at the end of the game +} +function fifteen_resize(){ + var rect=f.parentNode.getBoundingClientRect(); + if((p.size[0]/p.size[1])<(rect.width/rect.height)){f.style.transform='scale('+(rect.height/p.size[1])+')'} + else{f.style.transform='scale('+(rect.width/p.size[0])+')'} +} +if(p.keyBoard){document.addEventListener("keydown",function(e){ + e=e.keyCode; + if(e==37){move_slot(m[freeslot[0]][freeslot[1]+1]);} + else if(e==39){move_slot(m[freeslot[0]][freeslot[1]-1]);} + else if(e==38){move_slot(m[freeslot[0]+1][freeslot[1]]);} + else if(e==40){move_slot(m[freeslot[0]-1][freeslot[1]]);} +})} +let gamepad,gamepadPress; +if(p.gamePad){window.addEventListener('gamepadconnected',function(e){ + const update=()=>{ + for (gamepad of navigator.getGamepads()){ + if (!gamepad) continue; + const statenow=gamepad.buttons.some(btn=>btn.pressed); + if (gamepadPress!==statenow){ + gamepadPress=statenow; + if(gamepad.buttons[12].pressed&&m[freeslot[0]+1]){move_slot(m[freeslot[0]+1][freeslot[1]]);} + else if(gamepad.buttons[14].pressed&&m[freeslot[0]]) {move_slot(m[freeslot[0]][freeslot[1]+1]);} + else if(gamepad.buttons[15].pressed&&m[freeslot[0]]) {move_slot(m[freeslot[0]][freeslot[1]-1]);} + else if(gamepad.buttons[13].pressed&&m[freeslot[0]-1]){move_slot(m[freeslot[0]-1][freeslot[1]]);} + } + } + requestAnimationFrame(update); + };update(); + }); +} + diff --git a/Games/Puzzel_winner/icon.jpg b/Games/Puzzel_winner/icon.jpg new file mode 100644 index 0000000000..58d9404bb2 Binary files /dev/null and b/Games/Puzzel_winner/icon.jpg differ diff --git a/Games/Puzzel_winner/index.html b/Games/Puzzel_winner/index.html new file mode 100644 index 0000000000..5bb26d4df1 --- /dev/null +++ b/Games/Puzzel_winner/index.html @@ -0,0 +1,247 @@ + + + +Puzzel Winner + + + + + + + + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Load img file
    Difficulty
    Width
    Height
    Image fill
    Grid width
    Grid height
    Move time
    Numbers
    Puzzle fill
    Style blocks
    Refresh
    Create HTML game
    +
    +
    + + + + diff --git a/README.md b/README.md index e984cf33a4..4592f4172f 100644 --- a/README.md +++ b/README.md @@ -492,6 +492,7 @@ This repository also provides one such platforms where contributers come over an | 380 | [candy_match](https://github.com/kunjgit/GameZone/tree/main/Games/Candy_Match_Saga)| | 381 | [Crossy_Road](https://github.com/tanujbordikar/GameZone/tree/Crossy_Road)| | 382 | [HueHero](https://github.com/kunjgit/GameZone/tree/main/Games/HueHero)| +| 383 | [Puzzel_Winner](https://github.com/kunjgit/GameZone/tree/main/Games/Puzzel_Winner)| diff --git a/assets/images/HangMan.png b/assets/images/HangMan.png index 5390565b8f..1e8d749eaa 100644 Binary files a/assets/images/HangMan.png and b/assets/images/HangMan.png differ diff --git a/assets/images/HangMan.webp b/assets/images/HangMan.webp index f464b54490..b9258445a4 100644 Binary files a/assets/images/HangMan.webp and b/assets/images/HangMan.webp differ diff --git a/assets/images/Puzzel_winner.png b/assets/images/Puzzel_winner.png new file mode 100644 index 0000000000..35346cfa98 Binary files /dev/null and b/assets/images/Puzzel_winner.png differ