Code edit (1 edits merged)
Please save this source code
Code edit (7 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: cell is not defined' in or related to this line: 'scoreTest += cell.letter;' Line Number: 401
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: '[Exception... "Failure" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: https://beta.frvr.ai/game-template/index-0.0.3.html?frame_id=0&v2=1&1715679717556&disable_analytics=1 line 181 > injectedScript :: execute/window.getRenderer/t.Text.prototype.updateText :: line 1" data: no]' in or related to this line: 'scoreTestText.setText(nouveauScore);' Line Number: 357
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 (23 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: Button is not defined' in or related to this line: 'var validateButton = new Button('Validate', {' Line Number: 271
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: 'ReferenceError: columnFrom is not defined' in or related to this line: 'scoreTest = columnFrom;' Line Number: 89
Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: cells is not defined' in or related to this line: 'mainGrid.cells[i][j].setLetter(cells[i][j].columnFrom, cells[i][j].lineFrom, wordGrid.cells[i][j].letter);' Line Number: 346
Code edit (7 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: newLetter.toUpperCase is not a function' in or related to this line: 'self.texte.setText(newLetter.toUpperCase());' Line Number: 71
User prompt
Please fix the bug: 'ReferenceError: cells is not defined' in or related to this line: 'mainGrid.cells[i][j].setLetter(cells[i][j].column, cells[i][j].line, wordGrid.cells[i][j].letter);' Line Number: 342
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: wordGrid.cells[i][j].removeCell is not a function' in or related to this line: 'wordGrid.cells[i][j].removeCell(j);' Line Number: 342
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
===================================================================
--- original.js
+++ change.js
@@ -131,8 +131,20 @@
self.emptyCells.push(cell);
}
}
}; //Fin de la fonction initializeGrid
+ self.resetGrid = function () {
+ //Réinitialise la grille : remove all cells and repositionnement de la grille
+ for (var i = 0; i < self.gridLines; i++) {
+ for (var j = 0; j < self.gridColumns; j++) {
+ self.removeChild(self.cells[i][j]);
+ }
+ }
+ self.cells = [];
+ self.emptyCells = [];
+ self.gridColumns = 0;
+ self.gridLines = 0;
+ }; //Fin de la fonction resetGrid
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) {
@@ -249,8 +261,9 @@
* Game Code
****/
var wordsMainListTest = ["AARDVARK", "ALBATROSS", "ALLIGATOR", "ALPACA", "ANT"]; //The real main list is at the end
var scoreTest = 0; // Define scoreTest variable
+var score = 0;
var ScoreZone = {
x: 0,
y: 0,
width: game.width,
@@ -267,9 +280,16 @@
fill: "#ffff00",
anchorX: 0.5,
anchorY: 0
});
-LK.gui.top.addChild(scoreTestText);
+LK.gui.topLeft.addChild(scoreTestText);
+var scoreText = new Text2('0', {
+ size: 70,
+ fill: "#00ff00",
+ anchorX: 0.5,
+ anchorY: 0
+});
+LK.gui.top.addChild(scoreText);
var policeSize = 128;
var lettersGrid = game.addChild(new LettersGrid(3, 1, 'cell'));
lettersGrid.clickable = false;
lettersGrid.initializeGrid();
@@ -278,12 +298,10 @@
var mainGrid = game.addChild(new LettersGrid(6, 6, 'cell'));
mainGrid.initializeGrid();
mainGrid.x = (game.width - mainGrid.width) / 2 + lettersGrid.height / 2;
mainGrid.y = ScoreZone.height + 2 * lettersGrid.height;
-var wordGrid = game.addChild(new LettersGrid(0, 1, 'cellWord'));
-wordGrid.initializeGrid();
-wordGrid.x = (game.width - wordGrid.width) / 2 - wordGrid.height / 2 + lettersGrid.height / 2;
-wordGrid.y = ScoreZone.height + lettersGrid.height + mainGrid.height + 2 * lettersGrid.height;
+var wordGrid = null;
+initWordGrid();
var validateButton = new Button('', {
x: game.width / 2,
y: wordGrid.y + wordGrid.height + 300,
width: 200,
@@ -308,14 +326,12 @@
isMGRefillrequired = true;
} else {
//Le mot n'est pas valide, on remet les lettres dans la grille principale
for (var i = 0; i < wordGrid.gridColumns; i++) {
- wordGrid.cells[0][i].isClicked;
+ mainGrid.setLetter(wordGrid.cells[0][i].columnFrom, wordGrid.cells[0][i].lineFrom, wordGrid.cells[0][i].letter);
}
- //wordGrid.gridColumns = 0;
- //wordGrid.initializeGrid();
- //wordGrid.x = (game.width - wordGrid.width) / 2 - wordGrid.height / 2 + lettersGrid.height / 2;
- //wordGrid.y = ScoreZone.height + lettersGrid.height + mainGrid.height + 2 * lettersGrid.height;
+ wordGrid.resetGrid();
+ initWordGrid();
isMGRefillrequired = true;
}
}
});
@@ -329,8 +345,18 @@
****/
function updateScoreTest(nouveauScore) {
scoreTestText.setText(nouveauScore);
} //fin updateScoreTest
+function updateScore(nouveauScore) {
+ scoreText.setText(nouveauScore);
+} //fin updateScore
+function initWordGrid() {
+ //Initialise la grille des lettres formant le mot
+ wordGrid = game.addChild(new LettersGrid(0, 1, 'cellWord'));
+ wordGrid.initializeGrid();
+ wordGrid.x = (game.width - wordGrid.width) / 2 - wordGrid.height / 2 + lettersGrid.height / 2;
+ wordGrid.y = ScoreZone.height + lettersGrid.height + mainGrid.height + 2 * lettersGrid.height;
+} //Fin de la fonction initWordGrid
//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() * wordsMainListTest.length);
var word = wordsMainListTest[randomIndex];
@@ -359,16 +385,19 @@
}
} //Fin de la fonction stackLettersFromWords
//Fonction transfertLettersGridToMainGrid : permet de transférer les lettres de la liste lettersToAdd dans la grille principale
function transfertLettersGridToMainGrid() {
+ scoreTest = "";
for (var i = 0; i < lettersGrid.gridColumns && lettersToAdd.length > 0; i++) {
- mainGrid.addRandomLetter(lettersToAdd[0]);
- lettersToAdd.splice(0, 1);
+ var newLetter = lettersGrid.cells[0][i].letter;
+ mainGrid.addRandomLetter(newLetter);
+ scoreTest += newLetter;
+ lettersGrid.cells[0][i].setLetter('');
}
} //Fin de la fonction transfertLettersGridToMainGrid
//Fonction addCellLetterToWord : permet d'ajouter une cellule à la liste des lettres formant le mot situé sous la grille
function addCellLetterToWord(letter) {
- var cellLetter = wordGrid.addCell(letter, 'cellWord');
+ var cellLetter = wordGrid.addCell(letter, 'cell');
return cellLetter;
} //Fin de la fonction addCellLetterToWord
//Fonction validateWord : permet de valider le mot formé par le joueur
function validateWord() {
@@ -376,9 +405,9 @@
for (var i = 0; i < wordGrid.gridColumns; i++) {
word += wordGrid.cells[0][i].letter;
}
if (wordsMainList.includes(word)) {
- scoreTest += word.length;
+ score += word.length;
isWordValid = true;
} else {
isWordValid = false;
}
@@ -386,9 +415,12 @@
return isWordValid;
} //Fin de la fonction validateWord
game.update = function () {
updateScoreTest(scoreTest);
- scoreTest = wordGrid.x;
+ scoreTest += " / ";
+ for (var i = 0; i < lettersToAdd.length; i++) {
+ scoreTest += lettersToAdd[i];
+ }
//Recherche de la lettre cliquée dans la mainGrid et ajout de la lettre à la liste des lettres formant le mot
for (var i = 0; i < mainGrid.gridLines; i++) {
for (var j = 0; j < mainGrid.gridColumns; j++) {
if (mainGrid.cells[i][j].isClicked) {
@@ -458,8 +490,14 @@
if (isMGRefillrequired) {
transfertLettersGridToMainGrid();
isMGRefillrequired = false;
}
+ //Detection de la fin de la partie
+ if (mainGrid.isFull()) {
+ LK.setTimeout(function () {
+ LK.showGameOver();
+ }, 3000);
+ }
}
}; //Fin de la fonction update
//Liste des mots en majuscule
var wordsMainList = ["AARDVARK", "ALBATROSS", "ALLIGATOR", "ALPACA", "ANT", "ANTEATER", "ANTELOPE", "APE", "ARMADILLO", "BABOON", "BADGER", "BAT", "BEAR", "BEAVER", "BEE", "BEETLE", "BISON", "BOAR", "BUFFALO", "BUTTERFLY", "CAMEL", "CANARY", "CAPYBARA", "CARIBOU", "CARP", "CAT", "CATERPILLAR", "CHEETAH", "CHICKEN", "CHIMPANZEE", "CHINCHILLA", "CHOUGH", "CLAM", "COBRA", "COCKROACH", "COD", "CORMORANT", "COYOTE", "CRAB", "CRANE", "CROCODILE", "CROW", "CURLEW", "DEER", "DINOSAUR", "DOG", "DOGFISH", "DOLPHIN", "DONKEY", "DOTTEREL", "DOVE", "DRAGONFLY", "DUCK", "DUGONG", "DUNLIN", "EAGLE", "ECHIDNA", "EEL", "ELAND", "ELEPHANT", "ELK", "EMU", "FALCON", "FERRET", "FINCH", "FISH", "FLAMINGO", "FLY", "FOX", "FROG", "GAUR", "GAZELLE", "GERBIL", "GIRAFFE", "GNAT", "GNU", "GOAT", "GOLDFINCH", "GOLDFISH", "GOOSE", "GORILLA", "GOSHAWK", "GRASSHOPPER", "GROUSE", "GUANACO", "GULL", "HAMSTER", "HARE", "HAWK", "HEDGEHOG", "HERON", "HERRING", "HIPPOPOTAMUS", "HORNET", "HORSE", "HUMMINGBIRD", "HYENA", "IBEX", "IBIS", "JACKAL", "JAGUAR", "JAY", "JELLYFISH", "KANGAROO", "KINGFISHER", "KOALA", "KOOKABURA", "KUDU", "LAPWING", "LARK", "LEMUR", "LEOPARD", "LION", "LLAMA", "LOBSTER", "LOCUST", "LORIS", "LOUSE", "LYREBIRD", "MAGPIE", "MALLARD", "MANATEE", "MANDRILL", "MANTIS", "MARTEN", "MEERKAT", "MINK", "MOLE", "MONKEY", "MOOSE", "MOSQUITO", "MOUSE", "MULE", "NARWHAL", "NEWT", "NIGHTINGALE", "OCTOPUS", "OKAPI", "OPOSSUM", "ORYX", "OSTRICH", "OTTER", "OWL", "OYSTER", "PANTHER", "PARROT", "PARTRIDGE", "PEAFOWL", "PELICAN", "PENGUIN", "PHEASANT", "PIG", "PIGEON", "POLAR BEAR", "PORCUPINE", "PORPOISE", "QUAIL", "QUELEA", "QUETZAL", "RABBIT", "RACCOON", "RAIL", "RAM", "RAT", "RAVEN", "REINDEER", "RHINOCEROS", "ROOK", "SALAMANDER", "SALMON", "SANDPIPER", "SARDINE", "SCORPION", "SEAHORSE", "SEAL", "SHARK", "SHEEP", "SHREW", "SKUNK", "SNAIL", "SNAKE", "SPARROW", "SPIDER", "SPOONBILL", "SQUID", "SQUIRREL", "STARLING", "STINGRAY", "STINKBUG", "STORK", "SWALLOW", "SWAN", "TAPIR", "TARSIER", "TERMITE", "TIGER", "TERN", "THRUSH", "TIGER", "TOAD", "TOUCAN", "TROUT", "TURKEY", "TURTLE", "VIPER", "VULTURE", "WALLABY", "WALRUS", "WASP", "WEASEL", "WHALE", "WILDCAT", "WOLF", "WOMBAT", "WOODCOCK", "WOODPECKER", "WORM", "WREN", "YAK", "ZEBRA"];
\ No newline at end of file
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.