This commit is contained in:
2020-03-09 10:06:48 +01:00
parent a190ac0ea5
commit e80ead9234
2 changed files with 52 additions and 21 deletions

View File

@@ -2,15 +2,16 @@
var viewspeed = 500; // time the player can see the answers MS var viewspeed = 500; // time the player can see the answers MS
var timeout = 1000; // Time after all cards showed var timeout = 1000; // Time after all cards showed
var health = 5; var health = 5;
var level = 9; var level = 9*4;
var difficulty = 3; var difficulty = -1;
var showcontent = false; // show numbers inside the cards var showcontent = true; // show numbers inside the cards
// Game settings end // Game settings end
var play_array = []; var play_array = [];
var anim = 0; var anim = 0;
var y = 1; var y = 1;
var correct_answers = 0; var correct_answers = 0;
var avoid_repeat = []; // When a card is clicked, the player cant click on same card more than once
function initiate(){ // Call all the functions function initiate(){ // Call all the functions
@@ -104,8 +105,13 @@ function reply_click(clicked_id){ // Grabs the value from the id on the div/card
alert("You survived this round!"); alert("You survived this round!");
} }
}else{ }else{
//Avoid repeat fix
if (!avoid_repeat.includes(clicked_id)){
document.getElementById(clicked_id).style.border = "3px solid red"; // Makes the div/cards border red document.getElementById(clicked_id).style.border = "3px solid red"; // Makes the div/cards border red
document.getElementById(clicked_id).style.backgroundColor = "red"; document.getElementById(clicked_id).style.backgroundColor = "red";
avoid_repeat.push(clicked_id);
health--; health--;
console.log("Liv: " + health); console.log("Liv: " + health);
if(health == 0) if(health == 0)
@@ -113,6 +119,8 @@ function reply_click(clicked_id){ // Grabs the value from the id on the div/card
alert("Game over!"); alert("Game over!");
} }
} }
}
document.getElementById("alerted").innerHTML = clicked_id; // Just prints it out on the screen for testing document.getElementById("alerted").innerHTML = clicked_id; // Just prints it out on the screen for testing
} }
/* /*

View File

@@ -1,17 +1,34 @@
body { body {
background-color: #1d1e22; background-color: #1d1e22;
} }
/*
#wrapper { #wrapper {
/* max-width: 1200px; */
max-width: 741px; max-width: 741px;
margin: 30px auto; margin: 30px auto;
padding: 0 20px; padding: 0 20px;
width: 100%; width: 100%;
display: grid; display: grid;
grid-auto-rows: 100px; grid-auto-rows: 1fr;
grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
grid-gap: 1em; grid-gap: 1em;
} */
#wrapper {
max-width: 1200px;
max-width: 54%;
max-height: 50%;
margin: 30px auto;
padding: 0 20px;
width: 100%;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
/* grid-auto-rows: 1fr; */
/* grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); */
/* grid-gap: 1em; */
} }
.flexwrap{ .flexwrap{
display: flex; display: flex;
@@ -22,8 +39,14 @@
border-radius: 10px; border-radius: 10px;
padding: 20px; padding: 20px;
color: rgb(255, 255, 255); color: rgb(255, 255, 255);
background-color:rgb(0, 94, 165); background-color: rgb(0, 94, 165);
transition: 0.5s; transition: 0.5s;
height: 30vh;
width: 30vh;
min-width: 60px;
max-width: 100px;
max-height: 100px;
margin: 5px;
} }
.animations{ .animations{
border: 1px solid pink; border: 1px solid pink;