User prompt
parece que la base esta en modo transparente,revisa el codigo y arreglalo
User prompt
la base sige sin verse,y cuando este en el menu la musica tiene que ser la del menu,ninguna otra
User prompt
el ladrillo base debe estar abajo y no se ve
User prompt
la musica de menu dve hacer una transicion suave a la musica del juego ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
agrega musica distinta de menu de el juego
User prompt
los textos no se ocultan,ocultalos
User prompt
agrega un fondo y un menu al iniciar
User prompt
as que el ladrillo al ser drpoeado baje,y cuando toque el ladrillo base reprodusca e sonido ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
agrega las lineas de musica
Code edit (1 edits merged)
Please save this source code
User prompt
mueve hacia arriba el towerblock
User prompt
as que donde se colocan los bloques este mas cerca de arriba
Code edit (1 edits merged)
Please save this source code
User prompt
Tower Drop
Initial prompt
podrias crear un juego donde costrulles una torre por rectangulos mas o menos de area 9*2,que los rectangulos vallan de izquierda a derecha,y los pedasos que queden fuera de los rectangulos iferiores caigan
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var FallingPiece = Container.expand(function (pieceWidth, x, y) {
var self = Container.call(this);
self.fallSpeed = 5;
self.rotationSpeed = 0.1;
var pieceGraphics = self.attachAsset('fallingPiece', {
anchorX: 0.5,
anchorY: 0.5,
width: pieceWidth
});
self.x = x;
self.y = y;
self.update = function () {
self.y += self.fallSpeed;
self.rotation += self.rotationSpeed;
self.fallSpeed += 0.2; // Gravity acceleration
};
return self;
});
var MovingBlock = Container.expand(function (blockWidth) {
var self = Container.call(this);
self.blockWidth = blockWidth || 450;
self.speed = 3;
self.direction = 1;
var blockGraphics = self.attachAsset('movingBlock', {
anchorX: 0.5,
anchorY: 0.5,
width: self.blockWidth
});
self.update = function () {
self.x += self.speed * self.direction;
// Bounce at screen edges
if (self.x <= self.blockWidth / 2) {
self.x = self.blockWidth / 2;
self.direction = 1;
} else if (self.x >= 2048 - self.blockWidth / 2) {
self.x = 2048 - self.blockWidth / 2;
self.direction = -1;
}
};
return self;
});
var TowerBlock = Container.expand(function (blockWidth, x, y) {
var self = Container.call(this);
self.blockWidth = blockWidth;
var blockGraphics = self.attachAsset('towerBlock', {
anchorX: 0.5,
anchorY: 0.5,
width: self.blockWidth
});
self.x = x;
self.y = y;
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2C3E50
});
/****
* Game Code
****/
var towerBlocks = [];
var fallingPieces = [];
var currentMovingBlock = null;
var gameHeight = 2732;
var gameWidth = 2048;
var blockHeight = 100;
var baseY = gameHeight - 80;
var currentBlockWidth = 450;
var towerHeight = 0;
var gameActive = false;
var gameStarted = false;
var menuScreen = null;
var startButton = null;
// UI Elements
var scoreTxt = new Text2('Height: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var widthTxt = new Text2('Width: 450px', {
size: 60,
fill: 0xFFFFFF
});
widthTxt.anchor.set(0.5, 0);
widthTxt.y = 100;
LK.gui.top.addChild(widthTxt);
// Create first moving block
function createNewMovingBlock() {
if (currentMovingBlock) {
currentMovingBlock.destroy();
}
currentMovingBlock = new MovingBlock(currentBlockWidth);
currentMovingBlock.x = gameWidth / 2;
currentMovingBlock.y = 100;
game.addChild(currentMovingBlock);
}
// Create the base block
var baseBlock = new TowerBlock(450, gameWidth / 2, baseY);
game.addChild(baseBlock);
towerBlocks.push(baseBlock);
// Add background
var background = game.attachAsset('background', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
// Create menu screen
function createMenuScreen() {
menuScreen = game.attachAsset('menuBackground', {
anchorX: 0.5,
anchorY: 0.5,
x: gameWidth / 2,
y: gameHeight / 2,
alpha: 0.9
});
startButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5,
x: gameWidth / 2,
y: gameHeight / 2
});
var titleText = new Text2('TOWER DROP', {
size: 120,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = gameWidth / 2;
titleText.y = gameHeight / 2 - 200;
game.addChild(titleText);
var startText = new Text2('TAP TO START', {
size: 60,
fill: 0xFFFFFF
});
startText.anchor.set(0.5, 0.5);
startText.x = gameWidth / 2;
startText.y = gameHeight / 2;
game.addChild(startText);
}
// Initialize menu
createMenuScreen();
// Start background music
LK.playMusic('bgmusic');
// Handle block drop
function dropBlock() {
if (!gameActive || !currentMovingBlock) {
return;
}
var droppedX = currentMovingBlock.x;
var droppedWidth = currentMovingBlock.blockWidth;
// Get the top block of the tower
var topBlock = towerBlocks[towerBlocks.length - 1];
var topBlockX = topBlock.x;
var topBlockWidth = topBlock.blockWidth;
// Calculate overlap
var leftEdgeDropped = droppedX - droppedWidth / 2;
var rightEdgeDropped = droppedX + droppedWidth / 2;
var leftEdgeTop = topBlockX - topBlockWidth / 2;
var rightEdgeTop = topBlockX + topBlockWidth / 2;
var overlapLeft = Math.max(leftEdgeDropped, leftEdgeTop);
var overlapRight = Math.min(rightEdgeDropped, rightEdgeTop);
var overlapWidth = overlapRight - overlapLeft;
if (overlapWidth <= 0) {
// Complete miss - game over
gameActive = false;
LK.showGameOver();
return;
}
// Drop sound will play when block lands after animation
// Calculate new block position and width
var newBlockX = (overlapLeft + overlapRight) / 2;
var newBlockY = topBlock.y - blockHeight;
// Create falling pieces for the parts that don't overlap
if (leftEdgeDropped < overlapLeft) {
// Left piece falls
var leftPieceWidth = overlapLeft - leftEdgeDropped;
var leftPieceX = leftEdgeDropped + leftPieceWidth / 2;
var leftPiece = new FallingPiece(leftPieceWidth, leftPieceX, newBlockY);
game.addChild(leftPiece);
fallingPieces.push(leftPiece);
LK.getSound('break').play();
}
if (rightEdgeDropped > overlapRight) {
// Right piece falls
var rightPieceWidth = rightEdgeDropped - overlapRight;
var rightPieceX = overlapRight + rightPieceWidth / 2;
var rightPiece = new FallingPiece(rightPieceWidth, rightPieceX, newBlockY);
game.addChild(rightPiece);
fallingPieces.push(rightPiece);
LK.getSound('break').play();
}
// Create new tower block with the overlapping portion at moving block position first
var newTowerBlock = new TowerBlock(overlapWidth, newBlockX, currentMovingBlock.y);
game.addChild(newTowerBlock);
towerBlocks.push(newTowerBlock);
// Animate the block falling down to its final position
tween(newTowerBlock, {
y: newBlockY
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
// Play drop sound when block lands
LK.getSound('drop').play();
}
});
// Update game state
currentBlockWidth = overlapWidth;
towerHeight++;
// Update UI
scoreTxt.setText('Height: ' + towerHeight);
widthTxt.setText('Width: ' + Math.round(currentBlockWidth) + 'px');
// Check if block is too small to continue
if (currentBlockWidth < 50) {
gameActive = false;
LK.setTimeout(function () {
LK.showGameOver();
}, 1000);
return;
}
// Create next moving block
LK.setTimeout(function () {
createNewMovingBlock();
}, 500);
// Remove current moving block
currentMovingBlock.destroy();
currentMovingBlock = null;
// Increase game difficulty slightly
if (currentMovingBlock) {
currentMovingBlock.speed = Math.min(currentMovingBlock.speed + 0.1, 8);
}
}
// Game tap handler
game.down = function (x, y, obj) {
if (!gameStarted) {
// Start the game
gameStarted = true;
gameActive = true;
// Remove menu elements
if (menuScreen) {
menuScreen.destroy();
menuScreen = null;
}
if (startButton) {
startButton.destroy();
startButton = null;
}
// Create first moving block
createNewMovingBlock();
} else if (gameActive) {
dropBlock();
}
};
// Main game loop
game.update = function () {
if (!gameStarted || !gameActive) {
return;
}
// Clean up falling pieces that are off screen
for (var i = fallingPieces.length - 1; i >= 0; i--) {
var piece = fallingPieces[i];
if (piece.y > gameHeight + 200) {
piece.destroy();
fallingPieces.splice(i, 1);
}
}
// Update score based on tower height
LK.setScore(towerHeight * 10 + Math.round(currentBlockWidth / 10));
}; ===================================================================
--- original.js
+++ change.js
@@ -78,9 +78,12 @@
var blockHeight = 100;
var baseY = gameHeight - 80;
var currentBlockWidth = 450;
var towerHeight = 0;
-var gameActive = true;
+var gameActive = false;
+var gameStarted = false;
+var menuScreen = null;
+var startButton = null;
// UI Elements
var scoreTxt = new Text2('Height: 0', {
size: 80,
fill: 0xFFFFFF
@@ -107,10 +110,49 @@
// Create the base block
var baseBlock = new TowerBlock(450, gameWidth / 2, baseY);
game.addChild(baseBlock);
towerBlocks.push(baseBlock);
-// Create first moving block
-createNewMovingBlock();
+// Add background
+var background = game.attachAsset('background', {
+ anchorX: 0,
+ anchorY: 0,
+ x: 0,
+ y: 0
+});
+// Create menu screen
+function createMenuScreen() {
+ menuScreen = game.attachAsset('menuBackground', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: gameWidth / 2,
+ y: gameHeight / 2,
+ alpha: 0.9
+ });
+ startButton = game.attachAsset('startButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: gameWidth / 2,
+ y: gameHeight / 2
+ });
+ var titleText = new Text2('TOWER DROP', {
+ size: 120,
+ fill: 0xFFFFFF
+ });
+ titleText.anchor.set(0.5, 0.5);
+ titleText.x = gameWidth / 2;
+ titleText.y = gameHeight / 2 - 200;
+ game.addChild(titleText);
+ var startText = new Text2('TAP TO START', {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ startText.anchor.set(0.5, 0.5);
+ startText.x = gameWidth / 2;
+ startText.y = gameHeight / 2;
+ game.addChild(startText);
+}
+// Initialize menu
+createMenuScreen();
// Start background music
LK.playMusic('bgmusic');
// Handle block drop
function dropBlock() {
@@ -202,15 +244,30 @@
}
}
// Game tap handler
game.down = function (x, y, obj) {
- if (gameActive) {
+ if (!gameStarted) {
+ // Start the game
+ gameStarted = true;
+ gameActive = true;
+ // Remove menu elements
+ if (menuScreen) {
+ menuScreen.destroy();
+ menuScreen = null;
+ }
+ if (startButton) {
+ startButton.destroy();
+ startButton = null;
+ }
+ // Create first moving block
+ createNewMovingBlock();
+ } else if (gameActive) {
dropBlock();
}
};
// Main game loop
game.update = function () {
- if (!gameActive) {
+ if (!gameStarted || !gameActive) {
return;
}
// Clean up falling pieces that are off screen
for (var i = fallingPieces.length - 1; i >= 0; i--) {
bloque rectangular de ladrillos de castillo. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
ladrillos rotos . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
ladrillos. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
boton de inicio ovalado sin texto. In-Game asset. 2d. High contrast. No shadows
con cielo y menos altas