User prompt
Make it 5 points per second
User prompt
Make that you lose 1 point per second when you swipe ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
It’s not working
User prompt
Make a 5 Second Timeout to the swipe feature when it’s used 5 seconds ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make that you can slice the Boxes with the Swipe feature
User prompt
Make it if you swipe you have a trail
User prompt
Make that if you swipe you get a bonus
User prompt
Add a Swipe mechanic
User prompt
Add a cube variant that destroys all cubes in it horizontal line
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'comboText.style.fill = 0xFFCC00; // Yellow for medium combo' Line Number: 108
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'comboText.setFill(0xFFCC00); // Yellow for medium combo' Line Number: 108
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'comboText.style.fill = 0xFFCC00; // Yellow for medium combo' Line Number: 108
User prompt
Make a Combo System
User prompt
Make the Background green when the score hits 300 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make the green slighter
User prompt
Make the background fade into green the closer you get to winning ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Initial prompt
Make the score black
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Box = Container.expand(function (type) {
var self = Container.call(this);
self.type = type || 'regular';
self.speed = 5;
self.points = 1;
self.active = true;
// Different box configurations based on type
if (self.type === 'regular') {
self.boxGraphics = self.attachAsset('regularBox', {
anchorX: 0.5,
anchorY: 0.5
});
self.points = 1;
} else if (self.type === 'bonus') {
self.boxGraphics = self.attachAsset('bonusBox', {
anchorX: 0.5,
anchorY: 0.5
});
self.points = 3;
self.speed = 7;
} else if (self.type === 'special') {
self.boxGraphics = self.attachAsset('specialBox', {
anchorX: 0.5,
anchorY: 0.5
});
self.points = 5;
self.speed = 9;
} else if (self.type === 'lineClear') {
self.boxGraphics = self.attachAsset('specialBox', {
anchorX: 0.5,
anchorY: 0.5
});
self.boxGraphics.tint = 0x9b59b6; // Purple tint
self.points = 2;
self.speed = 6;
self.isLineClearer = true;
}
// Add a small rotation to make it visually interesting
self.rotationSpeed = (Math.random() - 0.5) * 0.02;
self.update = function () {
if (!self.active) {
return;
}
self.y += self.speed;
self.boxGraphics.rotation += self.rotationSpeed;
// Check if box moved out of screen
if (self.y > 2732 + self.boxGraphics.height) {
self.active = false;
missedBoxes++;
// Check if the player has missed too many boxes
if (missedBoxes >= maxMissedBoxes) {
LK.effects.flashScreen(0xff0000, 500);
LK.getSound('gameOverSound').play();
LK.setTimeout(function () {
LK.showGameOver();
}, 500);
}
}
};
self.tap = function () {
if (!self.active) {
return;
}
self.active = false;
// Handle line-clearing box
if (self.isLineClearer) {
LK.getSound('lineClear').play();
// Find all boxes in the same horizontal line (within a small y-tolerance)
var yPosition = self.y;
var tolerance = 30; // Tolerance for y-position matching
var boxesInLine = [];
var totalPoints = self.points; // Start with the points from this box
// Find boxes in the same line
boxes.forEach(function (otherBox) {
if (otherBox !== self && otherBox.active && Math.abs(otherBox.y - yPosition) < tolerance) {
boxesInLine.push(otherBox);
totalPoints += otherBox.points;
otherBox.active = false;
// Create explosion effect for each box in line
tween(otherBox, {
alpha: 0,
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 300,
easing: tween.linear,
onFinish: function onFinish() {
otherBox.destroy();
}
});
}
});
// Show total points cleared
var pointText = new Text2('+' + totalPoints, {
size: 70,
fill: 0x9b59b6
});
pointText.anchor.set(0.5, 0.5);
pointText.x = self.x;
pointText.y = self.y;
game.addChild(pointText);
// Animate the text
tween(pointText, {
y: pointText.y - 80,
alpha: 0
}, {
duration: 1200,
easing: tween.easeOut,
onFinish: function onFinish() {
pointText.destroy();
}
});
// Update score with total points
LK.setScore(LK.getScore() + totalPoints);
updateScoreDisplay();
} else {
// Regular box behavior
// Play appropriate sound
if (self.type === 'regular') {
LK.getSound('tap').play();
} else {
LK.getSound('bonus').play();
}
// Update score
LK.setScore(LK.getScore() + self.points);
updateScoreDisplay();
// Show score increase effect
var pointText = new Text2('+' + self.points, {
size: 50,
fill: 0xFFFFFF
});
pointText.anchor.set(0.5, 0.5);
pointText.x = self.x;
pointText.y = self.y;
game.addChild(pointText);
// Animate the text and remove it
tween(pointText, {
y: pointText.y - 80,
alpha: 0
}, {
duration: 800,
easing: tween.easeOut,
onFinish: function onFinish() {
pointText.destroy();
}
});
}
// Animate the box explosion
tween(self, {
alpha: 0,
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 300,
easing: tween.linear,
onFinish: function onFinish() {
self.destroy();
}
});
// Check if player reached target score
if (LK.getScore() >= winScore) {
LK.showYouWin();
}
};
// Event handler for tapping on boxes
self.down = function () {
self.tap();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xFFFFFF
});
/****
* Game Code
****/
// Game variables
var boxes = [];
var spawnInterval = 1000; // Initial spawn interval in ms
var minSpawnInterval = 300; // Minimum spawn interval
var spawnTimer = null;
var missedBoxes = 0;
var maxMissedBoxes = 10; // Game over after 10 missed boxes
var winScore = 300; // Score needed to win
var difficultyIncreaseInterval = 10000; // Increase difficulty every 10 seconds
var difficultyTimer = null;
var gameStarted = false;
// Initialize UI
var scoreTxt = new Text2('0', {
size: 80,
fill: 0x000000
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var missedBoxesTxt = new Text2('Missed: 0/' + maxMissedBoxes, {
size: 50,
fill: 0xFFFFFF
});
missedBoxesTxt.anchor.set(0, 0);
missedBoxesTxt.x = 150;
missedBoxesTxt.y = 50;
LK.gui.topRight.addChild(missedBoxesTxt);
var instructionsTxt = new Text2('Tap the falling boxes!', {
size: 60,
fill: 0xFFFFFF
});
instructionsTxt.anchor.set(0.5, 0.5);
LK.gui.center.addChild(instructionsTxt);
// Hide instructions after a delay
LK.setTimeout(function () {
tween(instructionsTxt, {
alpha: 0
}, {
duration: 1000,
easing: tween.linear,
onFinish: function onFinish() {
instructionsTxt.destroy();
}
});
startGame();
}, 2000);
// Function to update score display
function updateScoreDisplay() {
scoreTxt.setText(LK.getScore());
missedBoxesTxt.setText('Missed: ' + missedBoxes + '/' + maxMissedBoxes);
}
// Function to spawn a box
function spawnBox() {
var boxType;
var random = Math.random();
if (random < 0.65) {
boxType = 'regular';
} else if (random < 0.85) {
boxType = 'bonus';
} else if (random < 0.95) {
boxType = 'special';
} else {
boxType = 'lineClear';
}
var box = new Box(boxType);
box.x = Math.random() * (2048 - 100) + 50; // Random x position
box.y = -100; // Start above the screen
// Add some variety to the path
box.xSpeed = (Math.random() - 0.5) * 3;
boxes.push(box);
game.addChild(box);
}
// Function to start the game
function startGame() {
if (gameStarted) {
return;
}
gameStarted = true;
// Reset variables
boxes.forEach(function (box) {
box.destroy();
});
boxes = [];
missedBoxes = 0;
LK.setScore(0);
updateScoreDisplay();
// Start spawning boxes
spawnTimer = LK.setInterval(function () {
spawnBox();
}, spawnInterval);
// Increase difficulty over time
difficultyTimer = LK.setInterval(function () {
if (spawnInterval > minSpawnInterval) {
spawnInterval = Math.max(minSpawnInterval, spawnInterval - 100);
// Clear and restart spawn timer with new interval
LK.clearInterval(spawnTimer);
spawnTimer = LK.setInterval(function () {
spawnBox();
}, spawnInterval);
}
}, difficultyIncreaseInterval);
// Play background music
LK.playMusic('gameMusic', {
fade: {
start: 0,
end: 0.5,
duration: 1000
}
});
}
// Update function called every frame
game.update = function () {
// Process all active boxes
for (var i = boxes.length - 1; i >= 0; i--) {
var box = boxes[i];
// Remove inactive boxes from the array
if (!box.active) {
boxes.splice(i, 1);
continue;
}
// Add some horizontal movement to make it more interesting
if (box.xSpeed) {
box.x += box.xSpeed;
// Bounce off the edges
if (box.x < 50 || box.x > 2048 - 50) {
box.xSpeed *= -1;
}
}
}
};
// Allow tapping anywhere on the screen to tap a box
game.down = function (x, y) {
// Check if any box was hit
var hitBox = false;
for (var i = boxes.length - 1; i >= 0; i--) {
var box = boxes[i];
// Calculate distance from tap to box center
var dx = x - box.x;
var dy = y - box.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// If tap is within the box, trigger a tap
if (distance < box.boxGraphics.width / 2 && box.active) {
box.tap();
hitBox = true;
break; // Only tap one box at a time
}
}
// Flash screen very subtly when missing a box
if (!hitBox && boxes.length > 0) {
LK.effects.flashScreen(0x3498db, 100);
}
};
// Game clean-up function
game.cleanup = function () {
if (spawnTimer) {
LK.clearInterval(spawnTimer);
}
if (difficultyTimer) {
LK.clearInterval(difficultyTimer);
}
LK.stopMusic();
}; ===================================================================
--- original.js
+++ change.js
@@ -33,8 +33,17 @@
anchorY: 0.5
});
self.points = 5;
self.speed = 9;
+ } else if (self.type === 'lineClear') {
+ self.boxGraphics = self.attachAsset('specialBox', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.boxGraphics.tint = 0x9b59b6; // Purple tint
+ self.points = 2;
+ self.speed = 6;
+ self.isLineClearer = true;
}
// Add a small rotation to make it visually interesting
self.rotationSpeed = (Math.random() - 0.5) * 0.02;
self.update = function () {
@@ -61,90 +70,91 @@
if (!self.active) {
return;
}
self.active = false;
- // Play appropriate sound
- if (self.type === 'regular') {
- LK.getSound('tap').play();
- } else {
- LK.getSound('bonus').play();
- }
- // Handle combo system
- var currentTime = Date.now();
- if (comboTimer) {
- LK.clearTimeout(comboTimer);
- }
- if (currentTime - lastTapTime < comboTimeWindow) {
- // Continue combo
- comboCount++;
- comboMultiplier = Math.min(5, 1 + Math.floor(comboCount / 3));
- // Flash combo text with animation
- comboText.setText('COMBO x' + comboMultiplier + ' (' + comboCount + ')');
- comboText.alpha = 1;
- comboText.scale.set(1.3);
- tween(comboText.scale, {
- x: 1,
- y: 1
+ // Handle line-clearing box
+ if (self.isLineClearer) {
+ LK.getSound('lineClear').play();
+ // Find all boxes in the same horizontal line (within a small y-tolerance)
+ var yPosition = self.y;
+ var tolerance = 30; // Tolerance for y-position matching
+ var boxesInLine = [];
+ var totalPoints = self.points; // Start with the points from this box
+ // Find boxes in the same line
+ boxes.forEach(function (otherBox) {
+ if (otherBox !== self && otherBox.active && Math.abs(otherBox.y - yPosition) < tolerance) {
+ boxesInLine.push(otherBox);
+ totalPoints += otherBox.points;
+ otherBox.active = false;
+ // Create explosion effect for each box in line
+ tween(otherBox, {
+ alpha: 0,
+ scaleX: 1.5,
+ scaleY: 1.5
+ }, {
+ duration: 300,
+ easing: tween.linear,
+ onFinish: function onFinish() {
+ otherBox.destroy();
+ }
+ });
+ }
+ });
+ // Show total points cleared
+ var pointText = new Text2('+' + totalPoints, {
+ size: 70,
+ fill: 0x9b59b6
+ });
+ pointText.anchor.set(0.5, 0.5);
+ pointText.x = self.x;
+ pointText.y = self.y;
+ game.addChild(pointText);
+ // Animate the text
+ tween(pointText, {
+ y: pointText.y - 80,
+ alpha: 0
}, {
- duration: 300,
- easing: tween.easeOutBounce
+ duration: 1200,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ pointText.destroy();
+ }
});
- // Set color based on combo level
- if (comboMultiplier >= 4) {
- comboText.style.fill = "#FF0000"; // Red for highest combo
- } else if (comboMultiplier >= 3) {
- comboText.style.fill = "#FF6600"; // Orange for high combo
- } else if (comboMultiplier >= 2) {
- comboText.style.fill = "#FFCC00"; // Yellow for medium combo
- }
+ // Update score with total points
+ LK.setScore(LK.getScore() + totalPoints);
+ updateScoreDisplay();
} else {
- // Reset combo
- comboCount = 1;
- comboMultiplier = 1;
- comboText.setText('');
- }
- // Set timer to reset combo if no tap within time window
- comboTimer = LK.setTimeout(function () {
- comboCount = 0;
- comboMultiplier = 1;
- // Fade out combo text
- tween(comboText, {
+ // Regular box behavior
+ // Play appropriate sound
+ if (self.type === 'regular') {
+ LK.getSound('tap').play();
+ } else {
+ LK.getSound('bonus').play();
+ }
+ // Update score
+ LK.setScore(LK.getScore() + self.points);
+ updateScoreDisplay();
+ // Show score increase effect
+ var pointText = new Text2('+' + self.points, {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ pointText.anchor.set(0.5, 0.5);
+ pointText.x = self.x;
+ pointText.y = self.y;
+ game.addChild(pointText);
+ // Animate the text and remove it
+ tween(pointText, {
+ y: pointText.y - 80,
alpha: 0
}, {
- duration: 500,
- easing: tween.linear
+ duration: 800,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ pointText.destroy();
+ }
});
- }, comboTimeWindow);
- lastTapTime = currentTime;
- // Calculate points with combo multiplier
- var totalPoints = self.points * comboMultiplier;
- // Update score
- LK.setScore(LK.getScore() + totalPoints);
- updateScoreDisplay();
- // Show score increase effect
- var pointText = new Text2('+' + totalPoints, {
- size: 50,
- fill: 0xFFFFFF
- });
- if (comboMultiplier > 1) {
- pointText.style.fill = comboText.style.fill;
- pointText.setText('+' + totalPoints + ' (x' + comboMultiplier + ')');
}
- pointText.anchor.set(0.5, 0.5);
- pointText.x = self.x;
- pointText.y = self.y;
- game.addChild(pointText);
- // Animate the text and then remove it
- tween(pointText, {
- y: pointText.y - 80,
- alpha: 0
- }, {
- duration: 800,
- easing: tween.easeOut,
- onFinish: function onFinish() {
- pointText.destroy();
- }
- });
// Animate the box explosion
tween(self, {
alpha: 0,
scaleX: 1.5,
@@ -188,15 +198,8 @@
var winScore = 300; // Score needed to win
var difficultyIncreaseInterval = 10000; // Increase difficulty every 10 seconds
var difficultyTimer = null;
var gameStarted = false;
-// Combo system variables
-var comboCount = 0;
-var comboTimer = null;
-var comboTimeWindow = 2000; // Time window in ms to maintain combo
-var lastTapTime = 0;
-var comboMultiplier = 1;
-var comboText = null;
// Initialize UI
var scoreTxt = new Text2('0', {
size: 80,
fill: 0x000000
@@ -210,16 +213,8 @@
missedBoxesTxt.anchor.set(0, 0);
missedBoxesTxt.x = 150;
missedBoxesTxt.y = 50;
LK.gui.topRight.addChild(missedBoxesTxt);
-// Combo text
-comboText = new Text2('', {
- size: 60,
- fill: 0xFFCC00
-});
-comboText.anchor.set(0.5, 0);
-comboText.y = 100;
-LK.gui.top.addChild(comboText);
var instructionsTxt = new Text2('Tap the falling boxes!', {
size: 60,
fill: 0xFFFFFF
});
@@ -246,14 +241,16 @@
// Function to spawn a box
function spawnBox() {
var boxType;
var random = Math.random();
- if (random < 0.7) {
+ if (random < 0.65) {
boxType = 'regular';
- } else if (random < 0.9) {
+ } else if (random < 0.85) {
boxType = 'bonus';
- } else {
+ } else if (random < 0.95) {
boxType = 'special';
+ } else {
+ boxType = 'lineClear';
}
var box = new Box(boxType);
box.x = Math.random() * (2048 - 100) + 50; // Random x position
box.y = -100; // Start above the screen
@@ -274,15 +271,8 @@
});
boxes = [];
missedBoxes = 0;
LK.setScore(0);
- comboCount = 0;
- comboMultiplier = 1;
- if (comboTimer) {
- LK.clearTimeout(comboTimer);
- comboTimer = null;
- }
- comboText.setText('');
updateScoreDisplay();
// Start spawning boxes
spawnTimer = LK.setInterval(function () {
spawnBox();
@@ -356,9 +346,6 @@
}
if (difficultyTimer) {
LK.clearInterval(difficultyTimer);
}
- if (comboTimer) {
- LK.clearTimeout(comboTimer);
- }
LK.stopMusic();
};
\ No newline at end of file