User prompt
Bombalar biraz daha hızlı düşsün
User prompt
Müzik sesi gelmiyor usta.
User prompt
Arkada düşük sesle çalan bir fon müziği olsun.
User prompt
Oyunda ayrıca gökten arada sırada bombalar düşsün.Eğer ninja bombalara değerse -100 puan alsın.
User prompt
Ninja platformun biraz daha üstünde dursun.
User prompt
Tahta görünümlü bir arka plan ekleyelim.Ayrıca ninja odundan yapılmış bir platformda hareket etsin.
User prompt
Meyveler biraz daha hızlı düşsün ve meyveleri yakalayamazsak -50 puan alalım.
User prompt
Ninjanın ve meyvelerin boyutunu 3 kay büyütelim. Ayrıca meyveler 2 kat daha hızlı düşsün. Süre ilerledikçe daha fazla meyve düşsün.
User prompt
Meyveler biraz daha hızlı düşsün fakat yukarıdan düşen meyve sayısını azalt.
User prompt
Hocam kodlarda hata var herhalde.Tekrar dener misin?
Code edit (1 edits merged)
Please save this source code
User prompt
Ninja Fruit Catcher
Initial prompt
Gardaş,oyunmuzda bir ninja karakter olsun.Yukarıdan birkaç meyve düşsün.Ninja bu meyvelere değdiğinde puan kazansın.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bomb = Container.expand(function () {
var self = Container.call(this);
var bombGraphics = self.attachAsset('bomb', {
anchorX: 0.5,
anchorY: 0.5
});
self.fallSpeed = 25 + Math.random() * 15;
self.penalty = 100;
self.update = function () {
self.y += self.fallSpeed;
};
return self;
});
var Fruit = Container.expand(function (fruitType) {
var self = Container.call(this);
var fruitGraphics = self.attachAsset(fruitType, {
anchorX: 0.5,
anchorY: 0.5
});
self.fallSpeed = 18 + Math.random() * 12;
self.points = 10;
self.fruitType = fruitType;
self.update = function () {
self.y += self.fallSpeed;
};
return self;
});
var Ninja = Container.expand(function () {
var self = Container.call(this);
var ninjaGraphics = self.attachAsset('ninja', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Add wooden background
var woodenBg = game.addChild(LK.getAsset('woodenBackground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
// Add wooden platform
var woodenPlatform = game.addChild(LK.getAsset('woodenPlatform', {
anchorX: 0.5,
anchorY: 1,
x: 2048 / 2,
y: 2732 - 50
}));
var ninja = game.addChild(new Ninja());
ninja.x = 2048 / 2;
ninja.y = 2732 - 350; // Position ninja higher above the platform
var fruits = [];
var bombs = [];
var fruitTypes = ['apple', 'banana', 'orange', 'grape'];
var spawnTimer = 0;
var spawnInterval = 120;
var bombSpawnTimer = 0;
var bombSpawnInterval = 300;
var difficultyTimer = 0;
var scoreTxt = new Text2('Score: 0', {
size: 100,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var dragNode = null;
function handleMove(x, y, obj) {
if (dragNode) {
dragNode.x = x;
if (dragNode.x < 180) dragNode.x = 180;
if (dragNode.x > 2048 - 180) dragNode.x = 2048 - 180;
}
}
game.move = handleMove;
game.down = function (x, y, obj) {
dragNode = ninja;
handleMove(x, y, obj);
};
game.up = function (x, y, obj) {
dragNode = null;
};
function spawnFruit() {
var randomType = fruitTypes[Math.floor(Math.random() * fruitTypes.length)];
var newFruit = game.addChild(new Fruit(randomType));
newFruit.x = 100 + Math.random() * (2048 - 200);
newFruit.y = -50;
newFruit.lastY = newFruit.y;
newFruit.lastIntersecting = false;
fruits.push(newFruit);
}
function spawnBomb() {
var newBomb = game.addChild(new Bomb());
newBomb.x = 100 + Math.random() * (2048 - 200);
newBomb.y = -50;
newBomb.lastY = newBomb.y;
newBomb.lastIntersecting = false;
bombs.push(newBomb);
}
game.update = function () {
spawnTimer++;
bombSpawnTimer++;
difficultyTimer++;
// Increase difficulty over time
if (difficultyTimer % 1800 == 0 && spawnInterval > 30) {
spawnInterval -= 5;
}
// Spawn fruits with increasing frequency
var fruitsToSpawn = 1;
if (difficultyTimer > 3600) fruitsToSpawn = 2; // After 1 minute, spawn 2 fruits
if (difficultyTimer > 7200) fruitsToSpawn = 3; // After 2 minutes, spawn 3 fruits
if (difficultyTimer > 10800) fruitsToSpawn = 4; // After 3 minutes, spawn 4 fruits
if (spawnTimer >= spawnInterval) {
for (var j = 0; j < fruitsToSpawn; j++) {
spawnFruit();
}
spawnTimer = 0;
}
// Spawn bombs occasionally
if (bombSpawnTimer >= bombSpawnInterval) {
spawnBomb();
bombSpawnTimer = 0;
}
// Update fruits
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
// Check if fruit went off screen
if (fruit.lastY < 2732 + 100 && fruit.y >= 2732 + 100) {
// Penalty for missing fruit
LK.setScore(LK.getScore() - 50);
scoreTxt.setText('Score: ' + LK.getScore());
fruit.destroy();
fruits.splice(i, 1);
continue;
}
// Check collision with ninja
var currentIntersecting = fruit.intersects(ninja);
if (!fruit.lastIntersecting && currentIntersecting) {
LK.setScore(LK.getScore() + fruit.points);
scoreTxt.setText('Score: ' + LK.getScore());
LK.getSound('catch').play();
// Visual feedback
tween(fruit, {
scaleX: 1.5,
scaleY: 1.5,
alpha: 0
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
fruit.destroy();
}
});
fruits.splice(i, 1);
continue;
}
fruit.lastY = fruit.y;
fruit.lastIntersecting = currentIntersecting;
}
// Update bombs
for (var k = bombs.length - 1; k >= 0; k--) {
var bomb = bombs[k];
// Check if bomb went off screen
if (bomb.lastY < 2732 + 100 && bomb.y >= 2732 + 100) {
bomb.destroy();
bombs.splice(k, 1);
continue;
}
// Check collision with ninja
var bombIntersecting = bomb.intersects(ninja);
if (!bomb.lastIntersecting && bombIntersecting) {
LK.setScore(LK.getScore() - bomb.penalty);
scoreTxt.setText('Score: ' + LK.getScore());
// Flash effect for bomb hit
LK.effects.flashScreen(0xFF0000, 500);
bomb.destroy();
bombs.splice(k, 1);
continue;
}
bomb.lastY = bomb.y;
bomb.lastIntersecting = bombIntersecting;
}
};
LK.playMusic('bgmusic'); ===================================================================
--- original.js
+++ change.js
@@ -11,9 +11,9 @@
var bombGraphics = self.attachAsset('bomb', {
anchorX: 0.5,
anchorY: 0.5
});
- self.fallSpeed = 15 + Math.random() * 10;
+ self.fallSpeed = 25 + Math.random() * 15;
self.penalty = 100;
self.update = function () {
self.y += self.fallSpeed;
};
An apple. 2d. High contrast. No shadows
Banana. 2d. High contrast. No shadows
An orange. 2d. High contrast. No shadows
A grape. 2d. High contrast. No shadows
Cute Ninja. 2d. High contrast. No shadows
Wooden Background
A bomb. In-Game asset. 2d. High contrast. No shadows
A dragonfruit. In-Game asset. 2d. High contrast. No shadows
Wooden platfom straigth. In-Game asset. 2d. High contrast. No shadows
A watermelon. In-Game asset. 2d. High contrast. No shadows
A health kit. In-Game asset. 2d. High contrast. No shadows