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
@@ -66,8 +66,11 @@
});
};
self.onClickCell = function () {
//Fonction appelée lors du click sur la cellule
+ if (!self.isClicked) {
+ return;
+ }
self.isClicked = true;
self.setColorToLetter("#FF0000");
};
self.isClicked = false; //Indique si la cellule a été cliquée
@@ -77,8 +80,9 @@
var self = Container.call(this);
self.gridColumns = columns;
self.gridLines = lines;
self.cellSize = 1280 / self.gridColumns;
+ self.clickable = true; //Indique si la grille est cliquable
self.cells = [];
self.emptyCells = []; //Liste des cellules vides
self.initializeGrid = function () {
for (var i = 0; i < self.gridLines; i++) {
@@ -94,8 +98,9 @@
cell.on('down', function () {
//Fonction appelée lors du click sur la cellule
this.onClickCell();
});
+ cell.clickable = !self.clickable;
self.emptyCells.push(cell);
}
}
}; //Fin de la fonction initializeGrid
@@ -169,9 +174,9 @@
/****
* Game Code
****/
-var wordsMainListTest = ["AARDVARK", "ALBATROSS", "ALLIGATOR", "ALPACA", "ANT"];
+var wordsMainListTest = ["AARDVARK", "ALBATROSS", "ALLIGATOR", "ALPACA", "ANT"]; //The real main list is at the end
var scoreTest = 0; // Define scoreTest variable
var ScoreZone = {
x: 0,
y: 0,
@@ -200,61 +205,58 @@
mainGrid.x = (game.width - mainGrid.gridColumns * mainGrid.cellSize) / 2;
mainGrid.y = ScoreZone.height + 2 * lettersGrid.height;
var lettersToAdd = [];
var currentLetterIndex = 0;
-var wordsToBegin = pickAndShakeWords(1);
-stackLettersFromWords(wordsToBegin);
+var wordsToBegin = pickAndShakeWords(1); // Pick and shuffle words from the main list
+if (wordsToBegin.length > 0) {
+ // If there are words to begin
+ stackLettersFromWords(wordsToBegin); // Stack letters from words to add them to the grid
+}
/****
* Functions
****/
function updateScoreTest(nouveauScore) {
scoreTestText.setText(nouveauScore);
} //fin updateScoreTest
//Fonction pickAndShakeSingleWord : permet de choisir un mot dans la liste des mots et de le mélanger
function pickAndShakeSingleWord() {
- var randomIndex = 3; //Math.floor(Math.random() * wordsMainList.length);
- var word = wordsMainList[randomIndex];
- var wordShuffled = "TEST";
- wordShuffled = wordShuffled.split('').sort(function () {
+ var randomIndex = Math.floor(Math.random() * wordsMainListTest.length);
+ var word = wordsMainListTest[randomIndex];
+ var wordShuffled = wordShuffled = word.split('').sort(function () {
return 0.5 - Math.random();
}).join('');
scoreTest = wordShuffled;
return 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 words = [];
+ var wordsShuffeled = [];
for (var i = 0; i < numberOfWords; i++) {
var shuffledWord = pickAndShakeSingleWord();
- //var shuffledWord = "TEST";
- if (shuffledWord.length > 0) {
- //words.push(shuffledWord);
- }
+ wordsShuffeled.push(shuffledWord);
}
- return words;
+ return wordsShuffeled;
} //Fin de la fonction pickAndShakeWords
-//Fonction pickLettersFromWord : permet de choisir des lettres dans un mot
-function pickLettersFromWord(word, numberOfLetters) {
- var letters = [];
- for (var i = 0; i < numberOfLetters; i++) {
- letters.push(word[Math.floor(Math.random() * word.length)]);
- }
- return letters;
-} //Fin de la fonction pickLettersFromWord
-//Fonction stackLettersToAddFromWord : permet de stocker les lettres d'un mot dans la liste lettersToAdd
-function stackLettersToAddFromWord(word) {
- stackLettersToAdd(word.split(''));
-} //Fin de la fonction stackLettersToAddFromWord
//Fonction stackLettersFromWords : permet de stocker les lettres de plusieurs mots dans la liste lettersToAdd
function stackLettersFromWords(words) {
for (var i = 0; i < words.length; i++) {
- stackLettersToAddFromWord(words[i].word);
+ 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
game.update = function () {
updateScoreTest(scoreTest);
if (LK.ticks % 60 == 0) {
- // Add a letter every second
+ //Si la liste des lettres à ajouter n'est pas vide, on ajoute toutes les lettres puis on vide la liste
+ if (lettersToAdd.length > 0) {
+ for (var i = 0; i < lettersToAdd.length; i++) {
+ lettersGrid.addRandomLetter(lettersToAdd[i]);
+ }
+ lettersToAdd = [];
+ }
currentLetterIndex = (currentLetterIndex + 1) % lettersToAdd.length;
if (mainGrid.isFull()) {
mainGrid.colorAllCells("#FF0000");
LK.showGameOver();
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.