User prompt
oyunda 1 buçuk dakika geçirdiğimizde oyun bitmeli
User prompt
yukarıdaki bölümde otomarik olarak random bir yerde bir bilock oluşmalı
User prompt
buttona tıklayınca oyun game over olmalı
User prompt
buttona tıklayınca oyun en baştan başlaması gerekiyor
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'target')' in or related to this line: 'if (obj.event.target === button) {' Line Number: 153
User prompt
buttona tıklayınca oyun sona ermeli
User prompt
sağ üstte bulunan buttonun kodunu geri yaz
User prompt
block koymakodu silinmiş olmalı birdaha yaz
User prompt
vazgeçtim yazdığın kodları geri al
User prompt
Please fix the bug: 'Cannot set properties of null (setting 'x')' in or related to this line: 'currentBlock.x = Math.floor(Math.random() * BOARD_WIDTH);' Line Number: 140
User prompt
otomatik olarak yukarda doğan taşlardan en az 25 tane olmalı
User prompt
buttona tıklayınca oyunu enbaştan açmalı
User prompt
button sağ üstteki köşede bulunmalı
User prompt
oyun başladığında üst köşede bulunan bir button asseti yaparmısın
User prompt
Please fix the bug: 'Cannot set properties of null (setting 'x')' in or related to this line: 'currentBlock.x = Math.floor(Math.random() * BOARD_WIDTH);' Line Number: 121
User prompt
oyun başladığın da otomatik olarak yularıdaki bölümün rondom yerinde olan bir block asseti oluştur
User prompt
Oyunun yüzde 20'si dolduğunda oyun bitmesi lazım
User prompt
arkaplanı tamamen kaplayacak bir arkaplan asseti yaparmısın
User prompt
10 block yan yana gelince patlarlaması lazım
Initial prompt
block blast
===================================================================
--- original.js
+++ change.js
@@ -1,31 +1,62 @@
-/****
+/****
* Classes
-****/
+****/
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Block class representing each block in the game
var Block = Container.expand(function () {
- var self = Container.call(this);
- var blockGraphics = self.attachAsset('block', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.update = function () {
- // Update logic for blocks if needed
- };
+ var self = Container.call(this);
+ var blockGraphics = self.attachAsset('block', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.update = function () {
+ // Update logic for blocks if needed
+ };
});
-/****
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000 //Init game with black background
+ backgroundColor: 0x000000 //Init game with black background
});
-/****
+/****
* Game Code
-****/
+****/
+// Function to check and remove blocks when 10 are aligned horizontally
+function checkAndRemoveAlignedBlocks() {
+ for (var j = 0; j < boardGrid[0].length; j++) {
+ var consecutiveBlocks = 0;
+ for (var i = 0; i < boardGrid.length; i++) {
+ if (boardGrid[i][j] !== null) {
+ consecutiveBlocks++;
+ if (consecutiveBlocks >= 10) {
+ // Remove the aligned blocks
+ for (var k = i; k > i - 10; k--) {
+ if (boardGrid[k][j] !== null) {
+ boardGrid[k][j].destroy();
+ boardGrid[k][j] = null;
+ }
+ }
+ // Shift blocks above down
+ for (var k = i - 10; k >= 0; k--) {
+ if (boardGrid[k][j] !== null) {
+ boardGrid[k + 10][j] = boardGrid[k][j];
+ boardGrid[k][j] = null;
+ boardGrid[k + 10][j].y += BLOCK_SIZE * 10;
+ }
+ }
+ consecutiveBlocks = 0; // Reset counter after removal
+ }
+ } else {
+ consecutiveBlocks = 0; // Reset counter if a gap is found
+ }
+ }
+ }
+}
// Constants
var BOARD_WIDTH = 2048;
var BOARD_HEIGHT = 2000; // Area above where blocks are placed
var BLOCK_SIZE = 100; // Size of each block
@@ -36,76 +67,79 @@
var isGameOver = false;
// Create a grid for the board
var boardGrid = [];
for (var i = 0; i < BOARD_WIDTH / BLOCK_SIZE; i++) {
- boardGrid[i] = [];
- for (var j = 0; j < BOARD_HEIGHT / BLOCK_SIZE; j++) {
- boardGrid[i][j] = null;
- }
+ boardGrid[i] = [];
+ for (var j = 0; j < BOARD_HEIGHT / BLOCK_SIZE; j++) {
+ boardGrid[i][j] = null;
+ }
}
// Function to check if the board is filled beyond the limit
function checkBoardFilled() {
- var filledCount = 0;
- for (var i = 0; i < boardGrid.length; i++) {
- for (var j = 0; j < boardGrid[i].length; j++) {
- if (boardGrid[i][j] !== null) {
- filledCount++;
- }
- }
- }
- return filledCount >= MAX_BLOCKS;
+ var filledCount = 0;
+ for (var i = 0; i < boardGrid.length; i++) {
+ for (var j = 0; j < boardGrid[i].length; j++) {
+ if (boardGrid[i][j] !== null) {
+ filledCount++;
+ }
+ }
+ }
+ return filledCount >= MAX_BLOCKS;
}
// Function to place a block on the board
function placeBlock(x, y) {
- var gridX = Math.floor(x / BLOCK_SIZE);
- var gridY = Math.floor(y / BLOCK_SIZE);
- if (boardGrid[gridX][gridY] === null) {
- boardGrid[gridX][gridY] = currentBlock;
- currentBlock.x = gridX * BLOCK_SIZE + BLOCK_SIZE / 2;
- currentBlock.y = gridY * BLOCK_SIZE + BLOCK_SIZE / 2;
- currentBlock = null;
- }
+ var gridX = Math.floor(x / BLOCK_SIZE);
+ var gridY = Math.floor(y / BLOCK_SIZE);
+ if (boardGrid[gridX][gridY] === null) {
+ boardGrid[gridX][gridY] = currentBlock;
+ currentBlock.x = gridX * BLOCK_SIZE + BLOCK_SIZE / 2;
+ currentBlock.y = gridY * BLOCK_SIZE + BLOCK_SIZE / 2;
+ currentBlock = null;
+ }
}
// Function to create a new block at the bottom
function createNewBlock() {
- currentBlock = new Block();
- currentBlock.x = BOARD_WIDTH / 2;
- currentBlock.y = BOARD_HEIGHT + BLOCK_SIZE / 2;
- game.addChild(currentBlock);
+ currentBlock = new Block();
+ currentBlock.x = BOARD_WIDTH / 2;
+ currentBlock.y = BOARD_HEIGHT + BLOCK_SIZE / 2;
+ game.addChild(currentBlock);
}
// Initialize the first block
createNewBlock();
// Handle game updates
game.update = function () {
- if (isGameOver) return;
- // Check if the board is filled
- if (checkBoardFilled()) {
- isGameOver = true;
- LK.showGameOver();
- return;
- }
- // Move the current block upwards
- if (currentBlock) {
- currentBlock.y -= 5; // Move speed
- if (currentBlock.y <= BOARD_HEIGHT) {
- placeBlock(currentBlock.x, currentBlock.y);
- createNewBlock();
- }
- }
+ if (isGameOver) {
+ return;
+ }
+ // Check if the board is filled
+ if (checkBoardFilled()) {
+ isGameOver = true;
+ LK.showGameOver();
+ return;
+ }
+ // Move the current block upwards
+ if (currentBlock) {
+ currentBlock.y -= 5; // Move speed
+ if (currentBlock.y <= BOARD_HEIGHT) {
+ placeBlock(currentBlock.x, currentBlock.y);
+ checkAndRemoveAlignedBlocks(); // Check and remove aligned blocks
+ createNewBlock();
+ }
+ }
};
// Handle touch/mouse down events
game.down = function (x, y, obj) {
- if (currentBlock) {
- placeBlock(x, y);
- createNewBlock();
- }
+ if (currentBlock) {
+ placeBlock(x, y);
+ createNewBlock();
+ }
};
// Handle touch/mouse move events
game.move = function (x, y, obj) {
- if (currentBlock) {
- currentBlock.x = x;
- }
+ if (currentBlock) {
+ currentBlock.x = x;
+ }
};
// Handle touch/mouse up events
game.up = function (x, y, obj) {
- // No specific action needed on up
+ // No specific action needed on up
};
\ No newline at end of file