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
****/
// Sound effects
// Block assets with different colors and appearances
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);
}
// 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
@@ -1,6 +1,255 @@
-/****
+/****
+* 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: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87CEEB
+});
+
+/****
+* Game Code
+****/
+// Sound effects
+// Block assets with different colors and appearances
+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);
+}
+// 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;
+ }
+};
\ 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