diff --git a/.github/workflows/pr_tags.yaml b/.github/workflows/pr_tags.yaml new file mode 100644 index 0000000000..44f8d599d4 --- /dev/null +++ b/.github/workflows/pr_tags.yaml @@ -0,0 +1,78 @@ +# name: Pull Request Labels + +# on: +# pull_request_target: +# types: +# - opened +# - synchronize + +# jobs: +# pr-validation: +# runs-on: ubuntu-latest + +# steps: +# - name: Checkout repository +# uses: actions/checkout@v2 + +# - name: Set up Node.js +# uses: actions/setup-node@v2 +# with: +# node-version: '14' + +# - name: Install dependencies +# run: npm install --prefix .github octokit + +# - name: Fetch related issue and labels +# id: fetch_issue +# uses: actions/github-script@v4 +# with: +# github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} +# script: | +# const prNumber = context.payload.pull_request.number; +# const repoOwner = context.payload.repository.owner.login; +# const repoName = context.payload.repository.name; + +# const { data: pr } = await github.pulls.get({ +# owner: repoOwner, +# repo: repoName, +# pull_number: prNumber +# }); + +# const issueNumber = pr.body.match(/#([0-9]+)/)[1]; + +# const { data: issue } = await github.issues.get({ +# owner: repoOwner, +# repo: repoName, +# issue_number: issueNumber +# }); + +# return { +# issue: issue, +# prNumber: prNumber, +# repoOwner: repoOwner, +# repoName: repoName +# }; + +# - name: Apply labels to PR +# if: | +# steps.fetch_issue.outputs.issue.labels.some(function(label) { +# return label.name.toLowerCase() === 'gssoc'; +# }) +# run: | +# const issueLabels = steps.fetch_issue.outputs.issue.labels; +# const prNumber = steps.fetch_issue.outputs.prNumber; +# const repoOwner = steps.fetch_issue.outputs.repoOwner; +# const repoName = steps.fetch_issue.outputs.repoName; + +# const prLabels = issueLabels.filter(function(label) { +# return label.name.toLowerCase().startsWith('level'); +# }); +# prLabels.push('gssoc'); +# await github.issues.addLabels({ +# owner: repoOwner, +# repo: repoName, +# issue_number: prNumber, +# labels: prLabels.map(function(label) { +# return label.name; +# }) +# }); \ No newline at end of file diff --git a/Games/Maze_Runner/README.md b/Games/Maze_Runner/README.md new file mode 100644 index 0000000000..d6a292bad3 --- /dev/null +++ b/Games/Maze_Runner/README.md @@ -0,0 +1,43 @@ +# Maze_Runner +
+
+
+ +## **Description 📃** +
+
+This Maze Runner game challenges players to navigate through a randomly generated maze to reach the goal. Players control a character using arrow keys and must avoid maze walls to successfully complete each level. +- + +## **functionalities 🎮** +
+
+Navigate the maze using arrow keys (Up, Down, Left, Right). +Reach the goal represented by a green circle. +Avoid colliding with black walls (generated randomly). +Timer starts upon game start and counts down. +Game over if timer reaches zero. +Restart button available after game over to play again. + +
+ +## **How to play? 🕹ī¸** +
+
+Movement: Use arrow keys to move the player character. +Goal: Reach the green circle to win each level. +Timer: A 60-second timer starts upon game start. +Game Over: Timer ends or player reaches goal. Restart button appears. +Restart: Click Restart to play again from the beginning. +- + +
+ +## **Screenshots 📸** + +
+ + ![image](https://github.com/sanayamahajan-23/GameZone/blob/Maze_runner/Games/Maze_Runner/assets/images/Maze_Runner.png) + +
+ diff --git a/Games/Maze_Runner/assets/images/Maze_Runner.png b/Games/Maze_Runner/assets/images/Maze_Runner.png new file mode 100644 index 0000000000..528bff1f2f Binary files /dev/null and b/Games/Maze_Runner/assets/images/Maze_Runner.png differ diff --git a/Games/Maze_Runner/index.html b/Games/Maze_Runner/index.html new file mode 100644 index 0000000000..f1d8d8f245 --- /dev/null +++ b/Games/Maze_Runner/index.html @@ -0,0 +1,17 @@ + + + + + + Maze Runner Game + + + +
+ +
Time Left: 30s
+
+ + + + diff --git a/Games/Maze_Runner/script.js b/Games/Maze_Runner/script.js new file mode 100644 index 0000000000..b9eb1f51c0 --- /dev/null +++ b/Games/Maze_Runner/script.js @@ -0,0 +1,208 @@ +const canvas = document.getElementById('gameCanvas'); +const ctx = canvas.getContext('2d'); + +const canvasWidth = 800; +const canvasHeight = 600; +canvas.width = canvasWidth; +canvas.height = canvasHeight; + +const cellSize = 40; +let level = 1; +let mazeWidth = Math.floor(canvasWidth / cellSize); +let mazeHeight = Math.floor(canvasHeight / cellSize); + +const player = { + x: 0, + y: 0, + size: cellSize / 2, + color: 'red', + speed: 5 +}; + +const goal = { + x: mazeWidth - 1, + y: mazeHeight - 1, + size: cellSize / 2, + color: 'green' +}; + +let maze = generateMaze(mazeWidth, mazeHeight); +let timeLeft = 60; +let timerInterval; + +function generateMaze(width, height) { + const maze = new Array(height).fill(null).map(() => new Array(width).fill(1)); + + function carvePassagesFrom(cx, cy, maze) { + const directions = shuffle([ + [0, -1], // Up + [1, 0], // Right + [0, 1], // Down + [-1, 0] // Left + ]); + + directions.forEach(([dx, dy]) => { + const nx = cx + dx * 2; + const ny = cy + dy * 2; + + if (nx >= 0 && ny >= 0 && nx < width && ny < height && maze[ny][nx] === 1) { + maze[cy + dy][cx + dx] = 0; + maze[ny][nx] = 0; + carvePassagesFrom(nx, ny, maze); + } + }); + } + + maze[0][0] = 0; + carvePassagesFrom(0, 0, maze); + maze[height - 1][width - 1] = 0; + + return maze; +} + +function shuffle(array) { + for (let i = array.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [array[i], array[j]] = [array[j], array[i]]; + } + return array; +} + +function drawMaze(maze) { + ctx.clearRect(0, 0, canvasWidth, canvasHeight); + for (let y = 0; y < mazeHeight; y++) { + for (let x = 0; x < mazeWidth; x++) { + if (maze[y][x] === 1) { + ctx.fillStyle = 'black'; + ctx.fillRect(x * cellSize, y * cellSize, cellSize, cellSize); + } + } + } +} + +function drawPlayer(player) { + ctx.fillStyle = player.color; + ctx.beginPath(); + ctx.arc( + player.x * cellSize + player.size, + player.y * cellSize + player.size, + player.size, + 0, + Math.PI * 2 + ); + ctx.fill(); +} + +function drawGoal(goal) { + ctx.fillStyle = goal.color; + ctx.beginPath(); + ctx.arc( + goal.x * cellSize + goal.size, + goal.y * cellSize + goal.size, + goal.size, + 0, + Math.PI * 2 + ); + ctx.fill(); +} + +function isCollision(x, y) { + return maze[y][x] === 1; +} + +function movePlayer(dx, dy) { + const newX = player.x + dx; + const newY = player.y + dy; + if (newX >= 0 && newX < mazeWidth && newY >= 0 && newY < mazeHeight && !isCollision(newX, newY)) { + player.x = newX; + player.y = newY; + checkWin(); + } +} + +function checkWin() { + if (player.x === goal.x && player.y === goal.y) { + clearInterval(timerInterval); + // Display win message + ctx.fillStyle = 'black'; + ctx.font = '30px Arial'; + ctx.fillText('You Won!', canvasWidth / 2 - 50, canvasHeight / 2); + + setTimeout(() => { + nextLevel(); + }, 3000); // 3 seconds delay before moving to the next level + } +} + +function nextLevel() { + level++; + mazeWidth = Math.floor(canvasWidth / cellSize) + level; + mazeHeight = Math.floor(canvasHeight / cellSize) + level; + player.x = 0; + player.y = 0; + goal.x = mazeWidth - 1; + goal.y = mazeHeight - 1; + maze = generateMaze(mazeWidth, mazeHeight); + timeLeft = 30; // Reset timer for the new level + startTimer(); + draw(); +} + + + +document.addEventListener('keydown', (event) => { + switch (event.key) { + case 'ArrowUp': + movePlayer(0, -1); + break; + case 'ArrowDown': + movePlayer(0, 1); + break; + case 'ArrowLeft': + movePlayer(-1, 0); + break; + case 'ArrowRight': + movePlayer(1, 0); + break; + } + draw(); +}); + +function draw() { + drawMaze(maze); + drawPlayer(player); + drawGoal(goal); +} + + +function startTimer() { + const timerDisplay = document.getElementById('time'); + clearInterval(timerInterval); + timerInterval = setInterval(() => { + if (timeLeft > 0) { + timeLeft--; + timerDisplay.textContent = timeLeft; + } else { + clearInterval(timerInterval); + alert('Game Over! Time ran out.'); + resetGame(); + } + }, 1000); +} + +function resetGame() { + level = 1; + mazeWidth = Math.floor(canvasWidth / cellSize); + mazeHeight = Math.floor(canvasHeight / cellSize); + player.x = 0; + player.y = 0; + goal.x = mazeWidth - 1; + goal.y = mazeHeight - 1; + maze = generateMaze(mazeWidth, mazeHeight); + timeLeft = 60; + startTimer(); + draw(); +} + +startTimer(); +draw(); diff --git a/Games/Maze_Runner/styles.css b/Games/Maze_Runner/styles.css new file mode 100644 index 0000000000..e35c457f30 --- /dev/null +++ b/Games/Maze_Runner/styles.css @@ -0,0 +1,28 @@ +body, html { + margin: 0; + padding: 0; + overflow: hidden; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + background-color: #f0f0f0; +} + +#gameContainer { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} + +#gameCanvas { + border: 2px solid #000; + background-color: #fff; +} + +#timer { + margin-top: 10px; + font-size: 20px; + font-weight: bold; +} diff --git a/README.md b/README.md index 11884830cf..332f6b58a7 100644 --- a/README.md +++ b/README.md @@ -345,11 +345,11 @@ This repository also provides one such platforms where contributers come over an | [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) | - +| [Maze_Runner] (https://github.com/sanayamahajan-23/GameZone/tree/Maze_runner/Games/Maze_Runner)|
-
+
https://github.com/sanayamahajan-23/GameZone/tree/Maze_runner/Games/Maze_Runner

Page with Curl Contributing Guideline

@@ -785,6 +785,7 @@ This repository also provides one such platforms where contributers come over an | [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)| + |[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)| @@ -854,5 +855,4 @@ Terms and conditions for use, reproduction and distribution are under the [Apach
-

Back to top

diff --git a/assets/images/Maze_Runner.png b/assets/images/Maze_Runner.png new file mode 100644 index 0000000000..528bff1f2f Binary files /dev/null and b/assets/images/Maze_Runner.png differ