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 Fruit = Container.expand(function (fruitType) {
var self = Container.call(this);
var fruitGraphics = self.attachAsset(fruitType, {
anchorX: 0.5,
anchorY: 0.5
});
self.fallSpeed = 4 + Math.random() * 3;
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
****/
var ninja = game.addChild(new Ninja());
ninja.x = 2048 / 2;
ninja.y = 2732 - 200;
var fruits = [];
var fruitTypes = ['apple', 'banana', 'orange', 'grape'];
var spawnTimer = 0;
var spawnInterval = 90;
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 < 60) dragNode.x = 60;
if (dragNode.x > 2048 - 60) dragNode.x = 2048 - 60;
}
}
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);
}
game.update = function () {
spawnTimer++;
difficultyTimer++;
// Increase difficulty over time
if (difficultyTimer % 1800 == 0 && spawnInterval > 30) {
spawnInterval -= 5;
}
// Spawn fruits
if (spawnTimer >= spawnInterval) {
spawnFruit();
spawnTimer = 0;
// Occasionally spawn multiple fruits
if (Math.random() < 0.3) {
LK.setTimeout(function () {
spawnFruit();
}, 20);
}
}
// 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) {
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;
}
};
LK.playMusic('bgmusic'); ===================================================================
--- original.js
+++ change.js
@@ -71,15 +71,14 @@
dragNode = null;
};
function spawnFruit() {
var randomType = fruitTypes[Math.floor(Math.random() * fruitTypes.length)];
- var newFruit = new Fruit(randomType);
+ 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);
- game.addChild(newFruit);
}
game.update = function () {
spawnTimer++;
difficultyTimer++;
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