-
Notifications
You must be signed in to change notification settings - Fork 839
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4949 from vivekvardhan2810/main
[New game]: Circuit Craze
- Loading branch information
Showing
6 changed files
with
220 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# *Game_Name* | ||
Circuit Craze | ||
|
||
--- | ||
|
||
<br> | ||
|
||
## *Description 📃* | ||
Circuit Craze is a puzzle game where players build and complete electrical circuits to power different machines and gadgets. Each level introduces more complex circuit components. | ||
|
||
## *Functionalities 🎮* | ||
|
||
1. Click the "Start Game" button to begin. | ||
2. Build and complete electrical circuits to power machines and gadgets. | ||
3. Monitor the score, progress, and level. | ||
4. When all circuits are completed, the game advances to the next level with new components. | ||
|
||
1. Controls: Use the mouse to connect circuit components and the keyboard to toggle switches. | ||
2. Scoring: Completing a circuit increases your score by 50 points. | ||
3. Difficulty: Each level introduces more complex components and wiring challenges. | ||
4. Timer: Each level has a 2-minute time limit. | ||
5. Game Over: When the timer runs out or a circuit is not completed correctly, the final score is displayed with an option to play again. | ||
|
||
<br> | ||
|
||
## *Screenshots 📸* | ||
![Screenshot 2024-07-23 231219](https://github.com/user-attachments/assets/32eca0da-2806-4ca6-9fcd-5ec7e893ace4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Circuit Craze</title> | ||
<link rel="stylesheet" href="styles.css"> | ||
</head> | ||
<body> | ||
<div class="overlay"> | ||
<div class="container"> | ||
<h1>Circuit Craze</h1> | ||
<div id="game-board"> | ||
<!-- Game board will be populated dynamically --> | ||
</div> | ||
<div id="controls"> | ||
<button id="reset-btn">Reset</button> | ||
</div> | ||
</div> | ||
</div> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
document.addEventListener('DOMContentLoaded', () => { | ||
const gameBoard = document.getElementById('game-board'); | ||
const boardSize = 5; | ||
let board = []; | ||
|
||
function createBoard() { | ||
gameBoard.innerHTML = ''; // Clear the game board before creating it | ||
board = []; | ||
for (let i = 0; i < boardSize; i++) { | ||
let row = []; | ||
for (let j = 0; j < boardSize; j++) { | ||
let cell = document.createElement('div'); | ||
cell.classList.add('cell'); | ||
cell.dataset.row = i; | ||
cell.dataset.col = j; | ||
cell.addEventListener('click', () => toggleCell(cell)); | ||
gameBoard.appendChild(cell); | ||
row.push(cell); | ||
} | ||
board.push(row); | ||
} | ||
} | ||
|
||
function toggleCell(cell) { | ||
let row = parseInt(cell.dataset.row); | ||
let col = parseInt(cell.dataset.col); | ||
|
||
toggleSingleCell(row, col); | ||
toggleSingleCell(row - 1, col); // Top | ||
toggleSingleCell(row + 1, col); // Bottom | ||
toggleSingleCell(row, col - 1); // Left | ||
toggleSingleCell(row, col + 1); // Right | ||
|
||
checkWin(); | ||
} | ||
|
||
function toggleSingleCell(row, col) { | ||
if (row >= 0 && row < boardSize && col >= 0 && col < boardSize) { | ||
let cell = board[row][col]; | ||
cell.classList.toggle('active'); | ||
} | ||
} | ||
|
||
function checkWin() { | ||
let allActive = true; | ||
for (let i = 0; i < boardSize; i++) { | ||
for (let j = 0; j < boardSize; j++) { | ||
if (!board[i][j].classList.contains('active')) { | ||
allActive = false; | ||
break; | ||
} | ||
} | ||
if (!allActive) break; | ||
} | ||
if (allActive) { | ||
alert('You completed the circuit! You win!'); | ||
} | ||
} | ||
|
||
function resetGame() { | ||
board.forEach(row => row.forEach(cell => cell.classList.remove('active'))); | ||
} | ||
|
||
createBoard(); | ||
document.getElementById('controls').querySelector('button').addEventListener('click', resetGame); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
body { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
background: linear-gradient(135deg, #1e1e1e 0%, #111 100%); | ||
overflow: hidden; | ||
} | ||
|
||
.overlay { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
background: rgba(0, 0, 0, 0.8); | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.container { | ||
text-align: center; | ||
background: rgba(0, 0, 0, 0.9); | ||
padding: 20px; | ||
border-radius: 15px; | ||
box-shadow: 0 0 20px rgba(0, 255, 0, 0.8); | ||
width: 90%; | ||
max-width: 500px; | ||
animation: fadeIn 1.5s ease-in-out; | ||
} | ||
|
||
h1 { | ||
font-size: 2.5em; | ||
color: #0f0; /* Neon green */ | ||
margin-bottom: 20px; | ||
text-shadow: 0 0 10px #0f0; | ||
animation: fadeIn 1.5s ease-in-out; | ||
} | ||
|
||
#game-board { | ||
display: grid; | ||
grid-template-columns: repeat(5, 60px); | ||
grid-template-rows: repeat(5, 60px); | ||
gap: 10px; | ||
margin: 20px auto; | ||
justify-content: center; | ||
animation: fadeIn 1.5s ease-in-out; | ||
} | ||
|
||
.cell { | ||
width: 60px; | ||
height: 60px; | ||
border-radius: 10px; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
cursor: pointer; | ||
background-color: #222; | ||
border: 2px solid #0f0; | ||
transition: background-color 0.3s, transform 0.2s, box-shadow 0.3s; | ||
box-shadow: 0 0 10px rgba(0, 255, 0, 0.6); | ||
} | ||
|
||
.cell:hover { | ||
transform: scale(1.1); | ||
} | ||
|
||
.cell.active { | ||
background-color: #0f0; /* Neon green */ | ||
color: #222; | ||
box-shadow: 0 0 20px rgba(0, 255, 0, 1); | ||
} | ||
|
||
#controls { | ||
margin-top: 20px; | ||
animation: fadeIn 1.5s ease-in-out; | ||
} | ||
|
||
button { | ||
background-color: #0f0; /* Neon green */ | ||
color: #222; | ||
border: none; | ||
padding: 10px 20px; | ||
font-size: 1em; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
transition: background-color 0.3s, transform 0.2s, box-shadow 0.3s; | ||
box-shadow: 0 0 10px rgba(0, 255, 0, 0.8); | ||
} | ||
|
||
button:hover { | ||
background-color: #0d0; | ||
transform: scale(1.1); | ||
box-shadow: 0 0 20px rgba(0, 255, 0, 1); | ||
} | ||
|
||
@keyframes fadeIn { | ||
from { opacity: 0; transform: translateY(-10px); } | ||
to { opacity: 1; transform: translateY(0); } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.