User prompt
Her meyve toplandığında skor 10 artsın
User prompt
Sepet hareket hızını %30 oranında artır
User prompt
Biraz azalt
User prompt
Sepet hareket hızını artır
User prompt
Tüm meyvelerin hareket hızı aynı olsun
User prompt
Eğer skor +50 olursa meyve ve sepetin hareket etme hızını %100 olarak artır
User prompt
Butona basınca daha pürüzsüz bir hareket olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Sepeti hareket etirebilecek iki buton olsun sağ ve sol
User prompt
Sepet x yönünde hareket edebilsin
User prompt
Meyveler yere sepeti geçerse skor -5 olarak azalsın
User prompt
Meyveler belirli bir süreden sonra kaybolmasın
User prompt
Sepet sadece x yönünde hareket etsin
User prompt
Meyveler yukarıdan rastgele aralıklarla yağsın
Code edit (1 edits merged)
Please save this source code
User prompt
Meyve Topla!
Initial prompt
Meyve toplama oyunu yap
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Fruit class: represents a collectible fruit
var Fruit = Container.expand(function () {
var self = Container.call(this);
// Randomly pick a fruit color for variety
var fruitColors = [0xff3b3b, 0xffe14d, 0x4de14d, 0x4db8ff, 0xff7ff0];
var color = fruitColors[Math.floor(Math.random() * fruitColors.length)];
// Create a simple ellipse as fruit
var fruitAsset = self.attachAsset('fruit', {
width: 120,
height: 120,
color: color,
shape: 'ellipse',
anchorX: 0.5,
anchorY: 0.5
});
// Used for animation
self.alpha = 0;
self.scaleX = 0.7;
self.scaleY = 0.7;
// Animate fruit appearing
tween(self, {
alpha: 1,
scaleX: 1,
scaleY: 1
}, {
duration: 200,
easing: tween.easeOut
});
// For tracking if already collected
self.collected = false;
// Destroy with a pop animation
self.collect = function (_onFinish) {
if (self.collected) return;
self.collected = true;
tween(self, {
scaleX: 1.4,
scaleY: 1.4,
alpha: 0
}, {
duration: 180,
easing: tween.easeIn,
onFinish: function onFinish() {
self.destroy();
if (_onFinish) _onFinish();
}
});
};
return self;
});
// Player class: draggable character
var Player = Container.expand(function () {
var self = Container.call(this);
// Character is a colored box
var playerAsset = self.attachAsset('player', {
width: 140,
height: 140,
color: 0x3b7fff,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5
});
// For a little style, add a face (ellipse for head, two eyes)
var face = self.attachAsset('face', {
width: 80,
height: 80,
color: 0xfffbe0,
shape: 'ellipse',
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -10
});
var eyeL = self.attachAsset('eyeL', {
width: 12,
height: 12,
color: 0x222222,
shape: 'ellipse',
anchorX: 0.5,
anchorY: 0.5,
x: -18,
y: -18
});
var eyeR = self.attachAsset('eyeR', {
width: 12,
height: 12,
color: 0x222222,
shape: 'ellipse',
anchorX: 0.5,
anchorY: 0.5,
x: 18,
y: -18
});
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xf7f7f7
});
/****
* Game Code
****/
// Game constants
// Tween plugin for fruit spawn/collect animations
var GAME_WIDTH = 2048;
var GAME_HEIGHT = 2732;
var FRUIT_SPAWN_MIN = 900; // ms
var FRUIT_SPAWN_MAX = 1800; // ms
var FRUIT_LIFETIME = 2600; // ms before fruit disappears
var WIN_SCORE = 20;
var FRUIT_FALL_SPEED = 12; // All fruits fall at this speed (px/frame)
// Game state
var fruits = [];
var player = null;
var dragNode = null;
var score = 0;
var scoreTxt = null;
var spawnTimer = null;
var fruitSpawnInterval = FRUIT_SPAWN_MAX;
var lastTouch = {
x: GAME_WIDTH / 2,
y: GAME_HEIGHT * 0.8
};
// Set up background color
game.setBackgroundColor(0xf7f7f7);
// Create and position player
player = new Player();
player.x = GAME_WIDTH / 2;
player.y = GAME_HEIGHT * 0.8;
game.addChild(player);
// Score text
scoreTxt = new Text2('0', {
size: 120,
fill: 0x222222
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// --- Add left/right move buttons ---
var buttonSize = 220;
var buttonMargin = 80;
var buttonY = GAME_HEIGHT - buttonSize - 80;
// Left button
var leftBtn = LK.getAsset('player', {
width: buttonSize,
height: buttonSize,
color: 0x3b7fff,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5,
x: buttonMargin + buttonSize / 2,
y: buttonY
});
var leftArrow = new Text2('◀', {
size: 160,
fill: "#fff"
});
leftArrow.anchor.set(0.5, 0.5);
leftArrow.x = leftBtn.width / 2;
leftArrow.y = leftBtn.height / 2;
leftBtn.addChild(leftArrow);
// Right button
var rightBtn = LK.getAsset('player', {
width: buttonSize,
height: buttonSize,
color: 0x3b7fff,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5,
x: GAME_WIDTH - buttonMargin - buttonSize / 2,
y: buttonY
});
var rightArrow = new Text2('▶', {
size: 160,
fill: "#fff"
});
rightArrow.anchor.set(0.5, 0.5);
rightArrow.x = rightBtn.width / 2;
rightArrow.y = rightBtn.height / 2;
rightBtn.addChild(rightArrow);
// Add to game
game.addChild(leftBtn);
game.addChild(rightBtn);
// Button press logic
var moveBtnInterval = null;
var MOVE_STEP = Math.round(48 * 1.3); // 30% faster
var MOVE_INTERVAL = Math.round(36 / 1.3); // 30% faster (lower interval)
function movePlayerDir(dir) {
var moveMultiplier = score >= 50 ? 2 : 1;
var px = Math.max(70, Math.min(GAME_WIDTH - 70, player.x + dir * MOVE_STEP * moveMultiplier));
// Stop any previous tween on player.x to avoid stacking
tween.stop(player, {
x: true
});
tween(player, {
x: px
}, {
duration: Math.round(180 / 1.3) / moveMultiplier,
// 30% faster
easing: tween.cubicOut
});
lastTouch.x = px;
lastTouch.y = player.y;
}
// Touch/hold left
leftBtn.down = function (x, y, obj) {
movePlayerDir(-1);
if (moveBtnInterval) LK.clearInterval(moveBtnInterval);
moveBtnInterval = LK.setInterval(function () {
movePlayerDir(-1);
}, MOVE_INTERVAL);
};
leftBtn.up = function (x, y, obj) {
if (moveBtnInterval) LK.clearInterval(moveBtnInterval);
moveBtnInterval = null;
};
// Touch/hold right
rightBtn.down = function (x, y, obj) {
movePlayerDir(1);
if (moveBtnInterval) LK.clearInterval(moveBtnInterval);
moveBtnInterval = LK.setInterval(function () {
movePlayerDir(1);
}, MOVE_INTERVAL);
};
rightBtn.up = function (x, y, obj) {
if (moveBtnInterval) LK.clearInterval(moveBtnInterval);
moveBtnInterval = null;
};
// Helper: update score display
function updateScore() {
scoreTxt.setText(score);
}
// Helper: spawn a fruit at a random X position at the top, and make it fall down
function spawnFruit() {
// Avoid top 100px (menu), and bottom 200px (player area)
var margin = 140;
var minX = margin;
var maxX = GAME_WIDTH - margin;
var fruit = new Fruit();
fruit.x = Math.floor(Math.random() * (maxX - minX)) + minX;
fruit.y = 120; // Always spawn at the top
// All fruits have the same fall speed, controlled by a single variable
fruit.fallSpeed = FRUIT_FALL_SPEED;
// Track lastY for good practice
fruit.lastY = fruit.y;
fruits.push(fruit);
game.addChild(fruit);
// Fruit will only be removed if collected or falls below the screen
}
// Helper: schedule next fruit spawn, with increasing speed
function scheduleNextFruit() {
// As score increases, spawn interval decreases
var minInterval = FRUIT_SPAWN_MIN;
var maxInterval = FRUIT_SPAWN_MAX;
var progress = Math.min(score / WIN_SCORE, 1);
fruitSpawnInterval = maxInterval - (maxInterval - minInterval) * progress;
var nextIn = Math.floor(fruitSpawnInterval * (0.7 + Math.random() * 0.6)); // randomize a bit
spawnTimer = LK.setTimeout(function () {
spawnFruit();
scheduleNextFruit();
}, nextIn);
}
// Start spawning fruits
scheduleNextFruit();
// Dragging logic
game.down = function (x, y, obj) {
// Only start drag if touch is on player (or close to it)
var dx = x - player.x;
var dy = y - player.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 120) {
dragNode = player;
lastTouch.x = x;
lastTouch.y = y;
}
};
game.move = function (x, y, obj) {
if (dragNode === player) {
// Allow player to move only in X direction, clamp within game area
var moveMultiplier = score >= 50 ? 2 : 1;
var px = Math.max(70, Math.min(GAME_WIDTH - 70, x));
// Stop any previous tween on player.x to avoid stacking
tween.stop(player, {
x: true
});
tween(player, {
x: px
}, {
duration: Math.round(90 / 1.3) / moveMultiplier,
// 30% faster
easing: tween.cubicOut
});
// Y stays fixed at initial position (bottom 20% of screen)
lastTouch.x = px;
lastTouch.y = player.y;
}
};
game.up = function (x, y, obj) {
dragNode = null;
};
// Main update loop: check for fruit collection
game.update = function () {
// Update fruit fall speed if score >= 50
if (score >= 50) {
FRUIT_FALL_SPEED = 24;
} else {
FRUIT_FALL_SPEED = 12;
}
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
if (fruit.collected) continue;
// Move fruit down
fruit.lastY = fruit.lastY === undefined ? fruit.y : fruit.lastY;
fruit.y += fruit.fallSpeed;
// Remove fruit if it falls below the screen (bottom margin)
if (fruit.lastY <= GAME_HEIGHT - 120 && fruit.y > GAME_HEIGHT - 120) {
if (!fruit.collected) {
// Decrease score by 5 if missed
score -= 5;
if (score < 0) score = 0;
updateScore();
fruit.collect(function () {
// Remove from array
for (var j = 0; j < fruits.length; j++) {
if (fruits[j] === fruit) {
fruits.splice(j, 1);
break;
}
}
});
}
// Cancel fruit timeout
if (fruit._timeout) LK.clearTimeout(fruit._timeout);
continue;
}
// Check intersection with player
if (player.intersects(fruit)) {
fruit.collect(function () {
// Remove from array
for (var j = 0; j < fruits.length; j++) {
if (fruits[j] === fruit) {
fruits.splice(j, 1);
break;
}
}
});
// Cancel fruit timeout
if (fruit._timeout) LK.clearTimeout(fruit._timeout);
// Add score
score += 10;
updateScore();
// Win condition
if (score >= WIN_SCORE) {
// Flash green, show win
LK.effects.flashScreen(0x44ff44, 800);
LK.showYouWin();
return;
}
}
fruit.lastY = fruit.y;
}
};
// On game over or win, cleanup timers
game.onDestroy = function () {
if (spawnTimer) LK.clearTimeout(spawnTimer);
for (var i = 0; i < fruits.length; i++) {
if (fruits[i]._timeout) LK.clearTimeout(fruits[i]._timeout);
}
fruits = [];
};
// Initial score
updateScore(); ===================================================================
--- original.js
+++ change.js
@@ -356,9 +356,9 @@
});
// Cancel fruit timeout
if (fruit._timeout) LK.clearTimeout(fruit._timeout);
// Add score
- score += 1;
+ score += 10;
updateScore();
// Win condition
if (score >= WIN_SCORE) {
// Flash green, show win
Start button . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Settings button. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Left right button. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
A hand. In-Game asset. High contrast. No shadows. 2 d
Between two button a hand. In-Game asset. 2d. High contrast. No shadows
A farm. In-Game asset. 2d. High contrast. No shadows
Left button. In-Game asset. 2d. High contrast. No shadows
Devam et. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Basket. In-Game asset. 2d. High contrast. No shadows
Banana. In-Game asset. 2d. High contrast. No shadows
Left button. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Apple. In-Game asset. 2d. High contrast. No shadows
Grape. In-Game asset. 2d. High contrast. No shadows
Potato. In-Game asset. 2d. High contrast. No shadows