Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added timer specific to difficulty level #26 #37

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions check.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
function check(){
for (let i = 0; i < tries-1; i++) {
function check() {
for (let i = 0; i < tries - 1; i++) {
const element = entered_word[i];

for (let x = 0; x < element.length; x++) {
const letter = element[x].toLowerCase();
var wrong_pos_letter=false
var wrong_pos_letter = false
for (let q = 0; q < selected_word.length; q++) {
if(letter==selected_word[q]){
wrong_pos_letter=true;
if (letter == selected_word[q]) {
wrong_pos_letter = true;

}
}
if(letter==selected_word[x]){
fill(0,255,0)
rect(((displayWidth*5)/16)+90*x, (displayHeight/3)-120+130*i, 90,120)
if (letter == selected_word[x]) {
fill(0, 255, 0)
rect(((displayWidth * 5) / 16) + 90 * x, (displayHeight / 3) - 120 + 130 * i, 90, 120)
}
else if(wrong_pos_letter==true){
fill(255,255,0)
rect(((displayWidth*5)/16)+90*x, (displayHeight/3)-120+130*i, 90,120)
else if (wrong_pos_letter == true) {
fill(255, 255, 0)
rect(((displayWidth * 5) / 16) + 90 * x, (displayHeight / 3) - 120 + 130 * i, 90, 120)

}
else{
else {
fill(225)
rect(((displayWidth*5)/16)+90*x, (displayHeight/3)-120+130*i, 90,120)
rect(((displayWidth * 5) / 16) + 90 * x, (displayHeight / 3) - 120 + 130 * i, 90, 120)

}
}
fill(0,0,0)
fill(0, 0, 0)
textSize(160);
textFont("Monospace");
text(element,(displayWidth*5)/16,(displayHeight/3)+130*i)
text(element, (displayWidth * 5) / 16, (displayHeight / 3) + 130 * i)
}
}
setTimeout( function ( ) { alert( "Time is up!!!" ); location.reload();}, 300000 ) //added a timer to reset the gane after 5 mins
317 changes: 170 additions & 147 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,154 +1,177 @@
<html>

<head>
<script
type="text/javascript"
src="https://code.jquery.com/jquery-1.8.2.js"
></script>
<style>
#dif{
display: flex;
justify-content: center;
gap: 5px;
}
.dif_but{
background-color: #dff9fb;
font-size: 24px;
border-radius: 5px;
width: 10vw;
text-align: center;

}
</style>
<style type="text/css">
#overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #000;
filter: alpha(opacity=40);
-moz-opacity: 0.4;
-khtml-opacity: 0.4;
opacity: 0.4;
z-index: 100;
display: none;
}
.blue a {
text-decoration: none;
}
.popup {
width: 100%;
margin: 0 auto;
display: none;
position: fixed;
z-index: 101;
}
.blue {
min-width: 600px;
width: 600px;
min-height: 150px;
margin: 100px auto;
background: #f3f3f3;
position: relative;
z-index: 103;
padding: 15px 35px;
border-radius: 5px;
box-shadow: 0 2px 5px #000;
}
.blue p {
clear: both;
color: #555555;
/* text-align: justify; */
font-size: 20px;
font-family: monospace;
}
.blue p a {
color: #681daa;
font-weight: bold;
}
.blue .x {
float: right;
height: 35px;
left: 22px;
position: relative;
top: -25px;
width: 34px;
}
.blue .x:hover {
cursor: pointer;
}
</style>
<script type="text/javascript">
$(function () {
var overlay = $('<div id="overlay"></div>');
overlay.show();
overlay.appendTo(document.body);
$(".popup").show();
$(".close").click(function () {
$(".popup").hide();
overlay.appendTo(document.body).remove();
return false;
});

$(".x").click(function () {
$(".popup").hide();
overlay.appendTo(document.body).remove();
return false;
});
});
</script>
<div class="popup">
<div class="blue">
<h1>Game Rules!</h1>
<p>
<ul><li>
You get 4 attempts to guess the right word
</li>
<li>
Each guess must be a valid 5 letter word. Press Enter to submit
</li>

<li>
To start playing, just begin typing your first guess
</li></ul>

<br />
<a href="" class="close">Close</a>
</p>
</div>
</div>
<body style="background-color: #7dc734">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.js"></script>
<script src="wordle.js"></script>
<script src="Falling_words.js"></script>
<script src="check.js"></script>
<script>
// When the user clicks on <div>, open the popup
function myFunction() {
var popup = document.getElementById("myPopup");
popup.classList.toggle("show");
}
</script>



<body style="background-color: #7dc734;">
<script type="text/javascript" src="https://code.jquery.com/jquery-1.8.2.js"></script>
<style>
#dif {
display: flex;
justify-content: center;
gap: 5px;
}
</style>
<style type="text/css">
.dif_but {
background-color: #dff9fb;
font-size: 24px;
border-radius: 5px;
width: 10vw;
text-align: center;

}

.dif_but:hover {
background-color: grey;
}

#overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #000;
filter: alpha(opacity=40);
-moz-opacity: 0.4;
-khtml-opacity: 0.4;
opacity: 0.4;
z-index: 100;
display: none;
}

.blue a {
text-decoration: none;
}

.popup {
width: 100%;
margin: 0 auto;
display: none;
position: fixed;
z-index: 101;
}

.blue {
min-width: 600px;
width: 600px;
min-height: 150px;
margin: 100px auto;
background: #f3f3f3;
position: relative;
z-index: 103;
padding: 15px 35px;
border-radius: 5px;
box-shadow: 0 2px 5px #000;
}

.blue p {
clear: both;
color: #555555;
/* text-align: justify; */
font-size: 20px;
font-family: monospace;
}

.blue p a {
color: #681daa;
font-weight: bold;
}

.blue .x {
float: right;
height: 35px;
left: 22px;
position: relative;
top: -25px;
width: 34px;
}

.blue .x:hover {
cursor: pointer;
}

.timercount {
height: 30px;
font-size: 30px;
font-family: monospace;
text-align: center;
padding: 20px;
}
</style>
<script type="text/javascript">
$(function () {
var overlay = $('<div id="overlay"></div>');
overlay.show();
overlay.appendTo(document.body);
$(".popup").show();
$(".close").click(function () {
$(".popup").hide();
overlay.appendTo(document.body).remove();
return false;
});

$(".x").click(function () {
$(".popup").hide();
overlay.appendTo(document.body).remove();
return false;
});
});
</script>
<div class="popup">
<div class="blue">
<h1>Game Rules!</h1>
<p>
<ul>
<li>
You get 4 attempts to guess the right word
</li>
<li>
Each guess must be a valid 5 letter word. Press Enter to submit
</li>

<li>
To start playing, just begin typing your first guess
</li>
</ul>

<br />
<a href="" class="close">Close</a>
</p>
</div>
</div>

<body style="background-color: #7dc734">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.js"></script>
<script src="wordle.js"></script>
<script src="Falling_words.js"></script>
<script src="check.js"></script>
<script>
// When the user clicks on <div>, open the popup
function myFunction() {
var popup = document.getElementById("myPopup");
popup.classList.toggle("show");
}
</script>



<body style="background-color: #7dc734;">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.js"></script>
<script src="wordle.js"></script>
<script src="Falling_words.js"></script>
<script src="check.js"></script>
<div style="width:100vw;">
<div style="display: flex;justify-content: center;">
<h1 style="font-family: monospace;font-size: 64px;">Wordle Clone</h1>
</div>
<div id="dif">
<div id="dif_title"></div>
<div id="0" class="dif_but" onclick="difficultyHandle(event)">Easy</div>
<div id="1" class="dif_but" onclick="difficultyHandle(event)">Medium</div>
<div id="2" class="dif_but" onclick="difficultyHandle(event)">Hard</div>
</div>
<div id="wordle_canvas" style="display: flex;justify-content: center;"></div>

</body>
<div style="width:100vw;">
<div style="display: flex;justify-content: center;">
<h1 style="font-family: monospace;font-size: 64px;">Wordle Clone</h1>
</div>
<div id="dif">
<div id="dif_title"></div>
<button id="3" class="dif_but" onClick="difficultyHandle(event, 3)">Easy</button>
<button id="2" class="dif_but" onClick="difficultyHandle(event, 2)">Medium</button>
<button id="1" class="dif_but" onClick="difficultyHandle(event, 1)">Hard</button>
</div>
<div class="timercount">Time left = <span id="timer"></span></div>
<div id="wordle_canvas" style="display: flex;justify-content: center;"></div>

</body>

</html>
265 changes: 141 additions & 124 deletions wordle.js

Large diffs are not rendered by default.