User prompt
agrega una nueva pelotita la de color negro esta solo aparece cuando la pelotita roja toca a otra roja y añade mas dificultad dependiendo del nivel
User prompt
pierdes cuando apenas tiras una pelotita solo debes de perder cuando se detecte una pelotita fuera del cubo por 3 segundos
User prompt
pierdes cuando apenas tiras una pelotita
User prompt
ahora el nivel terminara cuando el cuadrado se llene de pelotitas y no puedan caber mas y añade mas dificultad dependiendo del nivel
User prompt
quita el temporizador y las pelotitas que te tocara ya no deben de ser aleatoreas deben de aparecer dependiendo de las pelotitas que hay en pantalla para hacer que el jugador se le dificulte
User prompt
ponle fisicas ligeramente exageradas para evitar que las pelotitas se apilen
User prompt
el indicador de las pelotitas deben de mostrarlas pequeñas para evitar que tape toda la pantalla
User prompt
ahora cuando tires pelotitas te aparecera una pelotita diferente un poco aleatoreo y arriba ala derecha te indicara la siguiente pelotita que te tocara y en medio de la parte de arriba te indicara la pelotita que tienes
User prompt
la pelotita azul debe de ser mas grande y la pelotita morada debe de ser el doble de grande y agrega una nueva pelotita la roja esta aparece cuando la pelotita morada toca otra morada
User prompt
el selector de nivel no desaparece al seleccionar un nivel
User prompt
te falto el menu principal y la lista de niveles
User prompt
te falto el menu principal
Code edit (1 edits merged)
Please save this source code
User prompt
Color Merge Drop
Initial prompt
creemos un jurgo simple y el juego trata de dejar caer pelotitas de colores cada pelota tendra un color diferente y al tocar una pelotita del mismo color se transformara en otra ligeramente mas grande un ejemplo cuando la pelotita verde toca a otra verde las dos se eliminan y crean una pelotita azul un poco mas grande y la pelotita azul al tocar otra azul se volvera uno morado y sera un poco mas grande y la pelotita morada al tocar a otra morada simplemente desaparecera y marcara puntaje en total hay 3 pelotitas y todas tendran gravedad y colisiones y las pelotias donde se dejaran caer seria desde arriba y para que no se salgan de la camara abra una especie de cuadrado que evitara que se salgan y antes de empezar el juego entraras al menu principal en medio estara un boton sin nombre solo color que te dejara entrar ala lista de niveles cada nivel se desbloqueara por cada nivel jugado y en el gameplay estara un contador de puntaje y el tiempo
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Ball = Container.expand(function (color, size) {
var self = Container.call(this);
self.ballColor = color;
self.ballSize = size;
self.velocityX = 0;
self.velocityY = 0;
self.gravity = 0.5;
self.bounce = 0.6;
self.friction = 0.98;
self.merged = false;
var ballAsset;
if (color === 'green') {
ballAsset = self.attachAsset('greenBall', {
anchorX: 0.5,
anchorY: 0.5
});
self.radius = 40;
} else if (color === 'blue') {
ballAsset = self.attachAsset('blueBall', {
anchorX: 0.5,
anchorY: 0.5
});
self.radius = 80;
} else if (color === 'purple') {
ballAsset = self.attachAsset('purpleBall', {
anchorX: 0.5,
anchorY: 0.5
});
self.radius = 160;
} else if (color === 'red') {
ballAsset = self.attachAsset('redBall', {
anchorX: 0.5,
anchorY: 0.5
});
self.radius = 320;
}
self.update = function () {
if (self.merged) return;
// Apply gravity
self.velocityY += self.gravity;
// Apply friction
self.velocityX *= self.friction;
self.velocityY *= self.friction;
// Update position
self.x += self.velocityX;
self.y += self.velocityY;
// Floor collision
if (self.y + self.radius > gameFloor) {
self.y = gameFloor - self.radius;
self.velocityY *= -self.bounce;
if (Math.abs(self.velocityY) < 1) {
self.velocityY = 0;
}
}
// Wall collisions
if (self.x - self.radius < gameLeftWall + 20) {
self.x = gameLeftWall + 20 + self.radius;
self.velocityX *= -self.bounce;
}
if (self.x + self.radius > gameRightWall - 20) {
self.x = gameRightWall - 20 - self.radius;
self.velocityX *= -self.bounce;
}
// Check for merges with other balls
for (var i = 0; i < balls.length; i++) {
var otherBall = balls[i];
if (otherBall === self || otherBall.merged) continue;
var dx = self.x - otherBall.x;
var dy = self.y - otherBall.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < self.radius + otherBall.radius) {
// Collision detected
if (self.ballColor === otherBall.ballColor && !self.merging && !otherBall.merging) {
// Same color - merge
self.merging = true;
otherBall.merging = true;
mergeBalls(self, otherBall);
} else {
// Different colors - bounce
var angle = Math.atan2(dy, dx);
var sin = Math.sin(angle);
var cos = Math.cos(angle);
var vx1 = self.velocityX * cos + self.velocityY * sin;
var vy1 = self.velocityY * cos - self.velocityX * sin;
var vx2 = otherBall.velocityX * cos + otherBall.velocityY * sin;
var vy2 = otherBall.velocityY * cos - otherBall.velocityX * sin;
var finalVx1 = vx2;
var finalVx2 = vx1;
self.velocityX = finalVx1 * cos - vy1 * sin;
self.velocityY = vy1 * cos + finalVx1 * sin;
otherBall.velocityX = finalVx2 * cos - vy2 * sin;
otherBall.velocityY = vy2 * cos + finalVx2 * sin;
// Separate balls
var overlap = self.radius + otherBall.radius - distance;
var moveX = overlap * 0.5 * cos;
var moveY = overlap * 0.5 * sin;
self.x += moveX;
self.y += moveY;
otherBall.x -= moveX;
otherBall.y -= moveY;
}
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x222222
});
/****
* Game Code
****/
// Game state management
var gameState = 'menu'; // 'menu', 'levelSelect', 'playing'
var balls = [];
var gameLevel = storage.currentLevel || 1;
var maxUnlockedLevel = storage.maxUnlockedLevel || 1;
var gameScore = 0;
var gameTime = 60000; // 60 seconds
var gameStartTime = Date.now();
var targetScore = gameLevel * 100;
var dropCooldown = 0;
var gameLeftWall = 124;
var gameRightWall = 1924;
var gameFloor = 2500;
var nextBallColor = 'green';
// UI containers
var menuContainer = new Container();
var levelSelectContainer = new Container();
var gameContainer = new Container();
var uiContainer = new Container();
// Add containers to game
game.addChild(menuContainer);
game.addChild(levelSelectContainer);
game.addChild(gameContainer);
game.addChild(uiContainer);
// Hide level select and game containers initially
levelSelectContainer.visible = false;
gameContainer.visible = false;
// Create main menu
var menuButton = menuContainer.addChild(LK.getAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5
}));
menuButton.x = 1024;
menuButton.y = 1366;
var menuTitle = new Text2('Color Merge Drop', {
size: 120,
fill: 0xFFFFFF
});
menuTitle.anchor.set(0.5, 0.5);
menuTitle.x = 1024;
menuTitle.y = 800;
menuContainer.addChild(menuTitle);
var menuInstruction = new Text2('Tap to Start', {
size: 60,
fill: 0xAAAAAA
});
menuInstruction.anchor.set(0.5, 0.5);
menuInstruction.x = 1024;
menuInstruction.y = 1600;
menuContainer.addChild(menuInstruction);
// Create game boundaries (moved to game container)
var leftWall = gameContainer.addChild(LK.getAsset('wall', {
anchorX: 0,
anchorY: 0
}));
leftWall.x = gameLeftWall;
leftWall.y = 200;
var rightWall = gameContainer.addChild(LK.getAsset('wall', {
anchorX: 0,
anchorY: 0
}));
rightWall.x = gameRightWall;
rightWall.y = 200;
var floor = gameContainer.addChild(LK.getAsset('floor', {
anchorX: 0,
anchorY: 0
}));
floor.x = gameLeftWall + 20;
floor.y = gameFloor;
// Create drop zone
var dropZone = gameContainer.addChild(LK.getAsset('dropZone', {
anchorX: 0.5,
anchorY: 0
}));
dropZone.x = 1024;
dropZone.y = 100;
// Create level selection screen
var levelSelectTitle = new Text2('Select Level', {
size: 100,
fill: 0xFFFFFF
});
levelSelectTitle.anchor.set(0.5, 0.5);
levelSelectTitle.x = 1024;
levelSelectTitle.y = 400;
levelSelectContainer.addChild(levelSelectTitle);
var levelButtons = [];
var levelsPerRow = 4;
var totalLevels = 12;
var buttonSpacing = 200;
var startX = 1024 - (levelsPerRow - 1) * buttonSpacing / 2;
var startY = 800;
for (var i = 1; i <= totalLevels; i++) {
var row = Math.floor((i - 1) / levelsPerRow);
var col = (i - 1) % levelsPerRow;
var buttonX = startX + col * buttonSpacing;
var buttonY = startY + row * buttonSpacing;
var isUnlocked = i <= maxUnlockedLevel;
var levelButton = levelSelectContainer.addChild(LK.getAsset(isUnlocked ? 'levelButton' : 'lockedButton', {
anchorX: 0.5,
anchorY: 0.5
}));
levelButton.x = buttonX;
levelButton.y = buttonY;
levelButton.levelNumber = i;
levelButton.isUnlocked = isUnlocked;
levelButtons.push(levelButton);
if (isUnlocked) {
var levelLabel = new Text2(i.toString(), {
size: 60,
fill: 0xFFFFFF
});
levelLabel.anchor.set(0.5, 0.5);
levelLabel.x = buttonX;
levelLabel.y = buttonY;
levelSelectContainer.addChild(levelLabel);
}
}
// Back button for level select
var backButton = levelSelectContainer.addChild(LK.getAsset('backButton', {
anchorX: 0.5,
anchorY: 0.5
}));
backButton.x = 200;
backButton.y = 200;
var backLabel = new Text2('Back', {
size: 40,
fill: 0xFFFFFF
});
backLabel.anchor.set(0.5, 0.5);
backLabel.x = 200;
backLabel.y = 200;
levelSelectContainer.addChild(backLabel);
// Create UI (moved to UI container)
var scoreText = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreText.anchor.set(0, 0);
LK.gui.topLeft.addChild(scoreText);
scoreText.x = 150;
scoreText.y = 50;
var timeText = new Text2('Time: 60', {
size: 60,
fill: 0xFFFFFF
});
timeText.anchor.set(1, 0);
LK.gui.topRight.addChild(timeText);
timeText.x = -50;
timeText.y = 50;
var targetText = new Text2('Target: ' + targetScore, {
size: 50,
fill: 0xFFFF00
});
targetText.anchor.set(0, 0);
LK.gui.topLeft.addChild(targetText);
targetText.x = 150;
targetText.y = 120;
var levelText = new Text2('Level ' + gameLevel, {
size: 70,
fill: 0x00FF00
});
levelText.anchor.set(0.5, 0);
LK.gui.top.addChild(levelText);
levelText.y = 50;
function showMenu() {
gameState = 'menu';
menuContainer.visible = true;
levelSelectContainer.visible = false;
gameContainer.visible = false;
// Hide UI elements
scoreText.visible = false;
timeText.visible = false;
targetText.visible = false;
levelText.visible = false;
}
function showLevelSelect() {
gameState = 'levelSelect';
menuContainer.visible = false;
levelSelectContainer.visible = true;
gameContainer.visible = false;
// Update level buttons based on current unlocked levels
maxUnlockedLevel = storage.maxUnlockedLevel || 1;
for (var i = 0; i < levelButtons.length; i++) {
var button = levelButtons[i];
var isUnlocked = button.levelNumber <= maxUnlockedLevel;
button.isUnlocked = isUnlocked;
// Note: We can't change the asset type dynamically, so we'll handle this in the click handler
}
}
function startGame(level) {
gameState = 'playing';
gameLevel = level;
gameScore = 0;
gameStartTime = Date.now();
targetScore = gameLevel * 100;
// Clear existing balls
for (var i = balls.length - 1; i >= 0; i--) {
balls[i].destroy();
}
balls = [];
// Show game UI
menuContainer.visible = false;
levelSelectContainer.visible = false;
gameContainer.visible = true;
// Show UI elements
scoreText.visible = true;
timeText.visible = true;
targetText.visible = true;
levelText.visible = true;
// Update UI texts
updateScore();
updateTimer();
targetText.setText('Target: ' + targetScore);
levelText.setText('Level ' + gameLevel);
}
function createBall(x, y, color) {
var ball = new Ball(color);
ball.x = x;
ball.y = y;
balls.push(ball);
gameContainer.addChild(ball);
LK.getSound('drop').play();
return ball;
}
function mergeBalls(ball1, ball2) {
LK.getSound('merge').play();
var mergeX = (ball1.x + ball2.x) / 2;
var mergeY = (ball1.y + ball2.y) / 2;
// Mark balls as merged
ball1.merged = true;
ball2.merged = true;
// Remove from balls array
var index1 = balls.indexOf(ball1);
var index2 = balls.indexOf(ball2);
if (index1 > -1) balls.splice(index1, 1);
if (index2 > -1) balls.splice(index2, 1);
// Remove from display
ball1.destroy();
ball2.destroy();
// Create next color ball or add score
if (ball1.ballColor === 'green') {
var newBall = createBall(mergeX, mergeY, 'blue');
newBall.velocityX = (ball1.velocityX + ball2.velocityX) / 2;
newBall.velocityY = (ball1.velocityY + ball2.velocityY) / 2;
} else if (ball1.ballColor === 'blue') {
var newBall = createBall(mergeX, mergeY, 'purple');
newBall.velocityX = (ball1.velocityX + ball2.velocityX) / 2;
newBall.velocityY = (ball1.velocityY + ball2.velocityY) / 2;
} else if (ball1.ballColor === 'purple') {
var newBall = createBall(mergeX, mergeY, 'red');
newBall.velocityX = (ball1.velocityX + ball2.velocityX) / 2;
newBall.velocityY = (ball1.velocityY + ball2.velocityY) / 2;
} else if (ball1.ballColor === 'red') {
// Red balls disappear and give score
gameScore += 100;
LK.getSound('score').play();
LK.effects.flashObject(scoreText, 0xffff00, 500);
}
updateScore();
}
function updateScore() {
scoreText.setText('Score: ' + gameScore);
if (gameScore >= targetScore) {
// Level complete
if (gameLevel >= maxUnlockedLevel) {
maxUnlockedLevel = gameLevel + 1;
storage.maxUnlockedLevel = maxUnlockedLevel;
}
storage.currentLevel = gameLevel + 1;
LK.showYouWin();
}
}
function updateTimer() {
var elapsed = Date.now() - gameStartTime;
var remaining = Math.max(0, Math.ceil((gameTime - elapsed) / 1000));
timeText.setText('Time: ' + remaining);
if (remaining <= 0 && gameScore < targetScore) {
LK.showGameOver();
}
}
// Touch/click handler
game.down = function (x, y, obj) {
if (gameState === 'menu') {
// Check if menu button was clicked
var dx = x - menuButton.x;
var dy = y - menuButton.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 100) {
LK.getSound('button').play();
showLevelSelect();
}
} else if (gameState === 'levelSelect') {
// Check if back button was clicked
var dx = x - backButton.x;
var dy = y - backButton.y;
if (Math.abs(dx) < 60 && Math.abs(dy) < 40) {
LK.getSound('button').play();
showMenu();
return;
}
// Check if level button was clicked
for (var i = 0; i < levelButtons.length; i++) {
var button = levelButtons[i];
var dx = x - button.x;
var dy = y - button.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 75 && button.isUnlocked) {
LK.getSound('button').play();
startGame(button.levelNumber);
return;
}
}
} else if (gameState === 'playing') {
if (dropCooldown > 0) return;
// Drop ball at x position within drop zone
var dropX = Math.max(gameLeftWall + 60, Math.min(gameRightWall - 60, x));
createBall(dropX, 200, nextBallColor);
dropCooldown = 30; // 0.5 second cooldown
}
};
game.update = function () {
// Only run game logic when playing
if (gameState !== 'playing') return;
// Update cooldown
if (dropCooldown > 0) {
dropCooldown--;
}
// Update timer
updateTimer();
// Clean up merged balls
for (var i = balls.length - 1; i >= 0; i--) {
if (balls[i].merged) {
balls.splice(i, 1);
}
}
// Check for balls that fell off screen
for (var i = balls.length - 1; i >= 0; i--) {
if (balls[i].y > 2732) {
balls[i].destroy();
balls.splice(i, 1);
}
}
};
// Initialize game in menu state
showMenu(); ===================================================================
--- original.js
+++ change.js
@@ -28,15 +28,21 @@
ballAsset = self.attachAsset('blueBall', {
anchorX: 0.5,
anchorY: 0.5
});
- self.radius = 60;
+ self.radius = 80;
} else if (color === 'purple') {
ballAsset = self.attachAsset('purpleBall', {
anchorX: 0.5,
anchorY: 0.5
});
- self.radius = 80;
+ self.radius = 160;
+ } else if (color === 'red') {
+ ballAsset = self.attachAsset('redBall', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.radius = 320;
}
self.update = function () {
if (self.merged) return;
// Apply gravity
@@ -366,10 +372,14 @@
var newBall = createBall(mergeX, mergeY, 'purple');
newBall.velocityX = (ball1.velocityX + ball2.velocityX) / 2;
newBall.velocityY = (ball1.velocityY + ball2.velocityY) / 2;
} else if (ball1.ballColor === 'purple') {
- // Purple balls disappear and give score
- gameScore += 50;
+ var newBall = createBall(mergeX, mergeY, 'red');
+ newBall.velocityX = (ball1.velocityX + ball2.velocityX) / 2;
+ newBall.velocityY = (ball1.velocityY + ball2.velocityY) / 2;
+ } else if (ball1.ballColor === 'red') {
+ // Red balls disappear and give score
+ gameScore += 100;
LK.getSound('score').play();
LK.effects.flashObject(scoreText, 0xffff00, 500);
}
updateScore();
crea la imagen de un circulo azul simple y contorno azul fuerte. In-Game asset. 2d. High contrast. No shadows
crea la imagen de un circulo azul grisaseo simple y contorno azul fuerte.
crea la imagen de un rectangulo verde con borde verde oscuro y en medio que tenga la palabra play. In-Game asset. 2d. High contrast. No shadows
crea un fondo bonito que tenga pelotitas de colores. In-Game asset. 2d. High contrast. No shadows
crea la imagen de una pelotita simple con una carita kawai verde. In-Game asset. 2d. High contrast. No shadows
crea la imagen de una pelotita blanca simple kawai. In-Game asset. 2d. High contrast. No shadows
crea la imagen de una pelotita negra simple kawai y nerviosa. In-Game asset. 2d. High contrast. No shadows
crea la imagen de una pelotita azul kawai con lentes y simple. In-Game asset. 2d. High contrast. No shadows
crea una estrella dorada kawai y simple. In-Game asset. 2d. High contrast. No shadows
crea una estrella kawai deprimida y de color gris simple. In-Game asset. 2d. High contrast. No shadows
crea la imagen de una pelotita morada algo preocupada kawai y simple. In-Game asset. 2d. High contrast. No shadows
crea la imagen de una pelotita roja enojada y kawai simple. In-Game asset. 2d. High contrast. No shadows
crea un paisaje kawai. In-Game asset. 2d. High contrast. No shadows
crea la imagen de un rectangulo azul simple. In-Game asset. 2d. High contrast. No shadows
crea la imagen de un circulo naranja kawai enojada y simple. In-Game asset. 2d. High contrast. No shadows
crea ua pelotita kawai dorada simple y con lentes oscuros. In-Game asset. 2d. High contrast. No shadows
crea un rectangulo rojo que diga salir, simple. In-Game asset. 2d. High contrast. No shadows
crea un rectangulo verde que diga pausar. In-Game asset. 2d. High contrast. No shadows