Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: imageBackGround is not defined' in or related to this line: 'var backGround = imageBackGround;' Line Number: 484
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: this.children[e].setStageReference is not a function' in or related to this line: 'game.update = function () {' Line Number: 1100
Code edit (8 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: object.addChild is not a function' in or related to this line: 'object.addChild(nameGrid);' Line Number: 620
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: object.addChild is not a function' in or related to this line: 'object.addChild(nameGrid);' Line Number: 618
Code edit (8 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: t is undefined' in or related to this line: 'backGroundImage = LK.getAsset(image, {' Line Number: 539
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 (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in or related to this line: 'var nbWords = mainListsList[i].length;' Line Number: 468
Code edit (19 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in or related to this line: 'var nbWords = mainListsList[i].length;' Line Number: 468
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (6 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'resetGrid')' in or related to this line: 'mainGrid.resetGrid();' Line Number: 592
Code edit (12 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: setHelpButtons is not defined' in or related to this line: 'setHelpButtons('ButtonHelp');' Line Number: 471
Code edit (1 edits merged)
Please save this source code
Code edit (8 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -283,9 +283,8 @@
/****
* Game Code
****/
-// Button class for creating buttons in the game
/****
* GAME DESCRIPTION:
* Game Principle:
* NAME: QUIZ COOL by Dalhem 2024
@@ -315,8 +314,9 @@
* If the word is not valid, the letters forming the word are returned to their original position in the grid.
* A new word appears randomly within the grid to empty spaces.
* If there is no more space in the grid, the game is over.
****/
+// Button class for creating buttons in the game
var namesList = ["PLANETES AND SATELLITES", "USA STATES", "EUROPEAN CAPITALES", "ANIMALS", "PERIODIC TABLE OF THE ELEMENTS", "VIDEO GAMES"]; //Liste des thèmes de jeu
var backGroundsList = ["BackGroundPlanetesNSatellites", "BackGroundUSAStates", "BackGroundEuropeanCapitales", "BackGroundAnimals", "BackGroundPeriodic", "BackGroundGames"]; //Liste des assets de fond
var usaStates = ["ALABAMA", "ALASKA", "ARIZONA", "ARKANSAS", "CALIFORNIA", "COLORADO", "CONNECTICUT", "DELAWARE", "FLORIDA", "GEORGIA", "HAWAII", "IDAHO", "ILLINOIS", "INDIANA", "IOWA", "KANSAS", "KENTUCKY", "LOUISIANA", "MAINE", "MARYLAND", "MASSACHUSETTS", "MICHIGAN", "MINNESOTA", "MISSISSIPPI", "MISSOURI", "MONTANA", "NEBRASKA", "NEVADA", "NEW-HAMPSHIRE", "NEW-JERSEY", "NEW-MEXICO", "NEW-YORK", "NORTH-CAROLINA", "NORTH-DAKOTA", "OHIO", "OKLAHOMA", "OREGON", "PENNSYLVANIA", "RHODE-ISLAND", "SOUTH-CAROLINA", "SOUTH-DAKOTA", "TENNESSEE", "TEXAS", "UTAH", "VERMONT", "VIRGINIA", "WASHINGTON", "WEST-VIRGINIA", "WISCONSIN", "WYOMING"];
//var europeanCapitales = ["AMSTERDAM", "ANDORRA-LA-VELLA", "ANKARA", "ATHENS", "BELGRADE", "BERLIN", "BERN", "BRATISLAVA", "BRUSSELS", "BUCHAREST", "BUDAPEST", "CHISINAU", "COPENHAGEN", "DUBLIN", "HELSINKI", "KIEV", "LISBON", "LJUBLJANA", "LONDON", "LUXEMBOURG", "MADRID", "MINSK", "MONACO", "MOSCOW", "NICOSIA", "OSLO", "PARIS", "PODGORICA", "PRAGUE", "REYKJAVIK", "RIGA", "ROME", "SAN-MARINO", "SARAJEVO", "SKOPJE", "SOFIA", "STOCKHOLM", "TALLINN", "TBILISI", "TIRANA", "VADUZ", "VALLETTA", "VIENNA", "VILNIUS", "WARSAW", "ZAGREB"];
@@ -398,8 +398,9 @@
var wordGridWords = []; //Liste des mots deja formés
var isGameStarted = false; //Indique si le jeu a commencé dans un thème
var isThemaSelected = false; //Indique si un thème a été sélectionné
var isHelpOn = false; //Indique si l'aide est activée
+var helpTextGrids = []; //Liste des grilles d'aide
var isMGRefillrequired = false; //Indique si le remplissage de la grille principale est nécessaire
var isWordValid = false; //Indique si le mot formé est valide
var isWordInMainList = false; //Indique si le mot formé est dans la liste principale
var isWordAlreadyFound = false; //Indique si le mot formé a déjà été trouvé
@@ -421,9 +422,10 @@
var nbBoutons = backGroundsList.length;
for (var i = 0; i < backGroundsList.length; i++) {
var name = namesList[i];
miniBackGrounds[i] = new Button('', {
- assetName: backGroundsList[i],
+ //assetName: backGroundsList[i],
+ assetName: 'BackGroundNoImage',
mainList: mainListsList[i],
x: game.width / 2,
y: ScoreZone.height + this.height / 2 + i * (MainZone.height - this.height / 2) / nbBoutons,
width: game.width,
@@ -436,14 +438,15 @@
onClick: onClickMiniBackGround
});
var oneCell = new GridCell('', 'cell'); // Define oneCell variable
var nbWords = mainListsList[i].length;
- var nameGrid = makeNameGrid(name + "(" + nbWords + ")", 'cellWord');
- nameGrid.y = miniBackGrounds[i].height / 2 - 2.5 * nameGrid.height;
- nameGrid.width = miniBackGrounds[i].width - 2 * oneCell.width;
- nameGrid.height = 2 * miniBackGrounds[i].height;
- nameGrid.x = -nameGrid.width / 2 + oneCell.width / 2;
- miniBackGrounds[i].addChild(nameGrid);
+ displayText(name + "(" + nbWords + ")", 'cellWord', nbWords * oneCell.width + oneCell.width / 2, miniBackGrounds[i].height / 2 + 2.5 * oneCell.height);
+ //var nameGrid = makeNameGrid(name + "(" + nbWords + ")", 'cellWord');
+ //nameGrid.y = miniBackGrounds[i].height / 2 - 2.5 * nameGrid.height;
+ //nameGrid.width = miniBackGrounds[i].width - 2 * oneCell.width;
+ //nameGrid.height = 2 * miniBackGrounds[i].height;
+ //nameGrid.x = -nameGrid.width / 2 + oneCell.width / 2;
+ //miniBackGrounds[i].addChild(nameGrid);
game.addChild(miniBackGrounds[i]);
setHelpButton('ButtonHelp');
}
} //Fin de la fonction displayminiBackGrounds
@@ -462,17 +465,8 @@
}
LK.gui.top.addChild(scoreText);
}
} //Fin de la fonction onClickMiniBackGround
-//La largeur de la grille ne doit pas dépasser la largeur de la zone de jeu, la taille des cellules doit être adaptée
-function makeNameGrid(word, assetName) {
- var grid = new LettersGrid(word.length, 1, assetName);
- grid.initializeGrid();
- for (var i = 0; i < word.length; i++) {
- grid.setLetter(i, 0, word[i]);
- }
- return grid;
-} //Fin de la fonction makeNameGrid
//Fonction initGameThema : permet d'initialiser le thème du jeu (liste des mots et image de fond)
function initGameThema(mainList, backGround) {
isGameStarted = false;
isMGRefillrequired = false;
@@ -539,16 +533,39 @@
//On cache les miniatures des fonds
for (var i = 0; i < miniBackGrounds.length; i++) {
game.removeChild(miniBackGrounds[i]);
}
- setBackGroundImage('BackGroundHelp', MainZone.x, MainZone.y, MainZone.width, MainZone.height);
- displayText("-COOL QUIZZ-\nChoose a thema\nGuess the names\n\nBUTTONS:\nHelp: displays this\nHome: changes thema (keep score)\n\nCLUE BUTTONS (not free):\n-hightlights the first letter\n-hightlights a name\n-gives the letters\n\nHave fun !!", 'cellWord', MainZone.y + MainZone.height / 4);
+ //Si l'aide est déjà affichée, on la cache
+ if (isHelpOn) {
+ for (var i = 0; i < helpTextGrids.length; i++) {
+ game.removeChild(helpTextGrids[i]);
+ }
+ helpTextGrids = [];
+ isHelpOn = false;
+ if (!isGameStarted) {
+ //Si le jeu n'a pas commencé, on affiche les miniatures des fonds
+ displayminiBackGrounds();
+ }
+ return;
+ }
+ //setBackGroundImage('BackGroundHelp', MainZone.x, MainZone.y, MainZone.width, MainZone.height);
+ helpTextGrids = displayText(game, "-COOL QUIZZ-\nChoose a thema\nGuess the names\n\nBUTTONS:\nHelp: displays this\nHome: changes thema (keep score)\n\nCLUE BUTTONS (not free):\n-hightlights the first letter\n-hightlights a name\n-gives the letters\n\nHave fun !!", 'cellWord', 200, MainZone.y + MainZone.height / 4);
game.removeChild(helpButton);
+ isHelpOn = true;
setHomeButton('ButtonHome');
} //Fin de la fonction onClickHelpButton
+//Fonction makeNameGrid : permet de créer une grille de lettres pour afficher un mot
+function makeNameGrid(word, assetName) {
+ var grid = new LettersGrid(word.length, 1, assetName);
+ grid.initializeGrid();
+ for (var i = 0; i < word.length; i++) {
+ grid.setLetter(i, 0, word[i]);
+ }
+ return grid;
+} //Fin de la fonction makeNameGrid
//Fonction displayText : permet d'afficher un texte en utilisant des NameGrid
//Le texte est affiché dans la zone de jeu et une nouvelle NameGrid est créée pour chaque ligne
-function displayText(text, assetName, y) {
+function displayText(object, text, assetName, x, y) {
var textsGrid = []; //Liste des NameGrids affichant le texte
var nameGridRef = new LettersGrid(1, 1, assetName);
var cellWidth = nameGridRef.oneCell.width;
var cellHeight = nameGridRef.oneCell.height;
@@ -563,13 +580,17 @@
}
for (var j = 0; j < partialLines.length; j++) {
var nameGrid = null;
nameGrid = makeNameGrid(partialLines[j], assetName);
- nameGrid.x = cellWidth;
+ nameGrid.x = x;
nameGrid.y = y + i / 4 * cellHeight * 2 + j / 2 * cellHeight;
nameGrid.width /= 2;
nameGrid.height /= 2;
- game.addChild(nameGrid);
+ if (object instanceof Container) {
+ object.addChild(nameGrid);
+ } else {
+ console.error("The provided object is not a valid Container instance.");
+ }
textsGrid.push(nameGrid);
}
}
return textsGrid;
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.