User prompt
karakter play again diyene kadar müzik devam etsin
User prompt
sol için a tuşu ekle
User prompt
yön tuşları ile haraket etsin karakter
Code edit (1 edits merged)
Please save this source code
User prompt
Fruit Transformation Adventure
Initial prompt
oyuna ana menü yükle başla veya çıkış diye alt altta 2 seçenek olucak oyun başladığında karakter sağ sola gidebilir sadece aynı meyveden 10 tane yerse o mevyeye dönüşür ama başka bir meyveye dokunursa sıfırlanır bombaya çarpar ise ses efekti çıksın kaybettin diyip arkaya üzücü bir müzik ekle skor en sol yukarda gözüksün durdurma ekranı en sağ yukarda oyuna bir müzik ekle en sağ yukardaki durdurma ekranından müzik sesini kısabilir veya yükseltebilsin
/**** * 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.speed = 4 + Math.random() * 3; self.update = function () { self.y += self.speed; }; 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.fruitType = fruitType; self.speed = 3 + Math.random() * 2; self.update = function () { self.y += self.speed; }; return self; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.fruitCount = 0; self.currentFruitType = null; self.transformed = false; self.moveLeft = function () { if (self.x > 60) { self.x -= self.speed; } }; self.moveRight = function () { if (self.x < 2048 - 60) { self.x += self.speed; } }; self.collectFruit = function (fruitType) { if (self.currentFruitType === null || self.currentFruitType === fruitType) { self.currentFruitType = fruitType; self.fruitCount++; LK.getSound('collect').play(); if (self.fruitCount >= 10) { self.transform(fruitType); } } else { self.resetProgress(); } updateCounterText(); }; self.resetProgress = function () { self.fruitCount = 0; self.currentFruitType = null; self.transformed = false; playerGraphics.tint = 0xffffff; }; self.transform = function (fruitType) { self.transformed = true; LK.getSound('transform').play(); var colors = { 'apple': 0xff4444, 'orange': 0xff8844, 'banana': 0xffff44, 'grape': 0x8844ff }; playerGraphics.tint = colors[fruitType] || 0xffffff; LK.setScore(LK.getScore() + 100); scoreText.setText(LK.getScore()); tween(playerGraphics, { scaleX: 1.3, scaleY: 1.3 }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { tween(playerGraphics, { scaleX: 1, scaleY: 1 }, { duration: 200, easing: tween.easeIn }); } }); self.resetProgress(); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb }); /**** * Game Code ****/ var player; var fruits = []; var bombs = []; var gameRunning = true; var leftPressed = false; var rightPressed = false; var spawnTimer = 0; var scoreText; var counterText; // Initialize player player = game.addChild(new Player()); player.x = 2048 / 2; player.y = 2732 - 200; // Initialize UI scoreText = new Text2('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreText.anchor.set(0, 0); LK.gui.topLeft.addChild(scoreText); scoreText.x = 120; scoreText.y = 20; counterText = new Text2('Collect: 0/10', { size: 50, fill: 0xFFFFFF }); counterText.anchor.set(0.5, 0); LK.gui.top.addChild(counterText); counterText.y = 100; function updateCounterText() { var fruitName = player.currentFruitType || 'fruits'; counterText.setText(fruitName + ': ' + player.fruitCount + '/10'); } // Touch controls var touchStartX = null; var touchCurrentX = null; game.down = function (x, y, obj) { touchStartX = x; touchCurrentX = x; }; game.move = function (x, y, obj) { if (touchStartX !== null) { touchCurrentX = x; } }; game.up = function (x, y, obj) { touchStartX = null; touchCurrentX = null; }; function spawnFruit() { var fruitTypes = ['apple', 'orange', 'banana', 'grape']; var randomType = fruitTypes[Math.floor(Math.random() * fruitTypes.length)]; var fruit = new Fruit(randomType); fruit.x = Math.random() * (2048 - 160) + 80; fruit.y = -80; fruits.push(fruit); game.addChild(fruit); } function spawnBomb() { var bomb = new Bomb(); bomb.x = Math.random() * (2048 - 180) + 90; bomb.y = -90; bombs.push(bomb); game.addChild(bomb); } game.update = function () { if (!gameRunning) return; // Handle touch movement if (touchStartX !== null && touchCurrentX !== null) { var deltaX = touchCurrentX - touchStartX; if (deltaX < -50) { player.moveLeft(); } else if (deltaX > 50) { player.moveRight(); } } // Spawn objects spawnTimer++; if (spawnTimer % 80 === 0) { spawnFruit(); } if (spawnTimer % 150 === 0) { spawnBomb(); } // Update and check fruits for (var i = fruits.length - 1; i >= 0; i--) { var fruit = fruits[i]; if (fruit.lastY === undefined) fruit.lastY = fruit.y; // Remove off-screen fruits if (fruit.lastY <= 2732 && fruit.y > 2732) { fruit.destroy(); fruits.splice(i, 1); continue; } // Check collision with player if (fruit.intersects(player)) { player.collectFruit(fruit.fruitType); LK.setScore(LK.getScore() + 10); scoreText.setText('Score: ' + LK.getScore()); fruit.destroy(); fruits.splice(i, 1); continue; } fruit.lastY = fruit.y; } // Update and check bombs for (var j = bombs.length - 1; j >= 0; j--) { var bomb = bombs[j]; if (bomb.lastY === undefined) bomb.lastY = bomb.y; // Remove off-screen bombs if (bomb.lastY <= 2732 && bomb.y > 2732) { bomb.destroy(); bombs.splice(j, 1); continue; } // Check collision with player if (bomb.intersects(player)) { LK.getSound('explode').play(); LK.stopMusic(); LK.playMusic('sadMusic'); gameRunning = false; LK.effects.flashScreen(0xff0000, 1000); LK.setTimeout(function () { LK.showGameOver(); }, 1500); bomb.destroy(); bombs.splice(j, 1); continue; } bomb.lastY = bomb.y; } }; // Start background music LK.playMusic('bgMusic'); // Initialize counter text updateCounterText();
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,251 @@
-/****
+/****
+* 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.speed = 4 + Math.random() * 3;
+ self.update = function () {
+ self.y += self.speed;
+ };
+ 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.fruitType = fruitType;
+ self.speed = 3 + Math.random() * 2;
+ self.update = function () {
+ self.y += self.speed;
+ };
+ return self;
+});
+var Player = Container.expand(function () {
+ var self = Container.call(this);
+ var playerGraphics = self.attachAsset('player', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 8;
+ self.fruitCount = 0;
+ self.currentFruitType = null;
+ self.transformed = false;
+ self.moveLeft = function () {
+ if (self.x > 60) {
+ self.x -= self.speed;
+ }
+ };
+ self.moveRight = function () {
+ if (self.x < 2048 - 60) {
+ self.x += self.speed;
+ }
+ };
+ self.collectFruit = function (fruitType) {
+ if (self.currentFruitType === null || self.currentFruitType === fruitType) {
+ self.currentFruitType = fruitType;
+ self.fruitCount++;
+ LK.getSound('collect').play();
+ if (self.fruitCount >= 10) {
+ self.transform(fruitType);
+ }
+ } else {
+ self.resetProgress();
+ }
+ updateCounterText();
+ };
+ self.resetProgress = function () {
+ self.fruitCount = 0;
+ self.currentFruitType = null;
+ self.transformed = false;
+ playerGraphics.tint = 0xffffff;
+ };
+ self.transform = function (fruitType) {
+ self.transformed = true;
+ LK.getSound('transform').play();
+ var colors = {
+ 'apple': 0xff4444,
+ 'orange': 0xff8844,
+ 'banana': 0xffff44,
+ 'grape': 0x8844ff
+ };
+ playerGraphics.tint = colors[fruitType] || 0xffffff;
+ LK.setScore(LK.getScore() + 100);
+ scoreText.setText(LK.getScore());
+ tween(playerGraphics, {
+ scaleX: 1.3,
+ scaleY: 1.3
+ }, {
+ duration: 200,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(playerGraphics, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 200,
+ easing: tween.easeIn
+ });
+ }
+ });
+ self.resetProgress();
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87ceeb
+});
+
+/****
+* Game Code
+****/
+var player;
+var fruits = [];
+var bombs = [];
+var gameRunning = true;
+var leftPressed = false;
+var rightPressed = false;
+var spawnTimer = 0;
+var scoreText;
+var counterText;
+// Initialize player
+player = game.addChild(new Player());
+player.x = 2048 / 2;
+player.y = 2732 - 200;
+// Initialize UI
+scoreText = new Text2('Score: 0', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+scoreText.anchor.set(0, 0);
+LK.gui.topLeft.addChild(scoreText);
+scoreText.x = 120;
+scoreText.y = 20;
+counterText = new Text2('Collect: 0/10', {
+ size: 50,
+ fill: 0xFFFFFF
+});
+counterText.anchor.set(0.5, 0);
+LK.gui.top.addChild(counterText);
+counterText.y = 100;
+function updateCounterText() {
+ var fruitName = player.currentFruitType || 'fruits';
+ counterText.setText(fruitName + ': ' + player.fruitCount + '/10');
+}
+// Touch controls
+var touchStartX = null;
+var touchCurrentX = null;
+game.down = function (x, y, obj) {
+ touchStartX = x;
+ touchCurrentX = x;
+};
+game.move = function (x, y, obj) {
+ if (touchStartX !== null) {
+ touchCurrentX = x;
+ }
+};
+game.up = function (x, y, obj) {
+ touchStartX = null;
+ touchCurrentX = null;
+};
+function spawnFruit() {
+ var fruitTypes = ['apple', 'orange', 'banana', 'grape'];
+ var randomType = fruitTypes[Math.floor(Math.random() * fruitTypes.length)];
+ var fruit = new Fruit(randomType);
+ fruit.x = Math.random() * (2048 - 160) + 80;
+ fruit.y = -80;
+ fruits.push(fruit);
+ game.addChild(fruit);
+}
+function spawnBomb() {
+ var bomb = new Bomb();
+ bomb.x = Math.random() * (2048 - 180) + 90;
+ bomb.y = -90;
+ bombs.push(bomb);
+ game.addChild(bomb);
+}
+game.update = function () {
+ if (!gameRunning) return;
+ // Handle touch movement
+ if (touchStartX !== null && touchCurrentX !== null) {
+ var deltaX = touchCurrentX - touchStartX;
+ if (deltaX < -50) {
+ player.moveLeft();
+ } else if (deltaX > 50) {
+ player.moveRight();
+ }
+ }
+ // Spawn objects
+ spawnTimer++;
+ if (spawnTimer % 80 === 0) {
+ spawnFruit();
+ }
+ if (spawnTimer % 150 === 0) {
+ spawnBomb();
+ }
+ // Update and check fruits
+ for (var i = fruits.length - 1; i >= 0; i--) {
+ var fruit = fruits[i];
+ if (fruit.lastY === undefined) fruit.lastY = fruit.y;
+ // Remove off-screen fruits
+ if (fruit.lastY <= 2732 && fruit.y > 2732) {
+ fruit.destroy();
+ fruits.splice(i, 1);
+ continue;
+ }
+ // Check collision with player
+ if (fruit.intersects(player)) {
+ player.collectFruit(fruit.fruitType);
+ LK.setScore(LK.getScore() + 10);
+ scoreText.setText('Score: ' + LK.getScore());
+ fruit.destroy();
+ fruits.splice(i, 1);
+ continue;
+ }
+ fruit.lastY = fruit.y;
+ }
+ // Update and check bombs
+ for (var j = bombs.length - 1; j >= 0; j--) {
+ var bomb = bombs[j];
+ if (bomb.lastY === undefined) bomb.lastY = bomb.y;
+ // Remove off-screen bombs
+ if (bomb.lastY <= 2732 && bomb.y > 2732) {
+ bomb.destroy();
+ bombs.splice(j, 1);
+ continue;
+ }
+ // Check collision with player
+ if (bomb.intersects(player)) {
+ LK.getSound('explode').play();
+ LK.stopMusic();
+ LK.playMusic('sadMusic');
+ gameRunning = false;
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.setTimeout(function () {
+ LK.showGameOver();
+ }, 1500);
+ bomb.destroy();
+ bombs.splice(j, 1);
+ continue;
+ }
+ bomb.lastY = bomb.y;
+ }
+};
+// Start background music
+LK.playMusic('bgMusic');
+// Initialize counter text
+updateCounterText();
\ No newline at end of file
bomba. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Elma. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
muz. In-Game asset. 2d. High contrast. No shadows
portakal. In-Game asset. 2d. High contrast. No shadows
Üzüm. In-Game asset. 2d. High contrast. No shadows
gülen domates. In-Game asset. 2d. High contrast. No shadows
orman büyük olsun. In-Game asset. 2d. High contrast. No shadows
kivi. In-Game asset. 2d. High contrast. No shadows
Ananas. In-Game asset. 2d. High contrast. No shadows
Armut. In-Game asset. 2d. High contrast. No shadows
karpuz. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat