Code edit (9 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: word is undefined' in or related to this line: 'var wordShuffled = wordShuffled = word.split('').sort(function () {' Line Number: 495
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: pickAndShakeSingleWord is not defined' in or related to this line: 'var word = pickAndShakeSingleWord().word;' Line Number: 495
Code edit (6 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: maingrid is not defined' in or related to this line: 'if (maingrid) {' Line Number: 547
Code edit (1 edits merged)
Please save this source code
Code edit (18 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: clueButton is null' in or related to this line: 'clueButton = new Button('', {' Line Number: 433
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'y')' in or related to this line: 'var validateButton = new Button('', {' Line Number: 302
Code edit (8 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'width')' in or related to this line: 'self.width = options.width || 200;' Line Number: 56
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: wordsMainList is undefined' in or related to this line: 'var randomIndex = Math.floor(Math.random() * wordsMainList.length);' Line Number: 382
Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: word is undefined' in or related to this line: 'var wordShuffled = word.split('').sort(function () {' Line Number: 394
User prompt
Please fix the bug: 'TypeError: liste is undefined' in or related to this line: 'var randomIndex = Math.floor(Math.random() * liste.length);' Line Number: 390
Code edit (9 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -77,8 +77,9 @@
self.height = oneCell.cellSize + oneCell.cellSize * (self.gridLines - 1);
self.clickable = true; //Indique si la grille est cliquable
self.cells = [];
self.emptyCells = []; //Liste des cellules vides
+ self.words = []; //Liste des mots actuellement dans la grille
self.initializeGrid = function () {
for (var i = 0; i < self.gridLines; i++) {
self.cells[i] = [];
for (var j = 0; j < self.gridColumns; j++) {
@@ -185,8 +186,18 @@
self.emptyCells.push(self.cells[line][column]);
}
}
}; //Fin de la fonction removeLetter
+ self.addWord = function (word) {
+ // Add a word in the list of words
+ self.words.push(word);
+ }; //Fin de la fonction addWord
+ self.removeWord = function (word) {
+ // Remove a word from the list of words
+ if (self.words.includes(word)) {
+ self.words.splice(self.words.indexOf(word), 1);
+ }
+ }; //Fin de la fonction removeWord
self.isFull = function () {
for (var i = 0; i < self.gridLines; i++) {
for (var j = 0; j < self.gridColumns; j++) {
if (self.cells[i][j].letter === '') {
@@ -324,14 +335,16 @@
mainGrid.x = game.width / 2 - mainGrid.width / 2 + mainGrid.width / (mainGrid.gridColumns + 2);
mainGrid.y = MainZone.height / 6;
var wordGrid = null;
initWordGrid();
-var lettersToAdd = []; //File d'attente des lettres à ajouter dans la lettersGrid
var isGameStarted = false;
var isMGRefillrequired = false; //Indique si le remplissage de la grille principale est nécessaire
var isWordValid = false; //Indique si le mot formé est valide
setMainWordsList(planetesNsatellites);
+var validateButton = null;
setValidateButton('buttonValidate');
+var clueButton = new Button('', {});
+setClueButton('buttonClue');
/****
* Functions
****/
function updateScoreTest(nouveauScore) {
@@ -379,12 +392,12 @@
}
} //Fin de la fonction onClickValidateButton
//Fonction setValidateButton : permet de définir le bouton de validation
function setValidateButton(asset) {
- var validateButton = new Button('', {
+ validateButton = new Button('', {
assetName: asset,
- x: game.width / 2,
- y: wordGrid.y + wordGrid.height + 300,
+ x: game.width / 2 + 50,
+ y: wordGrid.y + wordGrid.height + 350,
width: 300,
height: 300,
fill: "#00FF00",
text: {
@@ -394,8 +407,31 @@
onClick: onClickValidateButton
});
game.addChild(validateButton);
} //Fin de la fonction setValidateButton
+//Fonction onClickClueButton : permet de donner un indice au joueur
+function onClickClueButton() {
+ return; //Pas encore implémenté
+} //Fin de la fonction onClickClueButton
+//Fonction setClueButton : permet de définir le bouton d'indice
+function setClueButton(asset) {
+ clueButton = new Button('', {
+ assetName: asset,
+ x: game.width / 2 - 350,
+ y: 150,
+ // Set a default y position
+ width: 300,
+ height: 300,
+ fill: "#00FF00",
+ text: {
+ size: 50,
+ fill: "#000000"
+ },
+ onClick: onClickClueButton
+ });
+ clueButton.y = clueButton.height / 2; // Adjust y position after initialization
+ game.addChild(clueButton);
+} //Fin de la fonction setClueButton
//Fonction initWordGrid : permet d'initialiser la grille des lettres formant le mot
function initWordGrid() {
//Initialise la grille des lettres formant le mot
wordGrid = game.addChild(new LettersGrid(0, 1, 'cellWord'));
@@ -406,40 +442,35 @@
//Fonction pickAndShakeSingleWord : permet de choisir un mot dans la liste des mots et de le mélanger
function pickAndShakeSingleWord() {
var randomIndex = Math.floor(Math.random() * wordsMainList.length);
var word = wordsMainList[randomIndex];
- //scoreTest = word;
var wordShuffled = wordShuffled = word.split('').sort(function () {
return 0.5 - Math.random();
}).join('');
- return wordShuffled;
+ return {
+ word: word,
+ wordShuffled: wordShuffled
+ };
} //Fin de la fonction pickAndShakeSingleWord
//Fonction pickAndShakeWords : permet de choisir plusieurs mots dans la liste des mots et de les mélanger
function pickAndShakeWords(numberOfWords) {
var wordsShuffeled = [];
for (var i = 0; i < numberOfWords; i++) {
- var shuffledWord = pickAndShakeSingleWord();
+ var shuffledWord = pickAndShakeSingleWord().wordShuffled;
wordsShuffeled.push(shuffledWord);
}
return wordsShuffeled;
} //Fin de la fonction pickAndShakeWords
-//Fonction stackLettersFromWords : permet de stocker les lettres de plusieurs mots dans la file d'attente lettersToAdd
-function stackLettersFromWords(words) {
- for (var i = 0; i < words.length; i++) {
- var word = words[i];
- var letters = word.split('');
- for (var j = 0; j < letters.length; j++) {
- lettersToAdd.push(letters[j]);
- }
- }
-} //Fin de la fonction stackLettersFromWords
//Fonction putRandomShuffledWordInGrid : permet de mettre un mot mélangé dans la grille principale
function putRandomShuffledWordInGrid() {
- var word = pickAndShakeSingleWord();
+ var word = pickAndShakeSingleWord().word;
var isPossibleToAddletter = true; //Indique si le mot peut être ajouté dans la grille principale
for (var i = 0; i < word.length && isPossibleToAddletter; i++) {
isPossibleToAddletter = mainGrid.addRandomLetter(word[i]);
}
+ if (isPossibleToAddletter) {
+ mainGrid.addWord(word);
+ }
return isPossibleToAddletter;
} //Fin de la fonction putRandomShuffledWordInGrid
//Fonction addCellLetterToWord : permet d'ajouter une cellule à la liste des lettres formant le mot situé sous la grille
function addCellLetterToWord(letter) {
@@ -452,16 +483,21 @@
for (var i = 0; i < wordGrid.gridColumns; i++) {
word += wordGrid.cells[0][i].letter;
}
if (liste.includes(word)) {
+ wordGrid.addWord(word); //Archive le mot
+ mainGrid.removeWord(word); //Retire le mot de la grille principale
score += word.length;
isWordValid = true;
} else {
isWordValid = false;
}
wordGrid.colorAllCells(isWordValid ? "#00FF00" : "#FF0000");
return isWordValid;
} //Fin de la fonction validateWord
+/****
+* Main loop
+****/
game.update = function () {
scoreTest = wordGrid.width;
updateScoreTest(scoreTest);
updateScore(score);
@@ -479,8 +515,16 @@
mainGrid.emptyCells.push(mainGrid.cells[i][j]);
}
}
}
+ //Affichage ou pas du bouton de validation
+ if (validateButton) {
+ if (wordGrid.isEmpty()) {
+ validateButton.visible = false;
+ } else {
+ validateButton.visible = true;
+ }
+ }
//Recherche de la lettre cliquée dans la wordGrid et retour de la lettre à la mainGrid
var indexCellToRemove = -1;
for (var j = 0; j < wordGrid.gridColumns; j++) {
if (wordGrid.cells[0][j].isClicked) {
An empty cell.
Drapeau national des USA en fond d'un patchwork des États américains.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Une jeton de scrabble sans lettre.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Un bouton arrondi suggérant une validation mais sans texte écrit dessus.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A round button with a cyan interrogation mark.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A round cyan button with a yellow lamp bulb.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Planetes.
Remove the white square and the red lines.
A patchwork of european countries with the european unio flag in back ground.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A yellow coin wher we can see '+10' written on it.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A red coin wher we can see '-10' written on it... Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Patchwork of heads of plenty animals.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
The periodic table of the elements.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Patchwork de mots sur un fond cyan.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Patchwork of scene extracted from video games.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
It is written "COOL QUIZZ".
A cyan circle button with a home silhouette in the center. The button means "go back to start window". Avoid white color.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.