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

ADD: Animation on timer #45

Merged
merged 2 commits into from
Jan 15, 2024
Merged
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: 37 additions & 2 deletions Dark/game.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
font-weight: 900;
}

.alert {
animation: bounceTimer 1.2s infinite ease-in-out;
}

.hud-prefix {
text-align: center;
font-size: 2rem;
Expand Down Expand Up @@ -92,14 +96,37 @@
animation: spin 2s linear infinite;
}


@keyframes bounceTimer {

0%,
100% {
transform: scale(1);
}

25% {
transform: scale(1.5);
}

50% {
transform: scale(1);
}

75% {
transform: scale(1.5);
}
}

@keyframes spin {
0% {
transform: rotate(0deg);
}

100% {
transform: rotate(360deg);
}
}

#question {
margin-bottom: 0px;
position: relative;
Expand All @@ -110,46 +137,53 @@
.container {
padding: 20px;
}

#hud {
position: relative;
bottom: 6em;
}

#question {
position: relative;
bottom: 1em;
}

.choice-container {
position: relative;
top: 1em;
}
}

@media screen and (max-width: 1024px) {
.container {
padding: 40px;
}

#hud {
position: relative;
bottom: 6em;
}

#question {
position: relative;
bottom: 1em;
}

.choice-container {
position: relative;
top: 0.5em;
}
}

footer{
footer {
position: relative;
display: flex;
width: 100%;
justify-content: center;
align-items: center;
}

.next_btn{
.next_btn {
background-color: #56a5eb;
height: 4rem;
border: none;
Expand All @@ -158,6 +192,7 @@ footer{
position: relative;
color: white;
}

.next_btn:hover {
cursor: pointer;
box-shadow: 0 0.4rem 1.4rem 0 rgba(86, 185, 235, 0.5);
Expand Down
2 changes: 1 addition & 1 deletion Dark/game.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<div id="hud-item" class="time">
<div class="timer">
<div class="time_left_txt">Time Left</div>
<div class="timer_sec">15</div>
<div class="timer_sec" id="timer">15</div>
</div>
<div class="time_line"></div>
</div>
Expand Down
7 changes: 7 additions & 0 deletions Dark/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ function startTimer(time) {
choices.children[i].classList.add("disabled");
}
}
if(time <5)
{
document.getElementById("timer").classList.add("alert");
}
else{
document.getElementById("timer").classList.remove("alert");
}
}
}

Expand Down
28 changes: 26 additions & 2 deletions Light/game.css
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,30 @@
animation: spin 2s linear infinite;
}

.alert {
animation: bounceTimer 1.2s infinite ease-in-out;
}

@keyframes bounceTimer {

0%,
100% {
transform: scale(1);
}

25% {
transform: scale(1.5);
}

50% {
transform: scale(1);
}

75% {
transform: scale(1.5);
}
}

@keyframes spin {
0% {
transform: rotate(0deg);
Expand Down Expand Up @@ -151,15 +175,15 @@
}
}

footer{
footer {
position: relative;
display: flex;
width: 100%;
justify-content: center;
align-items: center;
}

.next_btn{
.next_btn {
background-color: #56a5eb;
height: 4rem;
border: none;
Expand Down
2 changes: 1 addition & 1 deletion Light/game.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<div id="hud-item" class="time">
<div class="timer">
<div class="time_left_txt">Time Left</div>
<div class="timer_sec">15</div>
<div class="timer_sec" id="timer">15</div>
</div>
<div class="time_line"></div>
</div>
Expand Down
7 changes: 7 additions & 0 deletions Light/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ function startTimer(time) {
choices.children[i].classList.add("disabled");
}
}
if(time <5)
{
document.getElementById("timer").classList.add("alert");
}
else{
document.getElementById("timer").classList.remove("alert");
}
}
}

Expand Down