User prompt
başarım yeri en üste gelsin ve bütün başarımları içine alsın
User prompt
başarımlar şeyi yukarıya gelsin ve ön katmana gelsin
User prompt
yeni başarımlar ekle ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
haraket şeyleri dünyaya deymesin ve aşağıda olsun
User prompt
haraket şeyini ortaya getir
User prompt
uçma modunda blokların içinden geçme hatasını düzelt
User prompt
uçma modundaki hataları düzelt
User prompt
oyuna her zaman en tepeden başlasın
User prompt
oyuna elmas ve altın bloğu ekle
User prompt
dünyalar saçma saçma oluşmasın
User prompt
oyuna kum ekle ve kum yerçekiminden etkilensin
User prompt
oyuna uçma özelliği ekle
User prompt
karaktere yerçekimi ekle
User prompt
butonları ve yazıları büyüt
User prompt
kazandığmız başarımları görmek için bi menü yap ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.achievements = achievements;' Line Number: 524 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
oyuna başarımlar ekle ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
blok kırma sadece seçilen bloğu kırsın
User prompt
blok kırmaya efekt ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
blok menüsü bütün eşyaları içine alsın
User prompt
etrafındaki blokları kırsın
User prompt
blokları kırma ekle
User prompt
bloklar havada uçmasın
User prompt
dünyalar daha farklı ve güzel olsun
User prompt
her seferinde farklı bir dünya oluştur
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Block = Container.expand(function (blockType) { var self = Container.call(this); self.blockType = blockType; self.gridX = 0; self.gridY = 0; var blockGraphics = self.attachAsset(blockType, { anchorX: 0.5, anchorY: 0.5 }); // Add a subtle border effect blockGraphics.alpha = 0.9; self.setGridPosition = function (gridX, gridY) { self.gridX = gridX; self.gridY = gridY; self.x = gridX * GRID_SIZE + GRID_SIZE / 2 + GRID_OFFSET_X; self.y = gridY * GRID_SIZE + GRID_SIZE / 2 + GRID_OFFSET_Y; }; return self; }); var BlockSelectionMenu = Container.expand(function () { var self = Container.call(this); self.isVisible = false; // Background var bgGraphics = self.attachAsset('menuBg', { anchorX: 0.5, anchorY: 0.5, alpha: 0.9 }); // Title text var titleText = new Text2('Select Block Type', { size: 32, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0.5); titleText.x = 0; titleText.y = -200; self.addChild(titleText); // Close button var closeButton = self.attachAsset('closeButton', { anchorX: 0.5, anchorY: 0.5 }); closeButton.x = 280; closeButton.y = -200; // Block selection buttons self.menuButtons = []; var allBlockTypes = Object.keys(inventory); var buttonsPerRow = 3; var buttonSpacing = 160; for (var i = 0; i < allBlockTypes.length; i++) { var button = new Container(); // Button background var buttonBg = button.attachAsset('menuButton', { anchorX: 0.5, anchorY: 0.5, alpha: 0.8 }); // Block preview var blockPreview = button.attachAsset(allBlockTypes[i], { anchorX: 0.5, anchorY: 0.5, scaleX: 0.9, scaleY: 0.9 }); // Block name text var nameText = new Text2(allBlockTypes[i], { size: 18, fill: 0xFFFFFF }); nameText.anchor.set(0.5, 0); nameText.x = 0; nameText.y = 45; button.addChild(nameText); // Inventory count text var countText = new Text2(inventory[allBlockTypes[i]].toString(), { size: 16, fill: 0xFFDD44 }); countText.anchor.set(0.5, 0); countText.x = 0; countText.y = 65; button.addChild(countText); // Position button var col = i % buttonsPerRow; var row = Math.floor(i / buttonsPerRow); button.x = (col - 1) * buttonSpacing; button.y = row * buttonSpacing - 30; // Store button data button.blockType = allBlockTypes[i]; button.bgGraphics = buttonBg; button.countText = countText; // Button interaction button.down = function (x, y, obj) { this.bgGraphics.alpha = 1.0; selectedBlockType = this.blockType; updateToolbarSelection(); self.hide(); }; button.up = function (x, y, obj) { this.bgGraphics.alpha = 0.8; }; self.menuButtons.push(button); self.addChild(button); } // Close button interaction closeButton.down = function (x, y, obj) { closeButton.alpha = 0.7; self.hide(); }; closeButton.up = function (x, y, obj) { closeButton.alpha = 1.0; }; self.show = function () { self.isVisible = true; self.alpha = 0; self.visible = true; tween(self, { alpha: 1 }, { duration: 200 }); }; self.hide = function () { self.isVisible = false; tween(self, { alpha: 0 }, { duration: 200, onFinish: function onFinish() { self.visible = false; } }); }; self.updateInventoryCounts = function () { for (var i = 0; i < self.menuButtons.length; i++) { var button = self.menuButtons[i]; if (button.countText && button.blockType) { button.countText.setText(inventory[button.blockType].toString()); } } }; // Initially hidden self.visible = false; return self; }); var Character = Container.expand(function () { var self = Container.call(this); var characterGraphics = self.attachAsset('character', { anchorX: 0.5, anchorY: 0.5 }); self.gridX = 0; self.gridY = 0; self.targetX = 0; self.targetY = 0; self.isMoving = false; self.setGridPosition = function (gridX, gridY) { self.gridX = gridX; self.gridY = gridY; self.targetX = gridX * GRID_SIZE + GRID_SIZE / 2 + GRID_OFFSET_X; self.targetY = gridY * GRID_SIZE + GRID_SIZE / 2 + GRID_OFFSET_Y; if (!self.isMoving) { self.x = self.targetX; self.y = self.targetY; } }; self.moveToGrid = function (gridX, gridY) { if (self.isMoving) return false; if (!isValidGridPosition(gridX, gridY)) return false; // Check if there's a block at the target position if (grid[gridX][gridY] !== null) return false; self.isMoving = true; self.gridX = gridX; self.gridY = gridY; self.targetX = gridX * GRID_SIZE + GRID_SIZE / 2 + GRID_OFFSET_X; self.targetY = gridY * GRID_SIZE + GRID_SIZE / 2 + GRID_OFFSET_Y; tween(self, { x: self.targetX, y: self.targetY }, { duration: 200, onFinish: function onFinish() { self.isMoving = false; } }); return true; }; self.update = function () { // Character is always on top if (self.parent) { var parent = self.parent; parent.removeChild(self); parent.addChild(self); } }; return self; }); var ControlButton = Container.expand(function (direction) { var self = Container.call(this); self.direction = direction; var bgGraphics = self.attachAsset('controlBg', { anchorX: 0.5, anchorY: 0.5, alpha: 0.7 }); var arrowGraphics = self.attachAsset('arrow' + direction.charAt(0).toUpperCase() + direction.slice(1), { anchorX: 0.5, anchorY: 0.5, scaleX: 0.7, scaleY: 0.7 }); self.down = function (x, y, obj) { bgGraphics.alpha = 1.0; var newX = character.gridX; var newY = character.gridY; if (direction === 'up') newY--;else if (direction === 'down') newY++;else if (direction === 'left') newX--;else if (direction === 'right') newX++; character.moveToGrid(newX, newY); }; self.up = function (x, y, obj) { bgGraphics.alpha = 0.7; }; return self; }); var GridCell = Container.expand(function () { var self = Container.call(this); var cellGraphics = self.attachAsset('gridCell', { anchorX: 0.5, anchorY: 0.5, alpha: 0.1 }); self.gridX = 0; self.gridY = 0; self.isEmpty = true; self.setGridPosition = function (gridX, gridY) { self.gridX = gridX; self.gridY = gridY; self.x = gridX * GRID_SIZE + GRID_SIZE / 2 + GRID_OFFSET_X; self.y = gridY * GRID_SIZE + GRID_SIZE / 2 + GRID_OFFSET_Y; }; self.highlight = function () { cellGraphics.alpha = 0.3; }; self.unhighlight = function () { cellGraphics.alpha = 0.1; }; return self; }); var ToolbarButton = Container.expand(function (blockType) { var self = Container.call(this); self.blockType = blockType; self.isSelected = false; var bgGraphics = self.attachAsset('toolbarBg', { anchorX: 0.5, anchorY: 0.5, alpha: 0.8 }); var blockGraphics = self.attachAsset(blockType, { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8, scaleY: 0.8 }); var selectedBorder = self.attachAsset('selectedBorder', { anchorX: 0.5, anchorY: 0.5, alpha: 0 }); self.setSelected = function (selected) { self.isSelected = selected; selectedBorder.alpha = selected ? 0.8 : 0; bgGraphics.alpha = selected ? 1.0 : 0.8; }; self.down = function (x, y, obj) { selectedBlockType = self.blockType; updateToolbarSelection(); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ var GRID_SIZE = 80; var GRID_WIDTH = 20; var GRID_HEIGHT = 20; var GRID_OFFSET_X = (2048 - GRID_WIDTH * GRID_SIZE) / 2; var GRID_OFFSET_Y = 200; var selectedBlockType = 'dirt'; var blockTypes = ['dirt', 'stone', 'wood', 'grass', 'grassDark', 'grassLight']; var inventory = { dirt: 50, stone: 30, wood: 25, grass: 20, grassDark: 15, grassLight: 15 }; var grid = []; var placedBlocks = []; var toolbarButtons = []; var controlButtons = []; var pressTimer = null; var isLongPress = false; var pressStartTime = 0; var character = null; var blockSelectionMenu = null; var menuButton = null; // Initialize grid for (var x = 0; x < GRID_WIDTH; x++) { grid[x] = []; for (var y = 0; y < GRID_HEIGHT; y++) { grid[x][y] = null; var gridCell = new GridCell(); gridCell.setGridPosition(x, y); game.addChild(gridCell); } } // Initialize character at random position character = new Character(); var randomX = Math.floor(Math.random() * GRID_WIDTH); var randomY = Math.floor(Math.random() * GRID_HEIGHT); character.setGridPosition(randomX, randomY); game.addChild(character); // Create block selection menu blockSelectionMenu = new BlockSelectionMenu(); blockSelectionMenu.x = 1024; blockSelectionMenu.y = 1366; LK.gui.addChild(blockSelectionMenu); // Create menu button menuButton = new Container(); var menuBg = menuButton.attachAsset('toolbarBg', { anchorX: 0.5, anchorY: 0.5, alpha: 0.8 }); var menuText = new Text2('MENU', { size: 24, fill: 0xFFFFFF }); menuText.anchor.set(0.5, 0.5); menuText.x = 0; menuText.y = 0; menuButton.addChild(menuText); menuButton.x = 2048 - 80; menuButton.y = 150; menuButton.down = function (x, y, obj) { menuBg.alpha = 1.0; if (!blockSelectionMenu.isVisible) { blockSelectionMenu.show(); } }; menuButton.up = function (x, y, obj) { menuBg.alpha = 0.8; }; game.addChild(menuButton); // Create toolbar var toolbarY = 2732 - 120; var toolbarStartX = (2048 - blockTypes.length * 120) / 2; for (var i = 0; i < blockTypes.length; i++) { var button = new ToolbarButton(blockTypes[i]); button.x = toolbarStartX + i * 120 + 60; button.y = toolbarY; toolbarButtons.push(button); LK.gui.addChild(button); } // Create inventory display var inventoryTexts = {}; for (var i = 0; i < blockTypes.length; i++) { var blockType = blockTypes[i]; var inventoryText = new Text2(inventory[blockType].toString(), { size: 24, fill: 0xFFFFFF }); inventoryText.anchor.set(0.5, 0); inventoryText.x = toolbarStartX + i * 120 + 60; inventoryText.y = toolbarY + 60; inventoryTexts[blockType] = inventoryText; LK.gui.addChild(inventoryText); } // Create control buttons var controlButtonSize = 100; var controlPadding = 20; var controlCenterX = 150; var controlCenterY = GRID_OFFSET_Y + GRID_HEIGHT * GRID_SIZE + 150; var directions = [{ dir: 'up', x: 0, y: -1 }, { dir: 'down', x: 0, y: 1 }, { dir: 'left', x: -1, y: 0 }, { dir: 'right', x: 1, y: 0 }]; for (var i = 0; i < directions.length; i++) { var dirInfo = directions[i]; var button = new ControlButton(dirInfo.dir); button.x = controlCenterX + dirInfo.x * (controlButtonSize + controlPadding); button.y = controlCenterY + dirInfo.y * (controlButtonSize + controlPadding); controlButtons.push(button); game.addChild(button); } function updateToolbarSelection() { for (var i = 0; i < toolbarButtons.length; i++) { toolbarButtons[i].setSelected(toolbarButtons[i].blockType === selectedBlockType); } } function updateInventoryDisplay() { for (var blockType in inventoryTexts) { inventoryTexts[blockType].setText(inventory[blockType].toString()); } // Update block selection menu inventory counts if (blockSelectionMenu) { blockSelectionMenu.updateInventoryCounts(); } } function getGridPosition(worldX, worldY) { var gridX = Math.floor((worldX - GRID_OFFSET_X) / GRID_SIZE); var gridY = Math.floor((worldY - GRID_OFFSET_Y) / GRID_SIZE); return { x: gridX, y: gridY }; } function isValidGridPosition(gridX, gridY) { return gridX >= 0 && gridX < GRID_WIDTH && gridY >= 0 && gridY < GRID_HEIGHT; } function placeBlock(gridX, gridY) { if (!isValidGridPosition(gridX, gridY)) return false; if (grid[gridX][gridY] !== null) return false; if (inventory[selectedBlockType] <= 0) return false; // Don't place block on character position if (character && gridX === character.gridX && gridY === character.gridY) return false; var block = new Block(selectedBlockType); block.setGridPosition(gridX, gridY); game.addChild(block); grid[gridX][gridY] = block; placedBlocks.push(block); inventory[selectedBlockType]--; updateInventoryDisplay(); LK.getSound('place').play(); return true; } function removeBlock(gridX, gridY) { if (!isValidGridPosition(gridX, gridY)) return false; if (grid[gridX][gridY] === null) return false; var block = grid[gridX][gridY]; var blockType = block.blockType; // Create particle effects - multiple small pieces flying out for (var p = 0; p < 6; p++) { var particle = new Container(); var particleGraphics = particle.attachAsset(blockType, { anchorX: 0.5, anchorY: 0.5, scaleX: 0.3, scaleY: 0.3 }); particle.x = block.x; particle.y = block.y; game.addChild(particle); // Random direction for each particle var angle = p / 6 * Math.PI * 2 + (Math.random() - 0.5) * 0.5; var speed = 100 + Math.random() * 80; var targetX = particle.x + Math.cos(angle) * speed; var targetY = particle.y + Math.sin(angle) * speed; // Animate particle flying out and fading tween(particle, { x: targetX, y: targetY, scaleX: 0.1, scaleY: 0.1, alpha: 0, rotation: Math.random() * Math.PI * 2 }, { duration: 300 + Math.random() * 200, easing: tween.easeOut, onFinish: function onFinish() { particle.destroy(); } }); } // Add breaking animation with flash effect and rotation LK.effects.flashObject(block, 0xFFFFFF, 200); // Add screen shake effect for impact var originalX = game.x; var originalY = game.y; var shakeIntensity = 8; tween(game, { x: originalX + shakeIntensity }, { duration: 30, easing: tween.easeOut }); LK.setTimeout(function () { tween(game, { x: originalX - shakeIntensity }, { duration: 30, easing: tween.easeOut }); }, 30); LK.setTimeout(function () { tween(game, { x: originalX, y: originalY }, { duration: 40, easing: tween.easeOut }); }, 60); // Remove from placedBlocks array for (var i = placedBlocks.length - 1; i >= 0; i--) { if (placedBlocks[i] === block) { placedBlocks.splice(i, 1); break; } } // Animate block destruction with scaling and rotation tween(block, { scaleX: 0, scaleY: 0, alpha: 0, rotation: Math.PI * 0.5 }, { duration: 150, easing: tween.easeIn, onFinish: function onFinish() { block.destroy(); } }); grid[gridX][gridY] = null; inventory[blockType]++; updateInventoryDisplay(); LK.getSound('break').play(); return true; } // Initialize toolbar selection updateToolbarSelection(); updateInventoryDisplay(); game.down = function (x, y, obj) { var gridPos = getGridPosition(x, y); pressStartTime = LK.ticks; isLongPress = false; // Start long press timer for breaking blocks if (pressTimer) { LK.clearTimeout(pressTimer); } pressTimer = LK.setTimeout(function () { isLongPress = true; // Break blocks around character on long press var charX = character.gridX; var charY = character.gridY; var breakRadius = 1; // Break blocks in 3x3 area around character for (var dx = -breakRadius; dx <= breakRadius; dx++) { for (var dy = -breakRadius; dy <= breakRadius; dy++) { var targetX = charX + dx; var targetY = charY + dy; // Don't break the block the character is standing on if (dx === 0 && dy === 0) continue; if (isValidGridPosition(targetX, targetY) && grid[targetX][targetY] !== null) { // Add delay for cascading break effect var delay = (Math.abs(dx) + Math.abs(dy)) * 50; (function (x, y, delayTime) { LK.setTimeout(function () { if (isValidGridPosition(x, y) && grid[x][y] !== null) { removeBlock(x, y); } }, delayTime); })(targetX, targetY, delay); } } } }, 500); // 500ms long press }; game.up = function (x, y, obj) { // Clear the long press timer if (pressTimer) { LK.clearTimeout(pressTimer); pressTimer = null; } // If it wasn't a long press, place a block if (!isLongPress) { var gridPos = getGridPosition(x, y); if (isValidGridPosition(gridPos.x, gridPos.y)) { placeBlock(gridPos.x, gridPos.y); } } }; // Generate procedural world with biomes function generateWorld() { // Reset selected block type to dirt for generation selectedBlockType = 'dirt'; updateToolbarSelection(); // Define biomes var biomes = ['plains', 'desert', 'forest', 'mountains']; var currentBiome = biomes[Math.floor(Math.random() * biomes.length)]; var biomeTransition = Math.floor(GRID_WIDTH * 0.3) + Math.floor(Math.random() * Math.floor(GRID_WIDTH * 0.4)); var nextBiome = biomes[Math.floor(Math.random() * biomes.length)]; // Generate terrain layers with biome-specific features for (var x = 0; x < GRID_WIDTH; x++) { // Switch biome at transition point if (x >= biomeTransition) { currentBiome = nextBiome; } // Biome-specific height generation var baseHeight; var surfaceBlock = 'grass'; var treeChance = 0.15; var stoneChance = 0.1; var heightVariation = 4; if (currentBiome === 'plains') { baseHeight = Math.floor(GRID_HEIGHT * 0.75) + Math.floor(Math.random() * 3) - 1; surfaceBlock = 'grass'; treeChance = 0.08; stoneChance = 0.05; } else if (currentBiome === 'desert') { baseHeight = Math.floor(GRID_HEIGHT * 0.8) + Math.floor(Math.random() * 2); surfaceBlock = 'stone'; // Sandy appearance using stone treeChance = 0.02; // Very few trees stoneChance = 0.25; // More surface rocks heightVariation = 2; } else if (currentBiome === 'forest') { baseHeight = Math.floor(GRID_HEIGHT * 0.7) + Math.floor(Math.random() * 5) - 2; surfaceBlock = 'grass'; treeChance = 0.35; // Dense trees stoneChance = 0.08; heightVariation = 6; } else if (currentBiome === 'mountains') { // Create mountain peaks with more dramatic height changes var mountainPeak = Math.sin(x / GRID_WIDTH * Math.PI * 2) * 6; baseHeight = Math.floor(GRID_HEIGHT * 0.5) + Math.floor(mountainPeak) + Math.floor(Math.random() * 4) - 2; surfaceBlock = 'stone'; // Rocky surface treeChance = 0.05; // Few trees at high altitude stoneChance = 0.3; // Very rocky heightVariation = 8; } // Ensure baseHeight is within bounds baseHeight = Math.max(1, Math.min(baseHeight, GRID_HEIGHT - 3)); // Place surface layer if (baseHeight >= 0 && baseHeight < GRID_HEIGHT) { selectedBlockType = surfaceBlock; placeBlock(x, baseHeight); } // Place sub-surface layers with biome variation selectedBlockType = 'dirt'; var dirtLayers = currentBiome === 'desert' ? 1 : currentBiome === 'mountains' ? 2 : 3; for (var y = baseHeight + 1; y < Math.min(baseHeight + dirtLayers + 1, GRID_HEIGHT); y++) { if (Math.random() < (currentBiome === 'desert' ? 0.6 : 0.8)) { placeBlock(x, y); } } // Place stone in deeper layers selectedBlockType = 'stone'; var stoneStartDepth = baseHeight + dirtLayers + 1; for (var y = stoneStartDepth; y < GRID_HEIGHT; y++) { var stoneProb = currentBiome === 'mountains' ? 0.85 : currentBiome === 'desert' ? 0.7 : 0.6; if (Math.random() < stoneProb) { placeBlock(x, y); } } // Add biome-specific vegetation if (Math.random() < treeChance && baseHeight > 2) { selectedBlockType = 'wood'; var treeHeight; if (currentBiome === 'forest') { treeHeight = Math.floor(Math.random() * 5) + 3; // Tall trees } else if (currentBiome === 'desert') { treeHeight = Math.floor(Math.random() * 2) + 1; // Cacti/small plants } else { treeHeight = Math.floor(Math.random() * 3) + 2; // Normal trees } for (var i = 0; i < treeHeight; i++) { var treeY = baseHeight - i - 1; if (treeY >= 0) { placeBlock(x, treeY); } } } // Add biome-specific surface features if (Math.random() < stoneChance && baseHeight > 0) { selectedBlockType = 'stone'; placeBlock(x, baseHeight - 1); } // Add special biome features if (currentBiome === 'forest' && Math.random() < 0.1) { // Dense undergrowth selectedBlockType = 'grass'; if (baseHeight > 1) { placeBlock(x, baseHeight - 1); } } else if (currentBiome === 'mountains' && Math.random() < 0.15) { // Stone outcroppings selectedBlockType = 'stone'; for (var i = 0; i < 2; i++) { var rockY = baseHeight - i - 1; if (rockY >= 0 && Math.random() < 0.7) { placeBlock(x, rockY); } } } else if (currentBiome === 'desert' && Math.random() < 0.05) { // Rare oasis spots selectedBlockType = 'grass'; if (baseHeight > 0) { placeBlock(x, baseHeight - 1); } } } // Add scattered resources with biome preferences var resourceCount = currentBiome === 'mountains' ? 30 : currentBiome === 'forest' ? 25 : 20; for (var i = 0; i < resourceCount; i++) { var randX = Math.floor(Math.random() * GRID_WIDTH); var randY = Math.floor(Math.random() * GRID_HEIGHT); if (grid[randX][randY] === null) { var resourceType; // Biome-specific resource distribution if (currentBiome === 'forest') { resourceType = Math.random() < 0.5 ? 'wood' : blockTypes[Math.floor(Math.random() * blockTypes.length)]; } else if (currentBiome === 'mountains') { resourceType = Math.random() < 0.6 ? 'stone' : blockTypes[Math.floor(Math.random() * blockTypes.length)]; } else if (currentBiome === 'desert') { resourceType = Math.random() < 0.4 ? 'stone' : blockTypes[Math.floor(Math.random() * blockTypes.length)]; } else { resourceType = blockTypes[Math.floor(Math.random() * blockTypes.length)]; } selectedBlockType = resourceType; placeBlock(randX, randY); } } // Create caves and caverns for more interesting exploration for (var caveCount = 0; caveCount < 3; caveCount++) { var caveX = Math.floor(Math.random() * (GRID_WIDTH - 6)) + 3; var caveY = Math.floor(Math.random() * (GRID_HEIGHT - 10)) + 5; var caveSize = Math.floor(Math.random() * 3) + 2; for (var cx = caveX - caveSize; cx <= caveX + caveSize; cx++) { for (var cy = caveY - caveSize; cy <= caveY + caveSize; cy++) { if (isValidGridPosition(cx, cy) && grid[cx][cy] !== null) { var distance = Math.sqrt((cx - caveX) * (cx - caveX) + (cy - caveY) * (cy - caveY)); if (distance <= caveSize && Math.random() < 0.7) { var block = grid[cx][cy]; if (block) { block.destroy(); grid[cx][cy] = null; // Remove from placedBlocks array for (var j = placedBlocks.length - 1; j >= 0; j--) { if (placedBlocks[j] === block) { placedBlocks.splice(j, 1); break; } } } } } } } } // Reset to dirt selection selectedBlockType = 'dirt'; updateToolbarSelection(); } // Generate the world after a short delay LK.setTimeout(function () { generateWorld(); }, 500); function applyGravity() { var blocksToMove = []; // Check all blocks from bottom to top for (var y = GRID_HEIGHT - 2; y >= 0; y--) { for (var x = 0; x < GRID_WIDTH; x++) { var block = grid[x][y]; if (block !== null) { // Check if block has support below var hasSupport = false; for (var checkY = y + 1; checkY < GRID_HEIGHT; checkY++) { if (grid[x][checkY] !== null) { hasSupport = true; break; } } // If no support, mark for falling if (!hasSupport) { var fallY = y; // Find where it should fall to for (var targetY = y + 1; targetY < GRID_HEIGHT; targetY++) { if (grid[x][targetY] !== null) { break; } fallY = targetY; } if (fallY !== y) { blocksToMove.push({ block: block, fromX: x, fromY: y, toX: x, toY: fallY }); } } } } } // Move blocks that need to fall for (var i = 0; i < blocksToMove.length; i++) { var moveData = blocksToMove[i]; var block = moveData.block; // Clear old position grid[moveData.fromX][moveData.fromY] = null; // Set new position grid[moveData.toX][moveData.toY] = block; block.setGridPosition(moveData.toX, moveData.toY); } } game.update = function () { // Apply gravity every few ticks to make blocks fall if (LK.ticks % 10 === 0) { applyGravity(); } // Replenish inventory slowly over time if (LK.ticks % 600 === 0) { // Every 10 seconds for (var blockType in inventory) { if (inventory[blockType] < 50) { inventory[blockType]++; } } updateInventoryDisplay(); } };
===================================================================
--- original.js
+++ change.js
@@ -467,24 +467,86 @@
if (!isValidGridPosition(gridX, gridY)) return false;
if (grid[gridX][gridY] === null) return false;
var block = grid[gridX][gridY];
var blockType = block.blockType;
- // Add breaking animation with flash effect
+ // Create particle effects - multiple small pieces flying out
+ for (var p = 0; p < 6; p++) {
+ var particle = new Container();
+ var particleGraphics = particle.attachAsset(blockType, {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.3,
+ scaleY: 0.3
+ });
+ particle.x = block.x;
+ particle.y = block.y;
+ game.addChild(particle);
+ // Random direction for each particle
+ var angle = p / 6 * Math.PI * 2 + (Math.random() - 0.5) * 0.5;
+ var speed = 100 + Math.random() * 80;
+ var targetX = particle.x + Math.cos(angle) * speed;
+ var targetY = particle.y + Math.sin(angle) * speed;
+ // Animate particle flying out and fading
+ tween(particle, {
+ x: targetX,
+ y: targetY,
+ scaleX: 0.1,
+ scaleY: 0.1,
+ alpha: 0,
+ rotation: Math.random() * Math.PI * 2
+ }, {
+ duration: 300 + Math.random() * 200,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ particle.destroy();
+ }
+ });
+ }
+ // Add breaking animation with flash effect and rotation
LK.effects.flashObject(block, 0xFFFFFF, 200);
+ // Add screen shake effect for impact
+ var originalX = game.x;
+ var originalY = game.y;
+ var shakeIntensity = 8;
+ tween(game, {
+ x: originalX + shakeIntensity
+ }, {
+ duration: 30,
+ easing: tween.easeOut
+ });
+ LK.setTimeout(function () {
+ tween(game, {
+ x: originalX - shakeIntensity
+ }, {
+ duration: 30,
+ easing: tween.easeOut
+ });
+ }, 30);
+ LK.setTimeout(function () {
+ tween(game, {
+ x: originalX,
+ y: originalY
+ }, {
+ duration: 40,
+ easing: tween.easeOut
+ });
+ }, 60);
// Remove from placedBlocks array
for (var i = placedBlocks.length - 1; i >= 0; i--) {
if (placedBlocks[i] === block) {
placedBlocks.splice(i, 1);
break;
}
}
- // Animate block destruction with scaling
+ // Animate block destruction with scaling and rotation
tween(block, {
scaleX: 0,
scaleY: 0,
- alpha: 0
+ alpha: 0,
+ rotation: Math.PI * 0.5
}, {
duration: 150,
+ easing: tween.easeIn,
onFinish: function onFinish() {
block.destroy();
}
});
@@ -517,9 +579,17 @@
var targetY = charY + dy;
// Don't break the block the character is standing on
if (dx === 0 && dy === 0) continue;
if (isValidGridPosition(targetX, targetY) && grid[targetX][targetY] !== null) {
- removeBlock(targetX, targetY);
+ // Add delay for cascading break effect
+ var delay = (Math.abs(dx) + Math.abs(dy)) * 50;
+ (function (x, y, delayTime) {
+ LK.setTimeout(function () {
+ if (isValidGridPosition(x, y) && grid[x][y] !== null) {
+ removeBlock(x, y);
+ }
+ }, delayTime);
+ })(targetX, targetY, delay);
}
}
}
}, 500); // 500ms long press