User prompt
Bloklar kısmındaki odun bloğunu kaldır
User prompt
Bloklar kısmındaki bir bloğu seçip envanterdeki bir bloğa dokunduğumuzda bloklar minecraft'taki gibi yer değiştirsin. Envantere geçen bloğu kullanalım
User prompt
Bloğu değiştirmek için minecrafttaki mekaniği kullan
User prompt
Bloklar kısmı 1 tuşa basınca aynı minecraft'taki gibi bir bölmede çıksın. Envanter 4 slot olsun. Değişen blok bloklar kısmına gitsin
User prompt
Oyuna bloklar kısmı ekle. Oraya dokunduğumuzda envanterimizde olmayan Demir, Bloğu, Odun Bloğu, Elmas Bloğunu envanterimize ekleyebilelim ve kullanabilelim
User prompt
Tüm blokları silme tuşu ekle
User prompt
çift tıklayarak bir alan belirleyebilelim. O yerdeki tüm blokları silebilelim veya bir bloktan seçilen her yere ekleyebilelim
User prompt
Oyuna bloklar katalogu ekle. Oraya farklı bloklar ekle . O blokları envantere ekleyebilelim
Code edit (1 edits merged)
Please save this source code
User prompt
BlockCraft Builder
Initial prompt
Minecraft 2
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Block = Container.expand(function (blockType) {
var self = Container.call(this);
self.blockType = blockType;
// Create the block visual based on type
var blockAsset = 'grassBlock';
if (blockType === 'stone') blockAsset = 'stoneBlock';else if (blockType === 'wood') blockAsset = 'woodBlock';else if (blockType === 'special') blockAsset = 'specialBlock';
var blockGraphics = self.attachAsset(blockAsset, {
anchorX: 0.5,
anchorY: 0.5
});
// Add isometric depth effect
var shadowGraphics = self.attachAsset(blockAsset, {
anchorX: 0.5,
anchorY: 0.5,
x: 4,
y: 4,
alpha: 0.3
});
// Animate block placement
self.animatePlace = function () {
blockGraphics.scaleX = 0.1;
blockGraphics.scaleY = 0.1;
tween(blockGraphics, {
scaleX: 1,
scaleY: 1
}, {
duration: 200,
easing: tween.bounceOut
});
};
// Animate block removal
self.animateRemove = function () {
tween(blockGraphics, {
scaleX: 0.1,
scaleY: 0.1,
alpha: 0
}, {
duration: 150,
easing: tween.easeIn,
onFinish: function onFinish() {
self.destroy();
}
});
};
return self;
});
var GridSlot = Container.expand(function (gridX, gridY) {
var self = Container.call(this);
self.gridX = gridX;
self.gridY = gridY;
self.hasBlock = false;
self.blockObj = null;
// Background grid visual
var slotGraphics = self.attachAsset('gridSlot', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.1
});
self.placeBlock = function (blockType) {
if (self.hasBlock) return false;
self.blockObj = new Block(blockType);
self.addChild(self.blockObj);
self.hasBlock = true;
self.blockObj.animatePlace();
LK.getSound('placeBlock').play();
return true;
};
self.removeBlock = function () {
if (!self.hasBlock) return false;
self.blockObj.animateRemove();
self.hasBlock = false;
self.blockObj = null;
LK.getSound('removeBlock').play();
return true;
};
self.down = function (x, y, obj) {
if (currentSelectedBlock) {
if (!self.hasBlock) {
self.placeBlock(currentSelectedBlock);
} else {
self.removeBlock();
}
}
};
return self;
});
var InventorySlot = Container.expand(function (blockType, index) {
var self = Container.call(this);
self.blockType = blockType;
self.index = index;
self.isSelected = false;
// Slot background
var slotBg = self.attachAsset('inventorySlot', {
anchorX: 0.5,
anchorY: 0.5
});
// Selected indicator
var selectedBg = self.attachAsset('inventorySelected', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0
});
// Block preview
var blockAsset = 'grassBlock';
if (blockType === 'stone') blockAsset = 'stoneBlock';else if (blockType === 'wood') blockAsset = 'woodBlock';else if (blockType === 'special') blockAsset = 'specialBlock';
var blockPreview = self.attachAsset(blockAsset, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.7,
scaleY: 0.7
});
self.setSelected = function (selected) {
self.isSelected = selected;
selectedBg.alpha = selected ? 1 : 0;
if (selected) {
tween(blockPreview, {
scaleX: 0.8,
scaleY: 0.8
}, {
duration: 150
});
} else {
tween(blockPreview, {
scaleX: 0.7,
scaleY: 0.7
}, {
duration: 150
});
}
};
self.down = function (x, y, obj) {
selectInventorySlot(self.index);
LK.getSound('selectBlock').play();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Block assets with different colors and appearances
// Sound effects
var gridSize = 20;
var blockSize = 80;
var gridOffsetX = 1024;
var gridOffsetY = 400;
var currentSelectedBlock = 'grass';
// Game state
var gameGrid = [];
var inventorySlots = [];
var blockTypes = ['grass', 'stone', 'wood', 'special'];
// Initialize grid
for (var x = 0; x < gridSize; x++) {
gameGrid[x] = [];
for (var y = 0; y < gridSize; y++) {
var slot = new GridSlot(x, y);
// Calculate isometric position
var isoX = (x - y) * (blockSize / 2);
var isoY = (x + y) * (blockSize / 4);
slot.x = gridOffsetX + isoX;
slot.y = gridOffsetY + isoY;
gameGrid[x][y] = slot;
game.addChild(slot);
}
}
// Create inventory UI
var inventoryContainer = new Container();
inventoryContainer.x = 1024;
inventoryContainer.y = 2500;
game.addChild(inventoryContainer);
// Create inventory slots
for (var i = 0; i < blockTypes.length; i++) {
var invSlot = new InventorySlot(blockTypes[i], i);
invSlot.x = (i - (blockTypes.length - 1) / 2) * 120;
invSlot.y = 0;
inventorySlots.push(invSlot);
inventoryContainer.addChild(invSlot);
}
// Create clear all button
var clearAllButton = new Container();
var clearButtonBg = clearAllButton.attachAsset('clearAllButton', {
anchorX: 0.5,
anchorY: 0.5
});
var clearButtonText = new Text2('CLEAR\nALL', {
size: 24,
fill: '#ffffff'
});
clearButtonText.anchor.set(0.5, 0.5);
clearAllButton.addChild(clearButtonText);
clearAllButton.x = (blockTypes.length / 2 + 1) * 120;
clearAllButton.y = 0;
inventoryContainer.addChild(clearAllButton);
clearAllButton.down = function (x, y, obj) {
// Clear all blocks from grid
for (var x = 0; x < gridSize; x++) {
for (var y = 0; y < gridSize; y++) {
if (gameGrid[x][y].hasBlock) {
gameGrid[x][y].removeBlock();
}
}
}
// Save the cleared state
saveGame();
};
// Select first inventory slot by default
inventorySlots[0].setSelected(true);
// Title text
var titleText = new Text2('BlockCraft Builder', {
size: 80,
fill: '#ffffff'
});
titleText.anchor.set(0.5, 0);
LK.gui.top.addChild(titleText);
titleText.y = 50;
// Instructions text
var instructionsText = new Text2('Tap blocks to select, then tap grid to place/remove', {
size: 40,
fill: '#ffffff'
});
instructionsText.anchor.set(0.5, 0);
LK.gui.top.addChild(instructionsText);
instructionsText.y = 150;
// Functions
function selectInventorySlot(index) {
// Deselect all slots
for (var i = 0; i < inventorySlots.length; i++) {
inventorySlots[i].setSelected(false);
}
// Select the clicked slot
inventorySlots[index].setSelected(true);
currentSelectedBlock = blockTypes[index];
}
// Load saved game state
var savedGrid = storage.savedGrid || {};
for (var x = 0; x < gridSize; x++) {
for (var y = 0; y < gridSize; y++) {
var key = x + '_' + y;
if (savedGrid[key]) {
gameGrid[x][y].placeBlock(savedGrid[key]);
}
}
}
// Auto-save function
function saveGame() {
var saveData = {};
for (var x = 0; x < gridSize; x++) {
for (var y = 0; y < gridSize; y++) {
if (gameGrid[x][y].hasBlock) {
var key = x + '_' + y;
saveData[key] = gameGrid[x][y].blockObj.blockType;
}
}
}
storage.savedGrid = saveData;
}
// Auto-save timer
var saveTimer = 0;
game.update = function () {
saveTimer++;
// Auto-save every 3 seconds (180 ticks at 60fps)
if (saveTimer >= 180) {
saveGame();
saveTimer = 0;
}
}; ===================================================================
--- original.js
+++ change.js
@@ -82,38 +82,15 @@
LK.getSound('removeBlock').play();
return true;
};
self.down = function (x, y, obj) {
- var currentTime = Date.now();
- // Check for double-tap
- if (lastTapSlot === self && currentTime - lastTapTime < doubleTapDelay) {
- // Double-tap detected - start area selection
- if (areaFillMode) {
- // Exit area fill mode
- exitAreaFillMode();
+ if (currentSelectedBlock) {
+ if (!self.hasBlock) {
+ self.placeBlock(currentSelectedBlock);
} else {
- // Enter area fill mode
- enterAreaFillMode(self);
+ self.removeBlock();
}
- return;
}
- // Single tap logic
- if (areaFillMode) {
- // In area fill mode, add/remove from selected area
- toggleAreaSelection(self);
- } else {
- // Normal block placement/removal
- if (currentSelectedBlock) {
- if (!self.hasBlock) {
- self.placeBlock(currentSelectedBlock);
- } else {
- self.removeBlock();
- }
- }
- }
- // Update last tap info
- lastTapTime = currentTime;
- lastTapSlot = self;
};
return self;
});
var InventorySlot = Container.expand(function (blockType, index) {
@@ -214,8 +191,35 @@
invSlot.y = 0;
inventorySlots.push(invSlot);
inventoryContainer.addChild(invSlot);
}
+// Create clear all button
+var clearAllButton = new Container();
+var clearButtonBg = clearAllButton.attachAsset('clearAllButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+});
+var clearButtonText = new Text2('CLEAR\nALL', {
+ size: 24,
+ fill: '#ffffff'
+});
+clearButtonText.anchor.set(0.5, 0.5);
+clearAllButton.addChild(clearButtonText);
+clearAllButton.x = (blockTypes.length / 2 + 1) * 120;
+clearAllButton.y = 0;
+inventoryContainer.addChild(clearAllButton);
+clearAllButton.down = function (x, y, obj) {
+ // Clear all blocks from grid
+ for (var x = 0; x < gridSize; x++) {
+ for (var y = 0; y < gridSize; y++) {
+ if (gameGrid[x][y].hasBlock) {
+ gameGrid[x][y].removeBlock();
+ }
+ }
+ }
+ // Save the cleared state
+ saveGame();
+};
// Select first inventory slot by default
inventorySlots[0].setSelected(true);
// Title text
var titleText = new Text2('BlockCraft Builder', {
@@ -265,106 +269,14 @@
}
}
storage.savedGrid = saveData;
}
-// Area selection functions
-function enterAreaFillMode(startSlot) {
- areaFillMode = true;
- if (startSlot.hasBlock) {
- areaFillBlockType = startSlot.blockObj.blockType;
- } else {
- areaFillBlockType = currentSelectedBlock;
- }
- selectedArea = [startSlot];
- updateAreaVisuals();
- updateInstructions('Area mode: Tap slots to select, double-tap to apply');
-}
-function exitAreaFillMode() {
- areaFillMode = false;
- selectedArea = [];
- areaFillBlockType = null;
- clearAreaVisuals();
- updateInstructions('Tap blocks to select, then tap grid to place/remove');
-}
-function toggleAreaSelection(slot) {
- var index = selectedArea.indexOf(slot);
- if (index > -1) {
- selectedArea.splice(index, 1);
- } else {
- selectedArea.push(slot);
- }
- updateAreaVisuals();
-}
-function updateAreaVisuals() {
- // Clear all previous selections
- for (var x = 0; x < gridSize; x++) {
- for (var y = 0; y < gridSize; y++) {
- var slot = gameGrid[x][y];
- if (slot.selectionIndicator) {
- slot.selectionIndicator.destroy();
- slot.selectionIndicator = null;
- }
- }
- }
- // Add selection indicators to selected slots
- for (var i = 0; i < selectedArea.length; i++) {
- var slot = selectedArea[i];
- slot.selectionIndicator = slot.attachAsset('selectedSlot', {
- anchorX: 0.5,
- anchorY: 0.5,
- alpha: 0.7
- });
- }
-}
-function clearAreaVisuals() {
- for (var x = 0; x < gridSize; x++) {
- for (var y = 0; y < gridSize; y++) {
- var slot = gameGrid[x][y];
- if (slot.selectionIndicator) {
- slot.selectionIndicator.destroy();
- slot.selectionIndicator = null;
- }
- }
- }
-}
-function applyAreaFill() {
- if (!areaFillMode || selectedArea.length === 0) return;
- for (var i = 0; i < selectedArea.length; i++) {
- var slot = selectedArea[i];
- if (areaFillBlockType === 'remove') {
- slot.removeBlock();
- } else {
- if (slot.hasBlock) {
- slot.removeBlock();
- }
- slot.placeBlock(areaFillBlockType);
- }
- }
- exitAreaFillMode();
-}
-function updateInstructions(text) {
- instructionsText.setText(text);
-}
// Auto-save timer
var saveTimer = 0;
-var lastTapTime = 0;
-var lastTapSlot = null;
-var doubleTapDelay = 300; // milliseconds
-var areaFillMode = false;
-var areaFillBlockType = null;
-var selectedArea = [];
game.update = function () {
saveTimer++;
// Auto-save every 3 seconds (180 ticks at 60fps)
if (saveTimer >= 180) {
saveGame();
saveTimer = 0;
}
- // Check for double-tap to apply area fill
- if (areaFillMode && selectedArea.length > 0) {
- var currentTime = Date.now();
- if (lastTapSlot && selectedArea.indexOf(lastTapSlot) > -1 && currentTime - lastTapTime < doubleTapDelay) {
- // Double-tap on selected area - apply fill
- applyAreaFill();
- }
- }
};
\ No newline at end of file
minecraft taş blok. In-Game asset. High contrast. No shadows
minecraft tahta blok. In-Game asset. High contrast. No shadows
Minecraft Demir Bloğu. 2D
Minecraft Elmas bloğu. In-Game asset. High contrast. No shadows
Minecraft çim bloğu. In-Game asset. High contrast. No shadows
Minecraft yanma efekti. In-Game asset. 2d. High contrast. No shadows
Minecraft su bloğu. In-Game asset. High contrast. No shadows
Minecraft obsidyen bloğu. mor renkli. In-Game asset. High contrast. No shadows