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
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: 381
Code edit (1 edits merged)
Please save this source code
Code edit (19 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: LK.Sprite is not a constructor' in or related to this line: 'var backGroundImage = game.addChild(new LK.Sprite('BackGroundImage', {' Line Number: 268
Code edit (1 edits merged)
Please save this source code
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
===================================================================
--- original.js
+++ change.js
@@ -3,38 +3,32 @@
****/
/****
* GAME DESCRIPTION:
* Game Principle:
- * -There is a board filled with words, where the player selects letters from a partially filled grid.
+ * -There is a board filled with letters, where the player selects letters from a partially filled grid.
* -With these letters, the player forms a word that appears below the grid, then validates their word.
- * -If the word is among the words on the board, it is valid, and the player earns points.
+ * -If the word is among the main list, it is valid, and the player earns points.
* -The score obtained is proportional to the length of the word.
- * -Above the grid, there are letters randomly taken from the word board.
* -These letters move randomly within the grid to empty spaces.
- * -New letters are placed above the grid.
* -If the word is not valid, the letters forming the word are returned to their original position in the grid.
- * -The letters above the grid move randomly within the grid to empty spaces.
+ * -A new word is selected from the main list, shuffled and randomly dispatched in the empty cells.
* -If there is no more space in the grid, the game is over.
* Game Areas:
- * The screen is divided into 6 main zones in the following descending order:
+ * The screen is divided into 5 main zones in the following descending order:
1. Score area: displays the player's score.
- 2. Next letters area: displays the letters that will fall into the grid.
- 3. The grid: the letter grid.
- 4. Word area: displays the word formed by the player.
- 5. Validation area: button to validate the word or erase letters.
- 6. Options area (or advertisement).
+ 2. The grid: the letter grid (main grid).
+ 3. Word area: displays the word formed by the player (word grid).
+ 4. Validation area: button to validate the word or erase letters.
+ 5. Options area (or advertisement).
* Game Progression:
- * At the start of the game, the grid is almost full, containing 5 letters.
- * Above the grid, there are 4 letters randomly taken from the word board.
+ * At the beginning of the game, the grid is almost empty, containing one shuffled word.
* The player can choose a letter in the grid by clicking on it.
* The chosen letter is added to the word area.
* The player can validate the word or erase a letter by clicking on the letter in the word, which then returns to its place in the grid.
* When the player thinks he has formed a word, he can validate it with the validate button located below the word area.
* If the word is valid, the player earns points, and the score is updated.
- * The letters located above the grid move randomly within the grid to empty spaces.
- * New letters are added above the grid.
* If the word is not valid, the letters forming the word are returned to their original position in the grid.
- * The letters located above the grid move randomly within the grid to empty spaces.
+ * 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 Button = Container.expand(function (text, options) {
@@ -259,8 +253,13 @@
/****
* Game Code
****/
+var backGroundImage = LK.getAsset('BackGroundImage', {
+ width: game.width,
+ height: game.height
+});
+game.addChild(backGroundImage);
//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 = {
@@ -282,21 +281,21 @@
anchorY: 0
});
LK.gui.topLeft.addChild(scoreTestText);
var scoreText = new Text2('0', {
- size: 70,
+ size: 80,
fill: "#00ff00",
anchorX: 0.5,
anchorY: 0
});
LK.gui.top.addChild(scoreText);
var policeSize = 128;
-var lettersGrid = game.addChild(new LettersGrid(3, 1, 'cell'));
+var lettersGrid = new LettersGrid(1, 1, 'cell');
lettersGrid.clickable = false;
lettersGrid.initializeGrid();
lettersGrid.x = (game.width - lettersGrid.width) / 2 + lettersGrid.height / 2;
lettersGrid.y = ScoreZone.height + lettersGrid.height / 2;
-var mainGrid = game.addChild(new LettersGrid(6, 6, 'cell'));
+var mainGrid = game.addChild(new LettersGrid(7, 7, 'cell'));
mainGrid.initializeGrid();
mainGrid.x = (game.width - mainGrid.width) / 2 + lettersGrid.height / 2;
mainGrid.y = ScoreZone.height + 2 * lettersGrid.height;
var wordGrid = null;
@@ -313,16 +312,17 @@
},
onClick: function onClick() {
//Fonction appelée lors du click sur le bouton de validation
if (validateWord()) {
- for (var i = 0; i < wordGrid.gridColumns; i++) {
- mainGrid.setLetter(i, 0, '');
- }
//On vide la grille des lettres formant le mot final apres x secondes
LK.setTimeout(function () {
wordGrid.resetGrid();
initWordGrid();
}, 1000);
+ if (mainGrid.isEmpty()) {
+ score += 10; //Bonus for emptying the main grid
+ 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++) {
mainGrid.setLetter(wordGrid.cells[0][i].columnFrom, wordGrid.cells[0][i].lineFrom, wordGrid.cells[0][i].letter);
@@ -350,10 +350,10 @@
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;
+ wordGrid.x = (game.width - wordGrid.width) / 2 - wordGrid.height / 2;
+ wordGrid.y = ScoreZone.height + 300 + mainGrid.height + 200;
} //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() * wordsMainList.length);
@@ -391,17 +391,8 @@
isPossibleToAddletter = mainGrid.addRandomLetter(word[i]);
}
return isPossibleToAddletter;
} //Fin de la fonction putRandomShuffledWordInGrid
-//Fonction transfertLettersGridToMainGrid : permet de transférer les lettres de la liste lettersToAdd dans la grille principale
-function transfertLettersGridToMainGrid() {
- for (var i = 0; i < lettersGrid.gridColumns && lettersToAdd.length > 0; i++) {
- var newLetter = lettersGrid.cells[0][i].letter;
- mainGrid.addRandomLetter(newLetter);
- lettersGrid.cells[0][i].setLetter('');
- lettersGrid.emptyCells.push(lettersGrid.cells[0][i]);
- }
-} //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');
return cellLetter;
@@ -462,9 +453,9 @@
//Chargement initiale de la grille principale si nécessaire (vide):
//mot(s) est choisi au hasard dans la liste principale,
//il est mélangé et les lettres sont directement ajoutées à la grille principale avec la fonction addRandomLetter
if (mainGrid.isEmpty() && !isGameStarted) {
- var wordsToBegin = pickAndShakeWords(2);
+ var wordsToBegin = pickAndShakeWords(1);
var wordCompiled = "";
for (var i = 0; i < wordsToBegin.length; i++) {
wordCompiled += wordsToBegin[i];
}
@@ -484,38 +475,8 @@
}, 1000);
}
isMGRefillrequired = false;
}
- //Remplissage de la file d'attente des lettres à ajouter dans la lettersGrid
- //Si le nombre de lettres est inférieur à la taille de la lettersGrid,
- //on prendre un mot au hasard dans la liste principale, on le mélange et on ajoute les lettres à la file d'attente
- if (lettersToAdd.length < lettersGrid.gridColumns) {
- var wordsToBegin = pickAndShakeWords(1);
- if (wordsToBegin.length > 0) {
- stackLettersFromWords(wordsToBegin);
- }
- }
- //Remplissage lettersGrid si elle est vide,
- //on retire les premières lettres de la liste des lettres à ajouter, et on les ajoute à la grille principale
- //sachant que le nombre de lettres à ajouter est égal à la taille de la lettersGrid
- if (lettersToAdd.length > 0 && lettersGrid.isEmpty()) {
- for (var i = 0; i < lettersGrid.gridColumns && lettersToAdd.length > 0; i++) {
- lettersGrid.addRandomLetter(lettersToAdd[0]);
- lettersToAdd.splice(0, 1);
- }
- }
- //Rechargement de la grille principale si nécessaire et fin de la partie
- if (isMGRefillrequired) {
- //Detection de la fin de la partie
- if (mainGrid.isFull()) {
- LK.setTimeout(function () {
- LK.showGameOver();
- }, 1000);
- } else {
- transfertLettersGridToMainGrid();
- isMGRefillrequired = false;
- }
- }
}
}; //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", "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"];
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.