Code edit (8 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: letterTilesArr is not a function' in or related to this line: 'letterTilesArr(letterTile);' Line Number: 235
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: 'Uncaught TypeError: Cannot read properties of undefined (reading 'anchor')' in or related to this line: 'scoreTxt.anchor.set(0.5, 0);' Line Number: 132
Code edit (2 edits merged)
Please save this source code
User prompt
when a word is correct, remove it from the levels[currentLevel].words array
Code edit (1 edits merged)
Please save this source code
Code edit (15 edits merged)
Please save this source code
User prompt
make a small star explosion on the blackboard when a word is correct
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: blackBoardText is not defined' in or related to this line: 'blackBoardArr.push(blackBoardText);' Line Number: 129
Code edit (1 edits merged)
Please save this source code
User prompt
when a submitted word is incorrect, destroy the letters on the blackboard and reset the lettertiles to alpha 1 and being clickable
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
===================================================================
--- original.js
+++ change.js
@@ -11,21 +11,25 @@
anchorY: 0.5
});
var letterText = new Text2(self.letter, {
size: 100,
- fill: "#000000"
+ fill: "#000000",
+ weight: 300
});
letterText.anchor.set(0.5, 0.5);
self.addChild(letterText);
self.setLetter = function (letter) {
self.letter = letter;
letterText.setText(letter);
};
+ self.clickable = true;
self.down = function (x, y, obj) {
- writeLetterOnBlackboard(self.letter);
- currentWord += self.letter;
- self.alpha = 0.5;
- self.down = null; // Make it unclickable
+ if (self.clickable) {
+ writeLetterOnBlackboard(self.letter);
+ currentWord += self.letter;
+ self.alpha = 0.5;
+ self.clickable = false; // Make it unclickable
+ }
};
return self;
});
var SubmitButton = Container.expand(function () {
@@ -47,23 +51,29 @@
console.log('correct');
var scoreIncrement = currentWord.length;
LK.setScore(LK.getScore() + scoreIncrement);
scoreTxt.setText(LK.getScore());
- clearBlackBoard();
+ // Create star explosion effect
+ createStarExplosion();
+ blackBoardArr = [];
+ blackboardOffsetX = 0;
+ blackboardOffsetY += 120;
+ game.children.forEach(function (child) {
+ if (child instanceof LetterTile) {
+ child.alpha = 1;
+ child.clickable = true;
+ }
+ });
+ currentWord = "";
} else {
console.log('incorrect');
// Destroy the letters on the blackboard
clearBlackBoard();
// Reset the letter tiles
game.children.forEach(function (child) {
if (child instanceof LetterTile) {
child.alpha = 1;
- child.down = function (x, y, obj) {
- writeLetterOnBlackboard(self.letter);
- currentWord += self.letter;
- self.alpha = 0.5;
- self.down = null; // Make it unclickable
- };
+ child.clickable = true;
}
});
blackboardOffsetX = 0;
currentWord = "";
@@ -99,23 +109,26 @@
var blackBoardArr = [];
var currentWord = "";
var scoreTxt = new Text2('0', {
size: 150,
- fill: "#ffffff"
+ fill: "#ADD8E6",
+ stroke: "#000000",
+ strokeThickness: 10
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var blackboardOffsetX = 0;
+var blackboardOffsetY = 0;
function writeLetterOnBlackboard(letter) {
var blackboardText = new Text2(letter, {
- size: 150,
+ size: 120,
fill: "#ffffff",
stroke: "#000000",
strokeThickness: 10
});
blackboardText.anchor.set(0.5, 0.5);
blackboardText.x = 400 + blackboardOffsetX;
- blackboardText.y = 400;
+ blackboardText.y = 400 + blackboardOffsetY;
game.addChild(blackboardText);
blackBoardArr.push(blackboardText);
blackboardOffsetX += 110; // Adjust the offset value as needed
// Check if this is the first letter clicked
@@ -274,5 +287,36 @@
// Initialize variables
// Update function
game.update = function () {
// Game update logic
-};
\ No newline at end of file
+};
+function createStarExplosion() {
+ for (var i = 0; i < 20; i++) {
+ var star = LK.getAsset('centerCircle', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: Math.random() * 0.5 + 0.5,
+ scaleY: Math.random() * 0.5 + 0.5,
+ x: 2048 / 2,
+ y: 2732 / 2
+ });
+ game.addChild(star);
+ var angle = Math.random() * Math.PI * 2;
+ var speed = Math.random() * 10 + 5;
+ var vx = Math.cos(angle) * speed;
+ var vy = Math.sin(angle) * speed;
+ (function (star, vx, vy) {
+ var lifetime = 30;
+ var tick = 0;
+ var interval = LK.setInterval(function () {
+ star.x += vx;
+ star.y += vy;
+ star.alpha -= 1 / lifetime;
+ tick++;
+ if (tick >= lifetime) {
+ star.destroy();
+ LK.clearInterval(interval);
+ }
+ }, 16);
+ })(star, vx, vy);
+ }
+}
\ No newline at end of file
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.