User prompt
süre geçtikçe bombalar hızlansın
User prompt
hepside bomba olsun
User prompt
biraz daha yukardan gelen bir meteor yappp
User prompt
bunu aradan hızal gelen meteormuş gibi yap
Code edit (1 edits merged)
Please save this source code
User prompt
Bouncey Fruit Frenzy
Initial prompt
bana eğlenceli bir oyun yap
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Basket class var Basket = Container.expand(function () { var self = Container.call(this); self.asset = self.attachAsset('basket', { anchorX: 0.5, anchorY: 0.5 }); return self; }); // Fruit class var Fruit = Container.expand(function () { var self = Container.call(this); // Fruit types: apple, banana, orange, grape, golden, bomb self.type = 'apple'; // default, will be set on creation self.speed = 6; // will be set on creation self.points = 1; // will be set on creation // Attach asset based on type self.setType = function (type) { self.type = type; if (self.asset) { self.removeChild(self.asset); } var assetId = ''; if (type === 'apple') assetId = 'fruit_apple';else if (type === 'banana') assetId = 'fruit_banana';else if (type === 'orange') assetId = 'fruit_orange';else if (type === 'grape') assetId = 'fruit_grape';else if (type === 'golden') assetId = 'fruit_golden';else if (type === 'bomb') assetId = 'bomb'; self.asset = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 0.5 }); }; self.update = function () { self.y += self.speed; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a1a }); /**** * Game Code ****/ // Music // Sound effects // Basket // Bomb // Fruits // Game variables var basket = null; var fruits = []; var score = 0; var scoreTxt = null; var dragNode = null; var lastBasketX = 0; var gameSpeed = 1; var spawnInterval = 60; // ticks between spawns var ticksSinceLastSpawn = 0; var gameOver = false; // Fruit types and weights for random selection var fruitTypes = [{ type: 'apple', weight: 30, points: 1, speed: 12 }, { type: 'banana', weight: 25, points: 1, speed: 11 }, { type: 'orange', weight: 20, points: 2, speed: 13 }, { type: 'grape', weight: 15, points: 2, speed: 14 }, { type: 'bomb', weight: 10, points: 0, speed: 13 }, { type: 'golden', weight: 2, points: 5, speed: 15 }]; // Helper: pick a random fruit type based on weights function pickRandomFruitType() { var total = 0; for (var i = 0; i < fruitTypes.length; i++) total += fruitTypes[i].weight; var r = Math.random() * total; var acc = 0; for (var i = 0; i < fruitTypes.length; i++) { acc += fruitTypes[i].weight; if (r < acc) return fruitTypes[i]; } return fruitTypes[0]; } // Helper: spawn a fruit at random x function spawnFruit() { var fruitInfo = pickRandomFruitType(); var fruit = new Fruit(); fruit.setType(fruitInfo.type); fruit.points = fruitInfo.points; fruit.speed = fruitInfo.speed * gameSpeed; // Random x, but keep inside screen var margin = 80; var minX = margin; var maxX = 2048 - margin; fruit.x = minX + Math.random() * (maxX - minX); fruit.y = -100; fruits.push(fruit); game.addChild(fruit); } // Score text scoreTxt = new Text2('0', { size: 120, fill: "#fff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Basket basket = new Basket(); basket.x = 1024; basket.y = 2732 - 120; game.addChild(basket); // Move handler for dragging basket function handleMove(x, y, obj) { if (dragNode) { // Clamp basket inside screen var halfW = basket.asset.width / 2; var minX = halfW; var maxX = 2048 - halfW; dragNode.x = Math.max(minX, Math.min(maxX, x)); } } game.move = handleMove; // Down handler: start dragging if touch is on basket or near bottom game.down = function (x, y, obj) { // Only allow drag if touch is near basket (bottom 400px) if (y > 2732 - 400) { dragNode = basket; handleMove(x, y, obj); } }; game.up = function (x, y, obj) { dragNode = null; }; // Update function game.update = function () { if (gameOver) return; // Increase game speed as score increases if (score < 10) gameSpeed = 1;else if (score < 20) gameSpeed = 1.15;else if (score < 40) gameSpeed = 1.3;else if (score < 60) gameSpeed = 1.5;else gameSpeed = 1.7; // Spawn fruits ticksSinceLastSpawn++; var interval = Math.max(18, Math.floor(spawnInterval / gameSpeed)); if (ticksSinceLastSpawn >= interval) { spawnFruit(); ticksSinceLastSpawn = 0; } // Update fruits for (var i = fruits.length - 1; i >= 0; i--) { var fruit = fruits[i]; fruit.update(); // Check for collision with basket if (fruit.intersects(basket)) { if (fruit.type === 'bomb') { // Bomb caught: game over LK.getSound('bomb').play(); LK.effects.flashScreen(0xff0000, 800); gameOver = true; LK.showGameOver(); return; } else { // Fruit caught if (fruit.type === 'golden') { LK.getSound('golden').play(); LK.effects.flashObject(basket, 0xffe700, 600); } else { LK.getSound('catch').play(); LK.effects.flashObject(basket, 0xffffff, 200); } score += fruit.points; LK.setScore(score); scoreTxt.setText(score); // Remove fruit fruit.destroy(); fruits.splice(i, 1); continue; } } // Missed fruit (not bomb): if it falls below screen if (fruit.y > 2732 + 80) { if (fruit.type !== 'bomb') { // Missed a fruit: game over LK.effects.flashScreen(0xff0000, 800); gameOver = true; LK.showGameOver(); return; } else { // Bomb missed: just remove fruit.destroy(); fruits.splice(i, 1); continue; } } } }; // Play background music LK.playMusic('bgmusic');
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,225 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+// Basket class
+var Basket = Container.expand(function () {
+ var self = Container.call(this);
+ self.asset = self.attachAsset('basket', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ return self;
+});
+// Fruit class
+var Fruit = Container.expand(function () {
+ var self = Container.call(this);
+ // Fruit types: apple, banana, orange, grape, golden, bomb
+ self.type = 'apple'; // default, will be set on creation
+ self.speed = 6; // will be set on creation
+ self.points = 1; // will be set on creation
+ // Attach asset based on type
+ self.setType = function (type) {
+ self.type = type;
+ if (self.asset) {
+ self.removeChild(self.asset);
+ }
+ var assetId = '';
+ if (type === 'apple') assetId = 'fruit_apple';else if (type === 'banana') assetId = 'fruit_banana';else if (type === 'orange') assetId = 'fruit_orange';else if (type === 'grape') assetId = 'fruit_grape';else if (type === 'golden') assetId = 'fruit_golden';else if (type === 'bomb') assetId = 'bomb';
+ self.asset = self.attachAsset(assetId, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ };
+ self.update = function () {
+ self.y += self.speed;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x1a1a1a
+});
+
+/****
+* Game Code
+****/
+// Music
+// Sound effects
+// Basket
+// Bomb
+// Fruits
+// Game variables
+var basket = null;
+var fruits = [];
+var score = 0;
+var scoreTxt = null;
+var dragNode = null;
+var lastBasketX = 0;
+var gameSpeed = 1;
+var spawnInterval = 60; // ticks between spawns
+var ticksSinceLastSpawn = 0;
+var gameOver = false;
+// Fruit types and weights for random selection
+var fruitTypes = [{
+ type: 'apple',
+ weight: 30,
+ points: 1,
+ speed: 12
+}, {
+ type: 'banana',
+ weight: 25,
+ points: 1,
+ speed: 11
+}, {
+ type: 'orange',
+ weight: 20,
+ points: 2,
+ speed: 13
+}, {
+ type: 'grape',
+ weight: 15,
+ points: 2,
+ speed: 14
+}, {
+ type: 'bomb',
+ weight: 10,
+ points: 0,
+ speed: 13
+}, {
+ type: 'golden',
+ weight: 2,
+ points: 5,
+ speed: 15
+}];
+// Helper: pick a random fruit type based on weights
+function pickRandomFruitType() {
+ var total = 0;
+ for (var i = 0; i < fruitTypes.length; i++) total += fruitTypes[i].weight;
+ var r = Math.random() * total;
+ var acc = 0;
+ for (var i = 0; i < fruitTypes.length; i++) {
+ acc += fruitTypes[i].weight;
+ if (r < acc) return fruitTypes[i];
+ }
+ return fruitTypes[0];
+}
+// Helper: spawn a fruit at random x
+function spawnFruit() {
+ var fruitInfo = pickRandomFruitType();
+ var fruit = new Fruit();
+ fruit.setType(fruitInfo.type);
+ fruit.points = fruitInfo.points;
+ fruit.speed = fruitInfo.speed * gameSpeed;
+ // Random x, but keep inside screen
+ var margin = 80;
+ var minX = margin;
+ var maxX = 2048 - margin;
+ fruit.x = minX + Math.random() * (maxX - minX);
+ fruit.y = -100;
+ fruits.push(fruit);
+ game.addChild(fruit);
+}
+// Score text
+scoreTxt = new Text2('0', {
+ size: 120,
+ fill: "#fff"
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+// Basket
+basket = new Basket();
+basket.x = 1024;
+basket.y = 2732 - 120;
+game.addChild(basket);
+// Move handler for dragging basket
+function handleMove(x, y, obj) {
+ if (dragNode) {
+ // Clamp basket inside screen
+ var halfW = basket.asset.width / 2;
+ var minX = halfW;
+ var maxX = 2048 - halfW;
+ dragNode.x = Math.max(minX, Math.min(maxX, x));
+ }
+}
+game.move = handleMove;
+// Down handler: start dragging if touch is on basket or near bottom
+game.down = function (x, y, obj) {
+ // Only allow drag if touch is near basket (bottom 400px)
+ if (y > 2732 - 400) {
+ dragNode = basket;
+ handleMove(x, y, obj);
+ }
+};
+game.up = function (x, y, obj) {
+ dragNode = null;
+};
+// Update function
+game.update = function () {
+ if (gameOver) return;
+ // Increase game speed as score increases
+ if (score < 10) gameSpeed = 1;else if (score < 20) gameSpeed = 1.15;else if (score < 40) gameSpeed = 1.3;else if (score < 60) gameSpeed = 1.5;else gameSpeed = 1.7;
+ // Spawn fruits
+ ticksSinceLastSpawn++;
+ var interval = Math.max(18, Math.floor(spawnInterval / gameSpeed));
+ if (ticksSinceLastSpawn >= interval) {
+ spawnFruit();
+ ticksSinceLastSpawn = 0;
+ }
+ // Update fruits
+ for (var i = fruits.length - 1; i >= 0; i--) {
+ var fruit = fruits[i];
+ fruit.update();
+ // Check for collision with basket
+ if (fruit.intersects(basket)) {
+ if (fruit.type === 'bomb') {
+ // Bomb caught: game over
+ LK.getSound('bomb').play();
+ LK.effects.flashScreen(0xff0000, 800);
+ gameOver = true;
+ LK.showGameOver();
+ return;
+ } else {
+ // Fruit caught
+ if (fruit.type === 'golden') {
+ LK.getSound('golden').play();
+ LK.effects.flashObject(basket, 0xffe700, 600);
+ } else {
+ LK.getSound('catch').play();
+ LK.effects.flashObject(basket, 0xffffff, 200);
+ }
+ score += fruit.points;
+ LK.setScore(score);
+ scoreTxt.setText(score);
+ // Remove fruit
+ fruit.destroy();
+ fruits.splice(i, 1);
+ continue;
+ }
+ }
+ // Missed fruit (not bomb): if it falls below screen
+ if (fruit.y > 2732 + 80) {
+ if (fruit.type !== 'bomb') {
+ // Missed a fruit: game over
+ LK.effects.flashScreen(0xff0000, 800);
+ gameOver = true;
+ LK.showGameOver();
+ return;
+ } else {
+ // Bomb missed: just remove
+ fruit.destroy();
+ fruits.splice(i, 1);
+ continue;
+ }
+ }
+ }
+};
+// Play background music
+LK.playMusic('bgmusic');
\ No newline at end of file