Code edit (17 edits merged)
Please save this source code
User prompt
when a submitted word is correct, add 1 point of score for each letter in the word and update a scorelabel with the new score
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'letters')' in or related to this line: 'return levels[currentLevel].letters;' Line Number: 214
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: levels is not defined' in or related to this line: 'return levels[currentLevel];' Line Number: 240
Code edit (5 edits merged)
Please save this source code
User prompt
please populate the levels array with 10 sets of 3 letters and the words these can spell out
User prompt
each level should have it's letters, but also a set of acceptable words. please make a structure for that.
Code edit (8 edits merged)
Please save this source code
User prompt
once the first letter on each level is clicked, a submit button shoud appear below the leters
User prompt
once a letter is clicked, it should become 0.5 alpha and unclickable
User prompt
please adda black outline to backboardtext
Code edit (1 edits merged)
Please save this source code
User prompt
each added letter on blackboard should be offeset x-wise
User prompt
when player clicks a letter, it is written on the blackboard
Code edit (7 edits merged)
Please save this source code
User prompt
make a teacher class and graphics asset, and place her immediately above the background
Code edit (5 edits merged)
Please save this source code
User prompt
make a background graphic object covering the whole screen
Code edit (1 edits merged)
Please save this source code
User prompt
write a function that does the same as displayletterincircle but only displays the letters on a line, centered at height 2000
Code edit (2 edits merged)
Please save this source code
User prompt
please implement the function makeNewDrawing so that it places a number of graphics assets to form a line between drawStartX, drawStartY and the x and y passed as parameters.
Code edit (1 edits merged)
Please save this source code
/**** * Classes ****/ //<Assets used in the game will automatically appear here> // Class for Letter Tiles var LetterTile = Container.expand(function () { var self = Container.call(this); self.letter = ''; var tileGraphics = self.attachAsset('tile', { anchorX: 0.5, anchorY: 0.5 }); var letterText = new Text2(self.letter, { size: 100, fill: "#000000" }); letterText.anchor.set(0.5, 0.5); self.addChild(letterText); self.setLetter = function (letter) { self.letter = letter; letterText.setText(letter); }; self.down = function (x, y, obj) { writeLetterOnBlackboard(self.letter); currentWord += self.letter; self.alpha = 0.5; self.down = null; // Make it unclickable }; return self; }); var SubmitButton = Container.expand(function () { var self = Container.call(this); var buttonGraphics = self.attachAsset('submitButton', { anchorX: 0.5, anchorY: 0.5 }); var buttonText = new Text2('Submit', { size: 100, fill: "#000000" }); buttonText.anchor.set(0.5, 0.5); self.addChild(buttonText); self.down = function (x, y, obj) { console.log("Submit button clicked: ", currentWord); // Add logic to handle submit action if (levels[currentLevel].words.includes(currentWord)) { console.log('correct'); var scoreIncrement = currentWord.length; LK.setScore(LK.getScore() + scoreIncrement); scoreTxt.setText(LK.getScore()); } else { console.log('incorrect'); } }; return self; }); var Teacher = Container.expand(function () { var self = Container.call(this); var teacherGraphics = self.attachAsset('teacher', { anchorX: 0.5, anchorY: 0.5 }); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ var currentWord = ""; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var blackboardOffsetX = 0; function writeLetterOnBlackboard(letter) { var blackboardText = new Text2(letter, { size: 150, fill: "#ffffff", stroke: "#000000", strokeThickness: 10 }); blackboardText.anchor.set(0.5, 0.5); blackboardText.x = 400 + blackboardOffsetX; blackboardText.y = 400; game.addChild(blackboardText); blackboardOffsetX += 110; // Adjust the offset value as needed // Check if this is the first letter clicked if (blackboardOffsetX === 110) { var submitButton = new SubmitButton(); submitButton.x = 2048 / 2; submitButton.y = 2400; game.addChild(submitButton); } } // Add background graphic object covering the whole screen var background = LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2 - 50, y: 2732 / 2 - 200 }); game.init = function () { game.addChild(background); var teacher = new Teacher(); teacher.x = 2048 / 2 + 380; teacher.y = 2732 / 2 - 250; game.addChild(teacher); }; // Function to reset the game state for the new level function resetGameStateForNewLevel() { // Logic to reset the game state for the new level // For example, clear the board, reset the score, etc. LK.setScore(0); scoreTxt.setText(LK.getScore()); displayLettersInLine(); } // Function to display letters in a line centered at height 2000 function displayLettersInLine() { var startX = 2048 / 2 - letters.length * 220 / 2; var y = 2000; for (var i = 0; i < letters.length; i++) { var x = startX + i * 220; var letterTile = new LetterTile(); letterTile.setLetter(letters[i]); letterTile.x = x; letterTile.y = y; game.addChild(letterTile); } } // Function to advance to the next level function advanceToNextLevel() { if (currentLevel < levels.length - 1) { currentLevel++; letters = getLettersForCurrentLevel(); resetGameStateForNewLevel(); } else { console.log("All levels completed!"); } } // Define levels with different sets of letters and acceptable words var levels3 = [{ letters: ['N', 'W', 'O'], words: ['NOW', 'WON', 'OWN'] }, { letters: ['A', 'E', 'T'], words: ['TEA', 'EAT', 'ATE'] }, { letters: ['A', 'M', 'R'], words: ['MAR', 'ARM', 'RAM'] }, { letters: ['A', 'T', 'P'], words: ['APT', 'PAT', 'TAP'] }, { letters: ['A', 'T', 'R'], words: ['TAR', 'ART', 'RAT'] }, { letters: ['O', 'T', 'P'], words: ['OPT', 'TOP', 'POT'] }, { letters: ['A', 'E', 'R'], words: ['EAR', 'ARE', 'ERA'] }]; var levels4 = [{ letters: ['E', 'C', 'A', 'R'], words: ['ACRE', 'CARE', 'RACE', 'ACER'] }, { letters: ['E', 'S', 'N', 'T'], words: ['NETS', 'TENS', 'SENT', 'NEST'] }, { letters: ['E', 'L', 'A', 'M'], words: ['LAME', 'MALE', 'MEAL'] }, { letters: ['S', 'D', 'E', 'U'], words: ['DUES', 'SUED', 'USED'] }, { letters: ['P', 'S', 'A', 'N'], words: ['NAPS', 'SNAP', 'PANS', 'SPAN'] }, { letters: ['A', 'L', 'R', 'I'], words: ['LAIR', 'LIAR', 'RAIL'] }]; var levels5 = [{ letters: ['T', 'D', 'E', 'I'], words: ['DIET', 'EDIT', 'TIDE', 'TIED'] }, { letters: ['T', 'E', 'L', 'A', 'R'], words: ['ALTER', 'ALTER', 'LATER'] }, { letters: ['E', 'S', 'M', 'L', 'I'], words: ['LIMES', 'SMILE', 'MILES', 'SLIME'] }, { letters: ['S', 'R', 'T', 'I', 'E'], words: ['RITES', 'TIERS', 'TRIES', 'TIRES'] }, { letters: ['P', 'S', 'A', 'E', 'H'], words: ['HEAPS', 'SHAPE', 'PHASE'] }, { letters: ['O', 'D', 'Y', 'R', 'W'], words: ['DOWRY', 'ROWDY', 'WORDY'] }, { letters: ['E', 'B', 'O', 'R', 'S'], words: ['BORES', 'ROBES', 'SOBER'] }, { letters: ['P', 'L', 'E', 'S', 'O'], words: ['LOPES', 'POLES', 'SLOPE'] }]; // Initialize the first level's letters and show level 1 when the game starts var currentLevel = 0; function shuffleArray(array) { for (var i = array.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = array[i]; array[i] = array[j]; array[j] = temp; } } shuffleArray(levels3); shuffleArray(levels4); shuffleArray(levels5); var levels = levels3.concat(levels4, levels5); var letters = getLettersForCurrentLevel(); displayLettersInLine(); // Current level index // Function to get letters for the current level function getLettersForCurrentLevel() { return levels[currentLevel].letters; } // Initialize variables // Update function game.update = function () { // Game update logic };
===================================================================
--- original.js
+++ change.js
@@ -107,13 +107,15 @@
anchorY: 0.5,
x: 2048 / 2 - 50,
y: 2732 / 2 - 200
});
-game.addChild(background);
-var teacher = new Teacher();
-teacher.x = 2048 / 2 + 380;
-teacher.y = 2732 / 2 - 250;
-game.addChild(teacher);
+game.init = function () {
+ game.addChild(background);
+ var teacher = new Teacher();
+ teacher.x = 2048 / 2 + 380;
+ teacher.y = 2732 / 2 - 250;
+ game.addChild(teacher);
+};
// Function to reset the game state for the new level
function resetGameStateForNewLevel() {
// Logic to reset the game state for the new level
// For example, clear the board, reset the score, etc.
A smooth, clean, blank and empty scrabble tile for a game.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A clean, warm and welcoming classroom in a school, facing the blackboard.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A small golden star. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.