User prompt
make it so that sometimes in hardcore mode there is a 10 percent chance that a fruit will dodge the pencil
User prompt
oh, and in hardcore mode the pencil is also thrown faster
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'speed')' in or related to this line: 'pencil.speed *= storage.hardcoreMode ? 3 : 2;' Line Number: 687
User prompt
hardcore mode is very buggy, when you hit a fruit, you can earn infinite points without clicking anything
User prompt
Add settings hardcore mode. When you activate it, an emoji appears saying: "Are you sure?" Then you have to choose yes or no, and when you press yes, the fruits become much harder to hit and much faster.
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'self.parent.parent.addChild(new Shop());' Line Number: 350
User prompt
Pencil skins name:pencil picnic mat, golden pencil, wax pencil, remote control pencil and pencil case.
User prompt
Add shop, coins and skins. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Let's add the new things
User prompt
Add the new fruits
User prompt
Stop level up sound, is so repetitive
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'stop')' in or related to this line: 'pencil.glowTween.stop();' Line Number: 162 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Let's polish this game
User prompt
Let's polish this game
User prompt
when it gets dark, the fruits give a dash
User prompt
make it so that when you destroy 10 fruits, this happens. and the screen goes black to make it difficult
User prompt
make it so that when you level up, the screen goes dark, and adds light to the fruit
User prompt
make the bg change from time to time
User prompt
Add sound
User prompt
make the initial movement of the fruit change randomly
User prompt
add LK score
User prompt
make the fruit faster than the pencil
User prompt
make the fruit move back and forth too. to make it harder
User prompt
make the fruit move too
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'var tempX = realFruit.x;' Line Number: 110
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Fruit = Container.expand(function () { var self = Container.call(this); // Randomly select a fruit type var fruitTypes = ['Apple', 'Banana', 'pineapple', 'sleeve']; var randomFruit = fruitTypes[Math.floor(Math.random() * fruitTypes.length)]; // Attach the selected fruit image asset to the container var fruitGraphics = self.attachAsset(randomFruit, { anchorX: 0.5, anchorY: 0.5, scaleX: 5, // Scale fruit 5x horizontally scaleY: 5 // Scale fruit 5x vertically }); // Set initial position of the fruit in the middle of the screen self.x = 1024; // Center horizontally self.y = 1366; // Center vertically // Add update method to move the fruit left and right self.update = function () { // Gradually increase speed over time if (Math.abs(self.speed) < 40) { self.speed *= 1.0005; } // Move fruit left and right if (self.x <= 0 || self.x >= 2048) { self.speed = -self.speed; // Reverse direction when hitting screen edges } self.x += self.speed; }; // Randomly set initial direction of the fruit self.speed = Math.random() < 0.5 ? 20 : -20; // Initial speed of the fruit, faster than the pencil }); var Pencil = Container.expand(function () { var self = Container.call(this); // Attach the pencil image asset to the container var pencilGraphics = self.attachAsset('Pencil', { anchorX: 0.5, anchorY: 0.5 }); // Set initial position of the pencil self.x = 1024; // Center horizontally self.y = 0; // Position at the top of the screen // Add update method to move the pencil left and right self.update = function () { // Move pencil left and right if (self.x <= 0 || self.x >= 2048) { self.speed = -self.speed; // Reverse direction when hitting screen edges } self.x += self.speed; }; self.speed = 15; // Initial speed of the pencil }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var bg = LK.getAsset('Bg', { anchorX: 0.5, anchorY: 0.5, scaleX: 2048 / 100, // Scale to fit the screen width scaleY: 2732 / 100, // Scale to fit the screen height // Scale to fit 720p height x: 2048 / 2, // Center horizontally y: 2732 / 2 // Center vertically }); game.addChild(bg); var pencil = game.addChild(new Pencil()); var fruit = game.addChild(new Fruit()); // Initialize score display var scoreTxt = new Text2('0', { size: 150, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Initialize combo counter var comboCount = 0; var comboTxt = new Text2('', { size: 100, fill: 0xFFFF00 }); comboTxt.anchor.set(0.5, 0); comboTxt.y = 180; LK.gui.top.addChild(comboTxt); fruit.lastWasIntersecting = false; // Add event listener for screen touch to throw the pencil down game.down = function (x, y, obj) { pencil.speed = 20; // Set a downward speed for the pencil pencil.update = function () { // Move pencil down pencil.y += pencil.speed; }; // Play background music LK.playMusic('Levelup', { volume: 0.3 }); }; // Ensure the game updates the pencil's position every tick game.update = function () { pencil.update(); fruit.update(); // Check if the pencil has missed the target (e.g., gone off-screen) if (pencil.y > 2732) { // Reset combo comboCount = 0; comboTxt.setText(''); // Trigger game over if the pencil misses the target LK.showGameOver(); } else if (fruit.lastWasIntersecting === false && pencil.intersects(fruit)) { // Destroy the pencil after it touches a fruit pencil.destroy(); // Double the pencil speed with each fruit destroyed pencil.speed *= 2; // Play hit sound LK.getSound('Hit').play(); // Screen shake effect var shakeAmount = 20; var originalX = game.x; var originalY = game.y; var shakeCount = 0; var shakeInterval = LK.setInterval(function () { if (shakeCount < 6) { game.x = originalX + (Math.random() - 0.5) * shakeAmount; game.y = originalY + (Math.random() - 0.5) * shakeAmount; shakeCount++; } else { game.x = originalX; game.y = originalY; LK.clearInterval(shakeInterval); } }, 50); // Darken the screen var darkOverlay = LK.getAsset('Bg', { anchorX: 0.5, anchorY: 0.5, scaleX: 2048 / 100, scaleY: 2732 / 100, x: 2048 / 2, y: 2732 / 2, tint: 0x000000, alpha: 0.5 }); game.addChild(darkOverlay); // Remove dark overlay after a short duration LK.setTimeout(function () { darkOverlay.destroy(); }, 1000); // Update score and combo comboCount++; LK.setScore(LK.getScore() + comboCount); scoreTxt.setText(LK.getScore()); // Update combo display if (comboCount > 1) { comboTxt.setText('COMBO x' + comboCount); // Animate combo text tween(comboTxt, { scaleX: 1.5, scaleY: 1.5 }, { duration: 200, onFinish: function onFinish() { tween(comboTxt, { scaleX: 1, scaleY: 1 }, { duration: 200 }); } }); } // Check if 10 fruits have been destroyed if (LK.getScore() % 10 === 0) { // Play level up sound LK.getSound('Levelup').play(); // Increase fruit speed for a dash effect fruit.speed *= 2; // Reset fruit speed after a short duration LK.setTimeout(function () { fruit.speed /= 2; }, 1000); // Darken the screen var darkOverlay = LK.getAsset('Bg', { anchorX: 0.5, anchorY: 0.5, scaleX: 2048 / 100, scaleY: 2732 / 100, x: 2048 / 2, y: 2732 / 2, tint: 0x000000, alpha: 0.8 }); game.addChild(darkOverlay); // Add light effect to the fruit var light = LK.getAsset('Light', { anchorX: 0.5, anchorY: 0.5, scaleX: 10, scaleY: 10, x: fruit.x, y: fruit.y }); game.addChild(light); // Animate light effect tween(light, { alpha: 0 }, { duration: 1000, onFinish: function onFinish() { light.destroy(); } }); // Remove dark overlay after a short duration LK.setTimeout(function () { darkOverlay.destroy(); }, 1000); } // Create a new pencil pencil = game.addChild(new Pencil()); // Create particle effects when fruit is hit for (var i = 0; i < 5; i++) { var particle = LK.getAsset('Light', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2, x: fruit.x + (Math.random() - 0.5) * 100, y: fruit.y + (Math.random() - 0.5) * 100, tint: [0xffff00, 0xff0000, 0x00ff00][Math.floor(Math.random() * 3)] }); game.addChild(particle); // Animate particles tween(particle, { x: particle.x + (Math.random() - 0.5) * 200, y: particle.y - Math.random() * 200, alpha: 0, scaleX: 0.5, scaleY: 0.5 }, { duration: 800, onFinish: function onFinish() { particle.destroy(); } }); } // Bounce animation on fruit hit tween(fruit, { scaleX: 6, scaleY: 6 }, { duration: 300, easing: tween.bounceOut, onFinish: function onFinish() { tween(fruit, { scaleX: 5, scaleY: 5 }, { duration: 300, easing: tween.bounceIn, onFinish: function onFinish() { // Create a new fruit after the animation finishes fruit.destroy(); fruit = game.addChild(new Fruit()); // Add light effect to the fruit var light = LK.getAsset('Light', { anchorX: 0.5, anchorY: 0.5, scaleX: 10, scaleY: 10, x: fruit.x, y: fruit.y }); game.addChild(light); // Animate light effect tween(light, { alpha: 0 }, { duration: 1000, onFinish: function onFinish() { light.destroy(); } }); } }); } }); } fruit.lastWasIntersecting = pencil.intersects(fruit); };
===================================================================
--- original.js
+++ change.js
@@ -23,8 +23,12 @@
self.x = 1024; // Center horizontally
self.y = 1366; // Center vertically
// Add update method to move the fruit left and right
self.update = function () {
+ // Gradually increase speed over time
+ if (Math.abs(self.speed) < 40) {
+ self.speed *= 1.0005;
+ }
// Move fruit left and right
if (self.x <= 0 || self.x >= 2048) {
self.speed = -self.speed; // Reverse direction when hitting screen edges
}
@@ -85,23 +89,39 @@
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
+// Initialize combo counter
+var comboCount = 0;
+var comboTxt = new Text2('', {
+ size: 100,
+ fill: 0xFFFF00
+});
+comboTxt.anchor.set(0.5, 0);
+comboTxt.y = 180;
+LK.gui.top.addChild(comboTxt);
fruit.lastWasIntersecting = false;
// Add event listener for screen touch to throw the pencil down
game.down = function (x, y, obj) {
pencil.speed = 20; // Set a downward speed for the pencil
pencil.update = function () {
// Move pencil down
pencil.y += pencil.speed;
};
+ // Play background music
+ LK.playMusic('Levelup', {
+ volume: 0.3
+ });
};
// Ensure the game updates the pencil's position every tick
game.update = function () {
pencil.update();
fruit.update();
// Check if the pencil has missed the target (e.g., gone off-screen)
if (pencil.y > 2732) {
+ // Reset combo
+ comboCount = 0;
+ comboTxt.setText('');
// Trigger game over if the pencil misses the target
LK.showGameOver();
} else if (fruit.lastWasIntersecting === false && pencil.intersects(fruit)) {
// Destroy the pencil after it touches a fruit
@@ -109,8 +129,24 @@
// Double the pencil speed with each fruit destroyed
pencil.speed *= 2;
// Play hit sound
LK.getSound('Hit').play();
+ // Screen shake effect
+ var shakeAmount = 20;
+ var originalX = game.x;
+ var originalY = game.y;
+ var shakeCount = 0;
+ var shakeInterval = LK.setInterval(function () {
+ if (shakeCount < 6) {
+ game.x = originalX + (Math.random() - 0.5) * shakeAmount;
+ game.y = originalY + (Math.random() - 0.5) * shakeAmount;
+ shakeCount++;
+ } else {
+ game.x = originalX;
+ game.y = originalY;
+ LK.clearInterval(shakeInterval);
+ }
+ }, 50);
// Darken the screen
var darkOverlay = LK.getAsset('Bg', {
anchorX: 0.5,
anchorY: 0.5,
@@ -125,13 +161,35 @@
// Remove dark overlay after a short duration
LK.setTimeout(function () {
darkOverlay.destroy();
}, 1000);
- // Update score
- LK.setScore(LK.getScore() + 1);
+ // Update score and combo
+ comboCount++;
+ LK.setScore(LK.getScore() + comboCount);
scoreTxt.setText(LK.getScore());
+ // Update combo display
+ if (comboCount > 1) {
+ comboTxt.setText('COMBO x' + comboCount);
+ // Animate combo text
+ tween(comboTxt, {
+ scaleX: 1.5,
+ scaleY: 1.5
+ }, {
+ duration: 200,
+ onFinish: function onFinish() {
+ tween(comboTxt, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 200
+ });
+ }
+ });
+ }
// Check if 10 fruits have been destroyed
if (LK.getScore() % 10 === 0) {
+ // Play level up sound
+ LK.getSound('Levelup').play();
// Increase fruit speed for a dash effect
fruit.speed *= 2;
// Reset fruit speed after a short duration
LK.setTimeout(function () {
@@ -174,8 +232,34 @@
}, 1000);
}
// Create a new pencil
pencil = game.addChild(new Pencil());
+ // Create particle effects when fruit is hit
+ for (var i = 0; i < 5; i++) {
+ var particle = LK.getAsset('Light', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 2,
+ scaleY: 2,
+ x: fruit.x + (Math.random() - 0.5) * 100,
+ y: fruit.y + (Math.random() - 0.5) * 100,
+ tint: [0xffff00, 0xff0000, 0x00ff00][Math.floor(Math.random() * 3)]
+ });
+ game.addChild(particle);
+ // Animate particles
+ tween(particle, {
+ x: particle.x + (Math.random() - 0.5) * 200,
+ y: particle.y - Math.random() * 200,
+ alpha: 0,
+ scaleX: 0.5,
+ scaleY: 0.5
+ }, {
+ duration: 800,
+ onFinish: function onFinish() {
+ particle.destroy();
+ }
+ });
+ }
// Bounce animation on fruit hit
tween(fruit, {
scaleX: 6,
scaleY: 6
Pencil. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
picnic bg. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
heart icon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
mango fruit with eye and mouth animation.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Banana with eye and mouth animation.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
picnic bg in a night sky. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Watermelon with eye and mouth animation. In-Game asset. 2d. High contrast. No shadows
Orange with eye and mouth animation. In-Game asset. 2d. High contrast. No shadows
Shop icon. In-Game asset. 2d. High contrast. No shadows
Coin icon. In-Game asset. 2d. High contrast. No shadows
Emoji_shocked. In-Game asset. 2d. High contrast. No shadows
Settings icon. In-Game asset. 2d. High contrast. No shadows