User prompt
make blocks and background a bit bigger but blocks dont overflow to background
User prompt
blocks a bit smaller
User prompt
a new rectangle assets to below 5x5
User prompt
put a rectangle assest below the 5x5 line background
User prompt
make 5x5 line and the background a bit smaller
User prompt
add calculating score bar put it up to 5x5 line and put background to calculating score bar
User prompt
Please fix the bug: 'null is not an object (evaluating 'spinBtn.y')' in or related to this line: 'var scoreBarY = spinBtn.y + spinBtnRadius + 20; // Just behind the score numbers' Line Number: 154
User prompt
make score bar background smaller and make it background the score numbers
User prompt
make a square the background assest and make it fully background to 5x5 line
User prompt
make background 1 assest remove the fire and rainbow effects
User prompt
remove block_genus_0 image in background. It should be only in spawning blocks
User prompt
make score calculating bar bigger and remove the / 5000
User prompt
add new assets and make it the background square. Put up to the score bar and make bigger
User prompt
in the first spin no cooldown after first break add 3 second cooldown
User prompt
change break count 5 to 7 same genus blocks
User prompt
add 3 second cooldown to block spawn
User prompt
add score calculating bar up to 5x5 line with text βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
Put spin button below 5x5 line and add fire effect background
User prompt
put the screent into a rainbow square and make spin button a circle assets and put spin button below the blocks screen
User prompt
add different 8 block assest for 8 different genus blocks to spawn
User prompt
add break cooldown. make a algorithm sometimes game give low scores βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
add slowly,break and drop down animation to blocks. Change block colours 8 genus blocks to 8 different color. Add score bar while game contiune βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Spin & Match: Genus Block Breaker
Initial prompt
Make me a screen 5 line 5 column and put a spin button to down the 5 line 5 column screen. There comes random 25 blocks. In game will have 8 genus block, and if in the screens 5 or more blocks same genus, them will break and comes again random blocks. If white blocks break points give 1 x white block number, black blocks give 2 x black block number, yellow blocks give 3 x yellow block number, orange blocks give 4 x orange block number etc. Put point bar to below spin button. Block always spam to when no more 5 same genus block. And when we click the spin button game again give 25 random block and game started.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Block class: represents a single block in the grid var Block = Container.expand(function () { var self = Container.call(this); // Properties self.genus = 0; // 0-7 self.gridX = 0; // 0-4 self.gridY = 0; // 0-4 // Asset for the block var blockAsset = null; // Set genus and update asset self.setGenus = function (genus) { self.genus = genus; // Remove old asset if present if (blockAsset) { self.removeChild(blockAsset); } // Each genus gets a unique color and shape var colors = [0xf44336, // red 0x2196f3, // blue 0x4caf50, // green 0xffeb3b, // yellow 0x9c27b0, // purple 0xff9800, // orange 0x00bcd4, // cyan 0x8bc34a // light green ]; var shapes = ['box', 'ellipse', 'box', 'ellipse', 'box', 'ellipse', 'box', 'ellipse']; blockAsset = self.attachAsset('block_genus_' + genus, { width: blockSize, height: blockSize, color: colors[genus], shape: shapes[genus], anchorX: 0.5, anchorY: 0.5 }); }; // Animate breaking self.breakAnim = function (_onFinish) { tween(self, { scaleX: 1.3, scaleY: 1.3, alpha: 0 }, { duration: 200, easing: tween.cubicOut, onFinish: function onFinish() { self.scaleX = 1; self.scaleY = 1; self.alpha = 1; if (_onFinish) _onFinish(); } }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x222222 }); /**** * Game Code ****/ // --- Constants --- var gridSize = 5; var genusCount = 8; var blockSize = 260; // 5 blocks * 260 = 1300, fits well in 2048 width with margin var gridPadding = 24; var gridTotalSize = blockSize * gridSize + gridPadding * (gridSize - 1); var gridStartX = Math.floor((2048 - gridTotalSize) / 2) + blockSize / 2; var gridStartY = 400 + blockSize / 2; // leave space for Spin button // --- State --- var grid = []; // 2D array [y][x] of Block var score = 0; var isSpinning = false; // --- UI Elements --- var spinBtn = null; var scoreTxt = null; // --- Helper Functions --- // Generate a random genus (0-7) function randomGenus() { return Math.floor(Math.random() * genusCount); } // Place a block at grid[x][y] function placeBlock(x, y, genus) { var block = new Block(); block.setGenus(genus); block.gridX = x; block.gridY = y; block.x = gridStartX + x * (blockSize + gridPadding); block.y = gridStartY + y * (blockSize + gridPadding); block.scaleX = 1; block.scaleY = 1; block.alpha = 1; game.addChild(block); return block; } // Remove a block from the game and grid function removeBlock(block) { if (block) { block.destroy(); } } // Fill the grid with random blocks, destroying old ones function fillGridRandom() { // Remove old blocks for (var y = 0; y < gridSize; y++) { for (var x = 0; x < gridSize; x++) { if (grid[y][x]) { removeBlock(grid[y][x]); } } } // Fill with new blocks for (var y = 0; y < gridSize; y++) { for (var x = 0; x < gridSize; x++) { var genus = randomGenus(); var block = placeBlock(x, y, genus); grid[y][x] = block; } } } // Find all genus with 5 or more blocks, return array of {genus, blocks: [Block]} function findMatches() { // Count blocks per genus var genusBlocks = []; for (var g = 0; g < genusCount; g++) { genusBlocks[g] = []; } for (var y = 0; y < gridSize; y++) { for (var x = 0; x < gridSize; x++) { var block = grid[y][x]; genusBlocks[block.genus].push(block); } } var matches = []; for (var g = 0; g < genusCount; g++) { if (genusBlocks[g].length >= 5) { matches.push({ genus: g, blocks: genusBlocks[g] }); } } return matches; } // Break all matched blocks, animate, update score, and refill function breakAndRefill(matches, onFinish) { if (matches.length === 0) { if (onFinish) onFinish(); return; } var blocksToBreak = []; for (var i = 0; i < matches.length; i++) { blocksToBreak = blocksToBreak.concat(matches[i].blocks); } // Remove duplicates (shouldn't be any, but just in case) var uniqueBlocks = []; var seen = {}; for (var i = 0; i < blocksToBreak.length; i++) { var b = blocksToBreak[i]; var key = b.gridX + ',' + b.gridY; if (!seen[key]) { uniqueBlocks.push(b); seen[key] = true; } } // Animate breaking var brokenCount = 0; for (var i = 0; i < uniqueBlocks.length; i++) { (function (block) { block.breakAnim(function () { // Remove from grid grid[block.gridY][block.gridX] = null; removeBlock(block); brokenCount++; // When all blocks are broken, refill if (brokenCount === uniqueBlocks.length) { // Update score: 10 points per block, +10 per extra block above 5, * genus+1 for (var m = 0; m < matches.length; m++) { var count = matches[m].blocks.length; var genus = matches[m].genus; score += (10 * count + 10 * Math.max(0, count - 5)) * (genus + 1); } updateScore(); // Refill broken blocks with new random blocks for (var y = 0; y < gridSize; y++) { for (var x = 0; x < gridSize; x++) { if (!grid[y][x]) { var genus = randomGenus(); var newBlock = placeBlock(x, y, genus); grid[y][x] = newBlock; } } } // After refill, check for new matches recursively var newMatches = findMatches(); if (newMatches.length > 0) { breakAndRefill(newMatches, onFinish); } else { if (onFinish) onFinish(); } } }); })(uniqueBlocks[i]); } } // Update score text and LK score function updateScore() { LK.setScore(score); scoreTxt.setText(score); } // Check if any matches are possible (i.e., if any genus has 5+ blocks) function hasMatches() { var matches = findMatches(); return matches.length > 0; } // Handle Spin button press function onSpin() { if (isSpinning) return; isSpinning = true; // Animate all blocks out (optional, for feedback) for (var y = 0; y < gridSize; y++) { for (var x = 0; x < gridSize; x++) { var block = grid[y][x]; if (block) { tween(block, { scaleX: 0.7, scaleY: 0.7, alpha: 0.3 }, { duration: 120, easing: tween.cubicIn }); } } } // After short delay, refill grid LK.setTimeout(function () { fillGridRandom(); // After refill, check for matches and break recursively var matches = findMatches(); if (matches.length > 0) { breakAndRefill(matches, function () { isSpinning = false; // After all matches, check if any more matches are possible if (!hasMatches()) { // Game over LK.effects.flashScreen(0x000000, 600); LK.showGameOver(); } }); } else { isSpinning = false; // If no matches at all, game over LK.effects.flashScreen(0x000000, 600); LK.showGameOver(); } }, 180); } // --- UI Setup --- // Spin Button spinBtn = LK.getAsset('spinBtn', { width: 520, height: 160, color: 0xffffff, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 180 }); game.addChild(spinBtn); // Spin Button Text var spinBtnTxt = new Text2('SPIN', { size: 90, fill: 0x222222 }); spinBtnTxt.anchor.set(0.5, 0.5); spinBtnTxt.x = spinBtn.x; spinBtnTxt.y = spinBtn.y; game.addChild(spinBtnTxt); // Score Text (below Spin button) scoreTxt = new Text2('0', { size: 110, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); scoreTxt.x = 2048 / 2; scoreTxt.y = spinBtn.y + 120; LK.gui.top.addChild(scoreTxt); // --- Input Handling --- // Only allow pressing Spin button (not grid) spinBtn.down = function (x, y, obj) { if (isSpinning) return; onSpin(); // Animate button press tween(spinBtn, { scaleX: 0.92, scaleY: 0.92 }, { duration: 60, easing: tween.cubicIn, onFinish: function onFinish() { tween(spinBtn, { scaleX: 1, scaleY: 1 }, { duration: 80, easing: tween.cubicOut }); } }); tween(spinBtnTxt, { scaleX: 0.92, scaleY: 0.92 }, { duration: 60, easing: tween.cubicIn, onFinish: function onFinish() { tween(spinBtnTxt, { scaleX: 1, scaleY: 1 }, { duration: 80, easing: tween.cubicOut }); } }); }; // --- Game Initialization --- // Initialize grid array for (var y = 0; y < gridSize; y++) { grid[y] = []; for (var x = 0; x < gridSize; x++) { grid[y][x] = null; } } // Start with a random grid and score 0 score = 0; updateScore(); fillGridRandom(); // On game start, immediately break and refill if there are matches var initialMatches = findMatches(); if (initialMatches.length > 0) { breakAndRefill(initialMatches, function () { // Ready for first spin }); } // --- Game Update Loop (not used, but required for LK) --- game.update = function () { // No per-frame logic needed };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,371 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+// Block class: represents a single block in the grid
+var Block = Container.expand(function () {
+ var self = Container.call(this);
+ // Properties
+ self.genus = 0; // 0-7
+ self.gridX = 0; // 0-4
+ self.gridY = 0; // 0-4
+ // Asset for the block
+ var blockAsset = null;
+ // Set genus and update asset
+ self.setGenus = function (genus) {
+ self.genus = genus;
+ // Remove old asset if present
+ if (blockAsset) {
+ self.removeChild(blockAsset);
+ }
+ // Each genus gets a unique color and shape
+ var colors = [0xf44336,
+ // red
+ 0x2196f3,
+ // blue
+ 0x4caf50,
+ // green
+ 0xffeb3b,
+ // yellow
+ 0x9c27b0,
+ // purple
+ 0xff9800,
+ // orange
+ 0x00bcd4,
+ // cyan
+ 0x8bc34a // light green
+ ];
+ var shapes = ['box', 'ellipse', 'box', 'ellipse', 'box', 'ellipse', 'box', 'ellipse'];
+ blockAsset = self.attachAsset('block_genus_' + genus, {
+ width: blockSize,
+ height: blockSize,
+ color: colors[genus],
+ shape: shapes[genus],
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ };
+ // Animate breaking
+ self.breakAnim = function (_onFinish) {
+ tween(self, {
+ scaleX: 1.3,
+ scaleY: 1.3,
+ alpha: 0
+ }, {
+ duration: 200,
+ easing: tween.cubicOut,
+ onFinish: function onFinish() {
+ self.scaleX = 1;
+ self.scaleY = 1;
+ self.alpha = 1;
+ if (_onFinish) _onFinish();
+ }
+ });
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x222222
+});
+
+/****
+* Game Code
+****/
+// --- Constants ---
+var gridSize = 5;
+var genusCount = 8;
+var blockSize = 260; // 5 blocks * 260 = 1300, fits well in 2048 width with margin
+var gridPadding = 24;
+var gridTotalSize = blockSize * gridSize + gridPadding * (gridSize - 1);
+var gridStartX = Math.floor((2048 - gridTotalSize) / 2) + blockSize / 2;
+var gridStartY = 400 + blockSize / 2; // leave space for Spin button
+// --- State ---
+var grid = []; // 2D array [y][x] of Block
+var score = 0;
+var isSpinning = false;
+// --- UI Elements ---
+var spinBtn = null;
+var scoreTxt = null;
+// --- Helper Functions ---
+// Generate a random genus (0-7)
+function randomGenus() {
+ return Math.floor(Math.random() * genusCount);
+}
+// Place a block at grid[x][y]
+function placeBlock(x, y, genus) {
+ var block = new Block();
+ block.setGenus(genus);
+ block.gridX = x;
+ block.gridY = y;
+ block.x = gridStartX + x * (blockSize + gridPadding);
+ block.y = gridStartY + y * (blockSize + gridPadding);
+ block.scaleX = 1;
+ block.scaleY = 1;
+ block.alpha = 1;
+ game.addChild(block);
+ return block;
+}
+// Remove a block from the game and grid
+function removeBlock(block) {
+ if (block) {
+ block.destroy();
+ }
+}
+// Fill the grid with random blocks, destroying old ones
+function fillGridRandom() {
+ // Remove old blocks
+ for (var y = 0; y < gridSize; y++) {
+ for (var x = 0; x < gridSize; x++) {
+ if (grid[y][x]) {
+ removeBlock(grid[y][x]);
+ }
+ }
+ }
+ // Fill with new blocks
+ for (var y = 0; y < gridSize; y++) {
+ for (var x = 0; x < gridSize; x++) {
+ var genus = randomGenus();
+ var block = placeBlock(x, y, genus);
+ grid[y][x] = block;
+ }
+ }
+}
+// Find all genus with 5 or more blocks, return array of {genus, blocks: [Block]}
+function findMatches() {
+ // Count blocks per genus
+ var genusBlocks = [];
+ for (var g = 0; g < genusCount; g++) {
+ genusBlocks[g] = [];
+ }
+ for (var y = 0; y < gridSize; y++) {
+ for (var x = 0; x < gridSize; x++) {
+ var block = grid[y][x];
+ genusBlocks[block.genus].push(block);
+ }
+ }
+ var matches = [];
+ for (var g = 0; g < genusCount; g++) {
+ if (genusBlocks[g].length >= 5) {
+ matches.push({
+ genus: g,
+ blocks: genusBlocks[g]
+ });
+ }
+ }
+ return matches;
+}
+// Break all matched blocks, animate, update score, and refill
+function breakAndRefill(matches, onFinish) {
+ if (matches.length === 0) {
+ if (onFinish) onFinish();
+ return;
+ }
+ var blocksToBreak = [];
+ for (var i = 0; i < matches.length; i++) {
+ blocksToBreak = blocksToBreak.concat(matches[i].blocks);
+ }
+ // Remove duplicates (shouldn't be any, but just in case)
+ var uniqueBlocks = [];
+ var seen = {};
+ for (var i = 0; i < blocksToBreak.length; i++) {
+ var b = blocksToBreak[i];
+ var key = b.gridX + ',' + b.gridY;
+ if (!seen[key]) {
+ uniqueBlocks.push(b);
+ seen[key] = true;
+ }
+ }
+ // Animate breaking
+ var brokenCount = 0;
+ for (var i = 0; i < uniqueBlocks.length; i++) {
+ (function (block) {
+ block.breakAnim(function () {
+ // Remove from grid
+ grid[block.gridY][block.gridX] = null;
+ removeBlock(block);
+ brokenCount++;
+ // When all blocks are broken, refill
+ if (brokenCount === uniqueBlocks.length) {
+ // Update score: 10 points per block, +10 per extra block above 5, * genus+1
+ for (var m = 0; m < matches.length; m++) {
+ var count = matches[m].blocks.length;
+ var genus = matches[m].genus;
+ score += (10 * count + 10 * Math.max(0, count - 5)) * (genus + 1);
+ }
+ updateScore();
+ // Refill broken blocks with new random blocks
+ for (var y = 0; y < gridSize; y++) {
+ for (var x = 0; x < gridSize; x++) {
+ if (!grid[y][x]) {
+ var genus = randomGenus();
+ var newBlock = placeBlock(x, y, genus);
+ grid[y][x] = newBlock;
+ }
+ }
+ }
+ // After refill, check for new matches recursively
+ var newMatches = findMatches();
+ if (newMatches.length > 0) {
+ breakAndRefill(newMatches, onFinish);
+ } else {
+ if (onFinish) onFinish();
+ }
+ }
+ });
+ })(uniqueBlocks[i]);
+ }
+}
+// Update score text and LK score
+function updateScore() {
+ LK.setScore(score);
+ scoreTxt.setText(score);
+}
+// Check if any matches are possible (i.e., if any genus has 5+ blocks)
+function hasMatches() {
+ var matches = findMatches();
+ return matches.length > 0;
+}
+// Handle Spin button press
+function onSpin() {
+ if (isSpinning) return;
+ isSpinning = true;
+ // Animate all blocks out (optional, for feedback)
+ for (var y = 0; y < gridSize; y++) {
+ for (var x = 0; x < gridSize; x++) {
+ var block = grid[y][x];
+ if (block) {
+ tween(block, {
+ scaleX: 0.7,
+ scaleY: 0.7,
+ alpha: 0.3
+ }, {
+ duration: 120,
+ easing: tween.cubicIn
+ });
+ }
+ }
+ }
+ // After short delay, refill grid
+ LK.setTimeout(function () {
+ fillGridRandom();
+ // After refill, check for matches and break recursively
+ var matches = findMatches();
+ if (matches.length > 0) {
+ breakAndRefill(matches, function () {
+ isSpinning = false;
+ // After all matches, check if any more matches are possible
+ if (!hasMatches()) {
+ // Game over
+ LK.effects.flashScreen(0x000000, 600);
+ LK.showGameOver();
+ }
+ });
+ } else {
+ isSpinning = false;
+ // If no matches at all, game over
+ LK.effects.flashScreen(0x000000, 600);
+ LK.showGameOver();
+ }
+ }, 180);
+}
+// --- UI Setup ---
+// Spin Button
+spinBtn = LK.getAsset('spinBtn', {
+ width: 520,
+ height: 160,
+ color: 0xffffff,
+ shape: 'ellipse',
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 / 2,
+ y: 180
+});
+game.addChild(spinBtn);
+// Spin Button Text
+var spinBtnTxt = new Text2('SPIN', {
+ size: 90,
+ fill: 0x222222
+});
+spinBtnTxt.anchor.set(0.5, 0.5);
+spinBtnTxt.x = spinBtn.x;
+spinBtnTxt.y = spinBtn.y;
+game.addChild(spinBtnTxt);
+// Score Text (below Spin button)
+scoreTxt = new Text2('0', {
+ size: 110,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+scoreTxt.x = 2048 / 2;
+scoreTxt.y = spinBtn.y + 120;
+LK.gui.top.addChild(scoreTxt);
+// --- Input Handling ---
+// Only allow pressing Spin button (not grid)
+spinBtn.down = function (x, y, obj) {
+ if (isSpinning) return;
+ onSpin();
+ // Animate button press
+ tween(spinBtn, {
+ scaleX: 0.92,
+ scaleY: 0.92
+ }, {
+ duration: 60,
+ easing: tween.cubicIn,
+ onFinish: function onFinish() {
+ tween(spinBtn, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 80,
+ easing: tween.cubicOut
+ });
+ }
+ });
+ tween(spinBtnTxt, {
+ scaleX: 0.92,
+ scaleY: 0.92
+ }, {
+ duration: 60,
+ easing: tween.cubicIn,
+ onFinish: function onFinish() {
+ tween(spinBtnTxt, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 80,
+ easing: tween.cubicOut
+ });
+ }
+ });
+};
+// --- Game Initialization ---
+// Initialize grid array
+for (var y = 0; y < gridSize; y++) {
+ grid[y] = [];
+ for (var x = 0; x < gridSize; x++) {
+ grid[y][x] = null;
+ }
+}
+// Start with a random grid and score 0
+score = 0;
+updateScore();
+fillGridRandom();
+// On game start, immediately break and refill if there are matches
+var initialMatches = findMatches();
+if (initialMatches.length > 0) {
+ breakAndRefill(initialMatches, function () {
+ // Ready for first spin
+ });
+}
+// --- Game Update Loop (not used, but required for LK) ---
+game.update = function () {
+ // No per-frame logic needed
+};
\ No newline at end of file
doner. 2d. High contrast. No shadows
ayran. 2d. High contrast. No shadows
lettuce. 2d. High contrast. No shadows
tomato. 2d. High contrast. No shadows
beef. 2d. High contrast. No shadows
ketchup. 2d. High contrast. No shadows
purple cabbage. 2d. High contrast. No shadows
mayonnaise. 2d. High contrast. No shadows
return symbol
doner kebab master. 2d. Like doner store background
Mustard Bottle, label is x2. In-Game asset. 2d. High contrast. No shadows
Mustard Bottle, label is x5. In-Game asset. 2d. High contrast. No shadows
Mustard Bottle, label is x10. In-Game asset. 2d. High contrast. No shadows
Mustard Bottle, label is x25. In-Game asset. 2d. High contrast. No shadows
Mustard Bottle, label is x50. In-Game asset. 2d. High contrast. No shadows
Mustard Bottle, label is x100. In-Game asset. 2d. High contrast. No shadows
crushed mustard bottle. In-Game asset. 2d. High contrast. No shadows