Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: self.cells[i][j] is undefined' in or related to this line: 'if (self.cells[i][j].letter !== '') {' Line Number: 192
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: self.cells[i][j] is undefined' in or related to this line: 'if (self.cells[i][j].letter !== '') {' Line Number: 192
User prompt
Please fix the bug: 'TypeError: self.cells[i][j] is undefined' in or related to this line: 'if (self.cells[i][j].letter !== '') {' Line Number: 192
Code edit (6 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: word is not defined' in or related to this line: 'cellLetter.x = game.width / 2 + cellSize * (word.length / 2);' Line Number: 285
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
Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: self.texte.letter is undefined' in or related to this line: 'self.texte.letter.fill = color;' Line Number: 71
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 (16 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: emptyCells is not defined' in or related to this line: 'if (emptyCells.includes(self.cells[i][j])) {' Line Number: 128
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
Initial prompt
Cool Words
===================================================================
--- original.js
+++ change.js
@@ -73,9 +73,8 @@
return;
}
self.isClicked = true;
self.setColorToLetter("#FF0000");
- addCellLetterToWord(self);
};
self.isClicked = false; //Indique si la cellule a été cliquée
});
// LettersGrid class for managing the grid of letters, same as WordGrid but with control of number of columns and lines
@@ -89,11 +88,8 @@
self.emptyCells = []; //Liste des cellules vides
self.initializeGrid = function () {
for (var i = 0; i < self.gridLines; i++) {
self.cells[i] = [];
- if (!self.cells[i]) {
- self.cells[i] = [];
- }
for (var j = 0; j < self.gridColumns; j++) {
var cell = new GridCell('', assetName);
cell.x = j * self.cellSize + self.cellSize / 2;
cell.y = i * self.cellSize + self.cellSize / 2;
@@ -106,35 +102,37 @@
this.onClickCell();
});
cell.clickable = self.clickable;
self.emptyCells.push(cell);
- return cell;
}
}
}; //Fin de la fonction initializeGrid
- self.addCell = function () {
- //Ajoute une cellule à la grille dans le cas ou il n'y a qu'une seule ligne
+ self.addCell = function (letter, assetName) {
+ //Only when there is only one gridLine, add a cell to the grid with the given letter
+ var cell = null;
if (self.gridLines === 1) {
- var cell = new GridCell('', assetName);
- cell.x = self.cells[0].length * self.cellSize + self.cellSize / 2;
+ cell = new GridCell(letter, assetName);
+ cell.x = self.gridColumns * self.cellSize + self.cellSize / 2;
cell.y = self.cellSize / 2;
self.addChild(cell);
- self.cells[0].push(cell);
- cell.column = self.cells[0].length - 1;
+ self.cells[0][self.gridColumns] = cell;
+ cell.column = self.gridColumns;
cell.line = 0;
cell.on('down', function () {
//Fonction appelée lors du click sur la cellule
this.onClickCell();
});
cell.clickable = self.clickable;
self.emptyCells.push(cell);
+ self.gridColumns++;
}
+ return cell;
}; //Fin de la fonction addCell
self.addLetter = function (letter) {
var added = false;
for (var i = 0; i < self.gridLines && !added; i++) {
for (var j = 0; j < self.gridColumns && !added; j++) {
- if (self.cells[i] && self.cells[i][j] && self.cells[i][j].letter === '') {
+ if (self.cells[i][j].letter === '') {
self.cells[i][j].setLetter(letter);
added = true;
//Retrait de la cellule de la liste des cellules vides
if (self.emptyCells.includes(self.cells[i][j])) {
@@ -171,11 +169,8 @@
}
}; //Fin de la fonction removeLetter
self.isFull = function () {
for (var i = 0; i < self.gridLines; i++) {
- if (!self.cells[i]) {
- continue;
- }
for (var j = 0; j < self.gridColumns; j++) {
if (self.cells[i][j].letter === '') {
return false;
}
@@ -184,11 +179,8 @@
return true;
}; //Fin de la fonction isFull
self.isEmpty = function () {
for (var i = 0; i < self.gridLines; i++) {
- if (!self.cells[i]) {
- continue;
- }
for (var j = 0; j < self.gridColumns; j++) {
if (self.cells[i][j].letter !== '') {
return false;
}
@@ -197,11 +189,8 @@
return true;
}; //Fin de la fonction isEmpty
self.colorAllCells = function (color) {
for (var i = 0; i < self.gridLines; i++) {
- if (!self.cells[i]) {
- continue;
- }
for (var j = 0; j < self.gridColumns; j++) {
self.cells[i][j].setColorToLetter(color);
}
}
@@ -249,14 +238,9 @@
var mainGrid = game.addChild(new LettersGrid(6, 6, 'cell'));
mainGrid.initializeGrid();
mainGrid.x = (game.width - mainGrid.gridColumns * mainGrid.cellSize) / 2;
mainGrid.y = ScoreZone.height + 2 * lettersGrid.height;
-var wordGrid = game.addChild(new LettersGrid(1, 1, 'cellWord'));
-wordGrid.initializeGrid();
-wordGrid.x = (game.width - wordGrid.gridColumns * wordGrid.cellSize) / 2;
-wordGrid.y = ScoreZone.height + 3 * lettersGrid.height;
var lettersToAdd = [];
-var finalWord = [];
var currentLetterIndex = 0;
var wordsToBegin = pickAndShakeWords(1); // Pick and shuffle words from the main list
if (wordsToBegin.length > 0) {
// If there are words to begin
@@ -304,8 +288,29 @@
mainGrid.addRandomLetter(lettersToAdd[0]);
lettersToAdd.splice(0, 1);
}
} //Fin de la fonction transfertLettersToMainGrid
+//Fonction addCellLetterToWord : permet d'ajouter une cellule à la liste des lettres formant le mot sous la grille
+function addCellLetterToWord(cell) {
+ var cellSize = 128;
+ var cellLetter = new GridCell(cell.letter, 'cellWord');
+ cellLetter.x = game.width / 2 + cellSize * (word.length / 2);
+ cellLetter.y = ScoreZone.height + 3 * lettersGrid.height + cellSize / 2;
+ cellLetter.policeSize = 70;
+ cellLetter.texte.setStyle({
+ size: cellLetter.policeSize
+ });
+ cellLetter.on('down', function () {
+ //Fonction appelée lors du click sur la cellule
+ if (cellLetter.isClicked) {
+ cellLetter.isClicked = false;
+ cellLetter.setColorToLetter("#ffffff");
+ word.splice(word.indexOf(cellLetter.letter), 1);
+ }
+ });
+ word.push(cellLetter.letter);
+ game.addChild(cellLetter);
+} //Fin de la fonction addCellLetterToWord
game.update = function () {
updateScoreTest(scoreTest);
if (LK.ticks % 60 == 0) {
//Si la liste des lettres à ajouter n'est pas vide, on ajoute toutes les lettres puis on supprime les lettres de la liste
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.