Skip to content

Commit

Permalink
0.0.4
Browse files Browse the repository at this point in the history
displayLetter(letter)
  • Loading branch information
difabiolorenzo committed Dec 27, 2023
1 parent 094190d commit 49130b2
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 15 deletions.
54 changes: 46 additions & 8 deletions src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function replaceAt(string, index, replace, length) {

function initGame() {
getRandomDefinition();

createGrid(10, 10);
}

function createGrid(li, col) {
Expand All @@ -28,6 +28,40 @@ function createGrid(li, col) {
fillGrid();
}

function displayLetter(letter) {
var word_data = game.grille_en_cours;
var cell_to_display = []

for (var i=0; i<word_data.length; i++) {
for (var j=0; j<word_data[i].mot.length; j++) {
checkLetter(letter)
}
}

function checkLetter(letter) {
if (word_data[i].mot[j] != letter) {
return;
}

console.log(word_data[i].mot[j], word_data[i].orientation, word_data[i].x, word_data[i].y, word_data[i].visibilite[j])


if (word_data[i].orientation == "v") {
var cell_id = `cell_${(word_data[i].y) + 1 + j}_${(word_data[i].x) + 1}`
} else {
var cell_id = `cell_${(word_data[i].y) + 1}_${(word_data[i].x) + 1 + j}`
}

var cell_html = document.getElementById(cell_id);
cell_to_display.push(cell_id)


cell_html.className = "open_cell"
cell_html.innerHTML = "<a class=\"grid_letter\">" + word_data[i].mot[j] + "</a>"

}
}

function fillGrid() {
var selected_grid_id = 0;
game.grille_en_cours = [];
Expand All @@ -40,8 +74,8 @@ function fillGrid() {
var y = word_data.y;
var orientation = word_data.orientation;
var id = word_data.id;
game.grille_en_cours[i].visibilite = ""


if (orientation == "h") {
var number_cell = document.getElementById(`cell_${y+1}_${x}`);
number_cell.innerHTML = id;
Expand All @@ -52,19 +86,18 @@ function fillGrid() {
number_cell.className = "number_cell";
}

console.log(word, word.length)
for (var j=0; j<word.length; j++) {
if (orientation == "h") {
var cell = document.getElementById(`cell_${y+1}_${x+1+j}`);
} else {
var cell = document.getElementById(`cell_${y+1+j}_${x+1}`);
}

// cell.className = "hided_cell"
// cell.innerHTML = ""
cell.className = "hided_cell"
cell.innerHTML = ""

cell.className = "open_cell"
cell.innerHTML = "<a class=\"grid_letter\">" + word[j] + "</a>"
// cell.className = "open_cell"
// cell.innerHTML = "<a class=\"grid_letter\">" + word[j] + "</a>"

// AFFICHAGE HASARD LETTRE: A CHANGER
// if (Math.random() + .5 >> 0) {
Expand All @@ -74,7 +107,12 @@ function fillGrid() {
// cell.className = "open_cell";
// cell.innerHTML = "<a class=\"grid_letter\">" + word[j] + "</a>";
// }
}

//AJOUT ATTRIBUT VISIBILITE LETTRE
game.grille_en_cours[i].visibilite += "0";
}

console.log(word, game.grille_en_cours[i].visibilite, x, y, orientation)
}
}

Expand Down
10 changes: 3 additions & 7 deletions src/style/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,21 @@ body {

#definition_question {
padding: 3vh 1vw;
z-index: 2;
}

#definition_reponse {
display: flex;
background-color: var(--accent_1);
border-radius: 0 0 1vh 1vh;
border-radius: 1vh 1vh;
justify-content: center;
width: min-content;
padding: 1vh;
margin-top: -1vh;
margin-top: 1vh;
color: white;
font-size: x-large;
align-items: center;
animation: .5s displayDefinitionAnswer;
z-index: 1;
z-index: -1;
}
div#definition_reponse.hided, #definition.hided div#definition_reponse {
transform: translateY(-10vh);
Expand Down Expand Up @@ -131,12 +130,10 @@ div#actions {

#definition.hided #definition_question {
animation: .5s hideDefinition;
z-index: 2;
}

#definition.hided #definition_placeholder {
animation: .75s hideDefinition;
/* z-index: 0; */
}

@keyframes hideDefinition {
Expand All @@ -161,7 +158,6 @@ div#actions {

#definition.displayed #definition_question {
animation: .5s displayDefinition;
z-index: 2;
}

#definition.displayed #definition_placeholder {
Expand Down

0 comments on commit 49130b2

Please sign in to comment.