-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Related Issue Adding New Project: Simon-Says-Game #382 Issue No: #382 ## Description Adding a new project Simon Says Game ## Type of PR - [ ] Feature enhancement ## Screenshots / Videos (if applicable) ![Screenshot 2025-01-08 151520](https://github.com/user-attachments/assets/e86eb43d-66e0-46f2-912e-7946557d46c7) https://github.com/user-attachments/assets/f4e667a2-affe-4569-8411-2938d0fce9e7 ## Checklist - [. ] I have performed a self-review of my code. - [ .] I have read and followed the Contribution Guidelines. - [ .] I have tested the changes thoroughly before submitting this pull request. - [ .] I have provided relevant issue numbers, screenshots, and videos after making the changes. - [ .] I have commented my code, particularly in hard-to-understand areas. - [ .] I have followed the code style guidelines of this project. - [ .] I have checked for any existing open issues that my pull request may address. - [ .] I have ensured that my changes do not break any existing functionality. - [ ] Each contributor is allowed to create a maximum of 4 issues per day. This helps us manage and address issues efficiently. - [ .] I have read the resources for guidance listed below. - [ .] I have followed security best practices in my code changes. ## Contribution Guidelines Thank you for considering contributing to our project! To ensure smooth collaboration and effective contribution management, please adhere to the following guidelines: ### Issue Creation 1. **Limit on Issues:** - Each contributor is allowed to create a maximum of **4 issues per day**. This helps us manage and address issues efficiently. ### Contribution Levels 2. **Basic Contributions:** - This project is primarily focused on documentation. Most of the setup has been completed, so contributors will generally need to work on basic code tasks, such as writing tests. - For these tasks, issues will be assigned the **Easy** label. 3. **Acknowledging Hard Work:** - If a contributor puts in significant effort on a task, the issue will be upgraded to **Medium**. This is our way of recognizing and appreciating extra effort. 4. **Feature Additions and Component Work:** - Contributors working on new features or components using JSX/TSX will be assigned a level based on the complexity and quality of their work. - The more complex and valuable the contribution, the higher the level assigned. ### Level Definitions - **Easy:** - Tasks are straightforward, such as fixing minor bugs, writing tests, or making simple documentation updates. - **Medium:** - Tasks require more effort, such as addressing complex bugs, improving existing features, or making substantial documentation improvements. - **Hard:** - Tasks are highly complex and involve significant new feature development, major refactoring, or extensive contributions to the project’s core components. We look forward to your contributions and appreciate your effort in helping us improve the project!
- Loading branch information
Showing
4 changed files
with
150 additions
and
2 deletions.
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
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,26 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Simon Says Game</title> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
<body> | ||
<h1>Simon Says Game</h1> | ||
<h2>Press any key to start the game</h2> | ||
|
||
<div class="btn-container"> | ||
<div class="line-one"> | ||
<div class="btn red" type="button" id="red"></div> | ||
<div class="btn yellow" type="button" id="yellow"></div> | ||
</div> | ||
<div class="line-two"> | ||
<div class="btn green" type="button" id="green"></div> | ||
<div class="btn purple" type="button" id="purple"></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,82 @@ | ||
let gameSeq = []; | ||
let userSeq = []; | ||
|
||
let btns = ["yellow", "red", "purple", "green"]; | ||
|
||
let started = false; | ||
let level = 0; | ||
|
||
let h2 = document.querySelector("h2"); | ||
|
||
document.addEventListener("keypress", function (){ | ||
if(started == false){ | ||
console.log("Game is started"); | ||
started = true; | ||
|
||
levelUp(); | ||
} | ||
}); | ||
|
||
function gameFlash(btn){ | ||
btn.classList.add("flash"); | ||
setTimeout(function (){ | ||
btn.classList.remove("flash"); | ||
}, 250); | ||
} | ||
|
||
function userFlash(btn){ | ||
btn.classList.add("userflash"); | ||
setTimeout(function (){ | ||
btn.classList.remove("userflash"); | ||
}, 250); | ||
} | ||
|
||
function levelUp(){ | ||
userSeq = []; | ||
level++; | ||
h2.innerText = `Level ${level}`; | ||
|
||
let randIdx = Math.floor(Math.random() * 3); | ||
let randColor = btns[randIdx]; | ||
let randBtn = document.querySelector(`.${randColor}`); | ||
gameSeq.push(randColor); | ||
console.log(gameSeq); | ||
gameFlash(randBtn); | ||
} | ||
|
||
function checkAns(idx){ | ||
if(userSeq[idx] === gameSeq[idx]){ | ||
if(userSeq.length == gameSeq.length){ | ||
setTimeout(levelUp, 1000); | ||
} | ||
}else{ | ||
h2.innerHTML = `Game Over! Your score was <b>${level}</b> <br> Press any key to start.`; | ||
document.querySelector("body").style.backgroundColor = "red"; | ||
setTimeout(function(){ | ||
document.querySelector("body").style.backgroundColor = "white"; | ||
}, 120); | ||
reset(); | ||
} | ||
} | ||
|
||
function btnPress(){ | ||
let btn = this; | ||
userFlash(btn); | ||
|
||
userColor = btn.getAttribute("id"); | ||
userSeq.push(userColor); | ||
|
||
checkAns(userSeq.length-1); | ||
} | ||
|
||
let allBtns = document.querySelectorAll(".btn"); | ||
for(btn of allBtns){ | ||
btn.addEventListener("click", btnPress); | ||
} | ||
|
||
function reset(){ | ||
started = false; | ||
gameSeq = []; | ||
userSeq = []; | ||
level = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
body{ | ||
text-align: center; | ||
} | ||
|
||
.btn{ | ||
height: 200px; | ||
width: 200px; | ||
border-radius: 20%; | ||
border: 10px solid black; | ||
margin: 2.5rem; | ||
} | ||
|
||
.btn-container{ | ||
display:flex; | ||
justify-content: center; | ||
} | ||
|
||
.yellow{ | ||
background-color: #f99b45; | ||
} | ||
|
||
.red{ | ||
background-color: #d95980; | ||
} | ||
|
||
.purple{ | ||
background-color: #819ff9; | ||
} | ||
|
||
.green{ | ||
background-color: #63aac0; | ||
} | ||
|
||
.flash{ | ||
background-color: white; | ||
} | ||
|
||
.userflash{ | ||
background-color: green; | ||
} |