User prompt
Butonlar altlı üstlü olsun
User prompt
İki butonda aynı büyüklükte olsun
User prompt
Buton boyutları 400 pixel olsun
User prompt
Butonlar sahnenin alt kenarının orta noktasındanın üstünde olsun
User prompt
Butonların boyutu büyüsün
User prompt
Add two buttons in the bottom-left corner of the screen: one for up and one for down. When the player taps the up button, the karate character moves up. When the player taps the down button, the character moves down.
User prompt
Düşman daha az sıklıkla gelsin
User prompt
Düşmanlar sinüs eğrisi şeklinde hareket etsin
User prompt
Add enemies that spawn randomly from the right edge and move to the left edge of the screen. Destroy them when they exit the left side.
User prompt
Spawn enemies at random intervals from the right edge. As they move left, make them follow a wavy path using a sine function for vertical movement
User prompt
Spawn enemies randomly from the right edge. Enemies move left following a sine wave path. Limit the number of enemies on the screen to a maximum of 3 at the same time.
User prompt
Add enemies that spawn randomly from the right edge and move to the left edge of the screen. Destroy them when they exit the left side
User prompt
Engeller sahnenin sol tarfaından rastgele noktalardan gelir
User prompt
Düşmanlar rastglere noktalardan gelirler
User prompt
Y çizgisinde rastgele noktalardan spawn olurlar
User prompt
Düşmanlar y pozisyonunda sinüs eğrileri şeklinde hareket ederek, sağ kenardan sol kenara doğru hareket eder
User prompt
Coinleri oyundan kaldır
User prompt
Please fix the bug: 'storage is not defined' in or related to this line: 'var currentScore = storage.score || 0;' Line Number: 165 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Eklenen her oyuncu görseliyle beraber puan artış hızı artsın
User prompt
5 saniye boyunca hareket etmezse karakter aşağıya doğru 40 birim insin
User prompt
Oyun başladığında otomatik olarak 3 hamle yapılsın
User prompt
Düşmanların algılama alanını azalt
User prompt
Oyun başladığında ilk 3 saniye düşman gelmesin
User prompt
Add and remove 'Bat' image at the bottom-left corner every half second
User prompt
Add and remove 'Bat' image at the bottom-right corner every half second
/**** * Plugins ****/ var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ // Define a class for enemies var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.x -= self.speed; self.y += Math.sin(self.x / 100) * 10; if (self.x < -50) { self.destroy(); } // Check for intersection with Oyuncu and remove it if detected within a reduced range game.children.forEach(function (child) { if (child instanceof Oyuncu && self.intersects(child) && Math.abs(self.x - child.x) < 30 && Math.abs(self.y - child.y) < 30) { child.destroy(); } }); }; }); // Define a class for the Oyuncu character var Oyuncu = Container.expand(function () { var self = Container.call(this); var oyuncuGraphics = self.attachAsset('Oyuncu', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 7; self.jumpHeight = 20; self.isJumping = false; self.velocityY = 0; self.update = function () { if (self.isJumping) { self.y += self.velocityY; self.velocityY += 0.7; if (self.y >= 2732 / 2) { self.y = 2732 / 2; self.isJumping = false; self.velocityY = 0; } } // Maintain a 10-unit distance from the player if (Math.abs(self.x - player.x) > 10) { self.x += (player.x > self.x ? 1 : -1) * self.speed; } else if (Math.abs(self.x - player.x) < 10) { self.x = player.x + (player.x > self.x ? -10 : 10); } if (Math.abs(self.y - player.y) > 10) { self.y += (player.y > self.y ? 1 : -1) * self.speed; } else if (Math.abs(self.y - player.y) < 10) { self.y = player.y + (player.y > self.y ? -10 : 10); } }; self.jump = function () { self.isJumping = true; self.velocityY = -self.jumpHeight; }; }); //<Assets used in the game will automatically appear here> // Define a class for the player character var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.jumpHeight = 20; self.isJumping = false; self.velocityY = 0; self.update = function () { // Move the player 10 units to the left every second if (LK.ticks % 60 === 0) { // 60 ticks per second self.x -= 10; } if (self.isJumping) { self.y += self.velocityY; self.velocityY += 0.7; // Decreased gravity effect by 30% if (self.y >= 2732 / 2) { // Ground level self.y = 2732 / 2; self.isJumping = false; self.velocityY = 0; } } // Move the player diagonally to the middle of the stage in the first move if (self.x < 2048 / 2 && self.y < 2732 / 2) { self.x += self.speed; self.y += self.speed; } else if (!self.isJumping) { if (self.x > 30) { self.x -= 4; } } // End the game if the player touches the edges of the background if (self.x <= 0 || self.x >= 2048 - self.width || self.y <= 0 || self.y >= 2732 - self.height) { LK.effects.flashScreen(0xff0000, 1000); // Flash screen red LK.showGameOver(); // Show game over screen return; // End the game } }; self.jump = function () { self.isJumping = true; self.velocityY = -self.jumpHeight; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Black background }); /**** * Game Code ****/ // Initialize background var background = game.addChild(LK.getAsset('arkplan', { anchorX: 0.0, anchorY: 0.0, scaleX: 2048 / 100, scaleY: 2732 / 100, x: 0, y: 0 })); // Initialize player var player = game.addChild(new Player()); player.x = 200; player.y = 2732 - player.height - 150; // Add a delay of 2 seconds before the game starts LK.setTimeout(function () { // Make the first jump move automatically player.jump(); }, 2000); // Initialize enemies var enemies = []; var enemySpawnInterval = 100; var enemySpawnCounter = 0; // Import storage plugin // Load score from storage or initialize to 0 var currentScore = storage.score || 0; // Create a new Text2 object to display the score var scoreText = new Text2(currentScore.toString(), { size: 100, fill: 0xFFFFFF }); // Add the score text to the game GUI at the top right of the screen LK.gui.topRight.addChild(scoreText); scoreText.x = 2048 - 50; // 50 pixels from the right edge scoreText.y = 0; // Handle game updates game.update = function () { player.update(); // Spawn enemies enemySpawnCounter++; if (enemySpawnCounter >= enemySpawnInterval) { var enemy = new Enemy(); enemy.x = 2048; enemy.y = Math.random() * (2732 / 2); enemies.push(enemy); game.addChild(enemy); // Decrease the spawn interval for the next enemy every 10 seconds if (LK.ticks % 600 == 0 && enemySpawnInterval > 10) { enemySpawnInterval -= 10; } enemySpawnCounter = 0; } // Update enemies for (var j = enemies.length - 1; j >= 0; j--) { enemies[j].update(); if (player.intersects(enemies[j]) && Math.abs(player.x - enemies[j].x) < 50 && Math.abs(player.y - enemies[j].y) < 50) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } else if (player.x > enemies[j].x && !enemies[j].passed) { enemies[j].passed = true; LK.setScore(LK.getScore() + 1); var currentScore = LK.getScore(); storage.score = currentScore; // Save score to storage var scoreAssetId = 'Skor' + currentScore; if (currentScore % 9 === 0) { var cicekAsset = game.addChild(LK.getAsset('cicek', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 })); LK.setTimeout(function () { cicekAsset.destroy(); }, 1000); // Add 'oyuncu' image to the bottom-left corner var oyuncu = game.addChild(new Oyuncu()); oyuncu.x = player.x + 10; oyuncu.y = player.y; } if (currentScore === 9) { LK.setScore(0); currentScore = 0; storage.score = currentScore; // Save reset score to storage } if (currentScore <= 9) { game.children.forEach(function (child) { if (child.assetId && child.assetId.startsWith('Skor')) { child.destroy(); } }); var scoreAsset = game.addChild(LK.getAsset(scoreAssetId, { anchorX: 0.5, anchorY: 1.0, x: 2048 / 2, y: 2732 })); LK.setTimeout(function () { scoreAsset.destroy(); }, 1000); } else { scoreText.setText(currentScore); } } } }; // Handle player jump game.down = function (x, y, obj) { player.jump(); };
===================================================================
--- original.js
+++ change.js
@@ -1,8 +1,12 @@
/****
+* Plugins
+****/
+var storage = LK.import("@upit/storage.v1");
+
+/****
* Classes
****/
-// Initialize storage object
// Define a class for enemies
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy', {
@@ -15,105 +19,28 @@
self.y += Math.sin(self.x / 100) * 10;
if (self.x < -50) {
self.destroy();
}
- // Check for intersection with Oyuncu and remove it if detected
+ // Check for intersection with Oyuncu and remove it if detected within a reduced range
game.children.forEach(function (child) {
if (child instanceof Oyuncu && self.intersects(child) && Math.abs(self.x - child.x) < 30 && Math.abs(self.y - child.y) < 30) {
child.destroy();
}
});
};
});
-var Enemy1 = Container.expand(function () {
- var self = Container.call(this);
- var enemy1Graphics = self.attachAsset('Enemy1', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 5;
- self.update = function () {
- self.x -= self.speed;
- self.y += Math.sin(self.x / 100) * 10;
- if (self.x < -50) {
- self.destroy();
- }
- // Check for intersection with Oyuncu and remove it if detected
- game.children.forEach(function (child) {
- if (child instanceof Oyuncu && self.intersects(child) && Math.abs(self.x - child.x) < 30 && Math.abs(self.y - child.y) < 30) {
- child.destroy();
- }
- });
- };
-});
-var Leaf = Container.expand(function () {
- var self = Container.call(this);
- var leafGraphics = self.attachAsset('yaprak', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 2 + Math.random() * 3; // Random speed between 2 and 5
- self.update = function () {
- self.y += self.speed;
- self.speed = 2 + Math.random() * 3; // Random speed between 2 and 5
- self.x += Math.sin(LK.ticks / 20) * 2; // Add swaying motion
- if (self.y > 2732) {
- self.destroy();
- }
- };
-});
// Define a class for the Oyuncu character
var Oyuncu = Container.expand(function () {
var self = Container.call(this);
var oyuncuGraphics = self.attachAsset('Oyuncu', {
anchorX: 0.5,
anchorY: 0.5
});
- self.speedX = (Math.random() - 0.5) * 10; // Random initial speed between -5 and 5
- self.speedY = (Math.random() - 0.5) * 10; // Random initial speed between -5 and 5
self.speed = 7;
self.jumpHeight = 20;
self.isJumping = false;
self.velocityY = 0;
self.update = function () {
- // Initialize lastX and lastY if not already set
- if (self.lastX === undefined) {
- self.lastX = self.x;
- }
- if (self.lastY === undefined) {
- self.lastY = self.y;
- }
- // Check if the character hasn't moved for 5 seconds (300 ticks)
- if (LK.ticks % 300 === 0) {
- if (self.x === self.lastX && self.y === self.lastY) {
- self.y += 40; // Move down by 40 units
- }
- }
- // Update lastX and lastY
- self.lastX = self.x;
- self.lastY = self.y;
- // Randomly change direction
- if (Math.random() < 0.05) {
- // 5% chance to change direction each frame
- self.speedX = (Math.random() - 0.5) * 10; // Random speed between -5 and 5
- self.speedY = (Math.random() - 0.5) * 10; // Random speed between -5 and 5
- }
- // Update position
- self.x += self.speedX;
- self.y += self.speedY;
- // Keep 'oyuncu' within screen bounds
- if (self.x < 0) {
- self.x = 0;
- }
- if (self.x > 2048) {
- self.x = 2048;
- }
- if (self.y < 0) {
- self.y = 0;
- }
- if (self.y > 2732) {
- self.y = 2732;
- }
if (self.isJumping) {
self.y += self.velocityY;
self.velocityY += 0.7;
if (self.y >= 2732 / 2) {
@@ -151,12 +78,12 @@
self.jumpHeight = 20;
self.isJumping = false;
self.velocityY = 0;
self.update = function () {
- // Move the player down 60 units every second if no action is taken
- if (LK.ticks % 120 === 0) {
- // 60 ticks per second, so 120 ticks is two seconds
- self.y += 60; // Move down 60 units
+ // Move the player 10 units to the left every second
+ if (LK.ticks % 60 === 0) {
+ // 60 ticks per second
+ self.x -= 10;
}
if (self.isJumping) {
self.y += self.velocityY;
self.velocityY += 0.7; // Decreased gravity effect by 30%
@@ -170,59 +97,25 @@
// Move the player diagonally to the middle of the stage in the first move
if (self.x < 2048 / 2 && self.y < 2732 / 2) {
self.x += self.speed;
self.y += self.speed;
- LK.getSound('arkplan').play(); // Play background sound when moving
} else if (!self.isJumping) {
- if (self.x > 30 && self.x <= 2048 - self.width) {
+ if (self.x > 30) {
self.x -= 4;
}
}
// End the game if the player touches the edges of the background
- if (self.x <= 0 || self.x >= 2048 - self.width || self.y <= 0 || self.y >= 2732 - self.height || LK.ticks > 600 && self.x < 100) {
+ if (self.x <= 0 || self.x >= 2048 - self.width || self.y <= 0 || self.y >= 2732 - self.height) {
LK.effects.flashScreen(0xff0000, 1000); // Flash screen red
LK.showGameOver(); // Show game over screen
return; // End the game
}
};
self.jump = function () {
self.isJumping = true;
- LK.playMusic('Skor', {
- loop: true
- });
self.velocityY = -self.jumpHeight;
- LK.getSound('Player').play();
};
});
-var ScrollingBackground = Container.expand(function () {
- var self = Container.call(this);
- var bg1 = self.attachAsset('arkplan', {
- anchorX: 0.0,
- anchorY: 0.0,
- scaleX: 2048 / 100,
- scaleY: 2732 / 100,
- x: 0,
- y: 0
- });
- var bg2 = self.attachAsset('arkplan', {
- anchorX: 0.0,
- anchorY: 0.0,
- scaleX: 2048 / 100,
- scaleY: 2732 / 100,
- x: 2048,
- y: 0
- });
- self.update = function () {
- bg1.x -= 2;
- bg2.x -= 2;
- if (bg1.x <= -2048) {
- bg1.x = bg2.x + 2048;
- }
- if (bg2.x <= -2048) {
- bg2.x = bg1.x + 2048;
- }
- };
-});
/****
* Initialize Game
****/
@@ -232,105 +125,26 @@
/****
* Game Code
****/
-// Add and remove 'Bat' image at the bottom-right corner every half second
-var batImage;
-var batVisible = false;
-LK.setInterval(function () {
- if (batVisible) {
- if (batImage) {
- batImage.destroy();
- batImage = null;
- }
- } else {
- batImage = LK.getAsset('Bat', {
- anchorX: 0.5,
- anchorY: 0.5,
- x: 2048 - 200,
- // Adjusted for half the width of the image
- y: 2732 - 200 // Adjusted for half the height of the image
- });
- game.addChild(batImage);
- }
- batVisible = !batVisible;
-}, 500); // Toggle every half second
-// Add and remove 'Bat' image at the bottom-left corner every half second
-var batImageLeft;
-var batVisibleLeft = false;
-LK.setInterval(function () {
- if (batVisibleLeft) {
- if (batImageLeft) {
- batImageLeft.destroy();
- batImageLeft = null;
- }
- } else {
- batImageLeft = LK.getAsset('Bat', {
- anchorX: 0.5,
- anchorY: 0.5,
- x: 0 + 200,
- // Adjusted for half the width of the image
- y: 2732 - 200 // Adjusted for half the height of the image
- });
- game.addChild(batImageLeft);
- }
- batVisibleLeft = !batVisibleLeft;
-}, 500); // Toggle every half second
-var banImage = LK.getAsset('Ban', {
- anchorX: 0.5,
- anchorY: 0.5,
- x: 2048 / 2,
- y: 2732 / 2
-});
-game.addChild(banImage);
// Initialize background
-var tween = function tween(target, properties, options) {
- // Implement a simple tween function using requestAnimationFrame
- var start = {};
- var change = {};
- var duration = options.duration || 1000;
- var easing = options.easing || function (t) {
- return t;
- };
- var startTime = Date.now();
- for (var prop in properties) {
- start[prop] = target[prop];
- change[prop] = properties[prop] - start[prop];
- }
- function animate(time) {
- var timeElapsed = time - startTime;
- var progress = Math.min(timeElapsed / duration, 1);
- for (var prop in properties) {
- target[prop] = start[prop] + change[prop] * easing(progress);
- }
- if (progress < 1) {
- LK.setTimeout(function () {
- animate(Date.now());
- }, 16); // Approximately 60 FPS
- } else if (options.onFinish) {
- options.onFinish();
- }
- }
- LK.setTimeout(function () {
- animate(Date.now());
- }, 16); // Approximately 60 FPS
-};
-var storage = {};
-var scrollingBackground = game.addChild(new ScrollingBackground());
+var background = game.addChild(LK.getAsset('arkplan', {
+ anchorX: 0.0,
+ anchorY: 0.0,
+ scaleX: 2048 / 100,
+ scaleY: 2732 / 100,
+ x: 0,
+ y: 0
+}));
// Initialize player
var player = game.addChild(new Player());
player.x = 200;
player.y = 2732 - player.height - 150;
-// Automatically make the first three moves within two seconds of game start
+// Add a delay of 2 seconds before the game starts
LK.setTimeout(function () {
- player.jump(); // First move
- LK.setTimeout(function () {
- player.jump(); // Second move
- LK.setTimeout(function () {
- player.jump(); // Third move
- }, 500); // Third move after 0.5 seconds
- }, 500); // Second move after 0.5 seconds
-}, 500); // First move after 0.5 seconds
+ // Make the first jump move automatically
+ player.jump();
+}, 2000);
// Initialize enemies
var enemies = [];
var enemySpawnInterval = 100;
var enemySpawnCounter = 0;
@@ -338,185 +152,83 @@
// Load score from storage or initialize to 0
var currentScore = storage.score || 0;
// Create a new Text2 object to display the score
var scoreText = new Text2(currentScore.toString(), {
- size: 250,
- fill: 0xFFFFFF,
- font: "bold"
+ size: 100,
+ fill: 0xFFFFFF
});
-// Add the score text to the game GUI at the top-right corner of the screen
+// Add the score text to the game GUI at the top right of the screen
LK.gui.topRight.addChild(scoreText);
-scoreText.anchor.set(1, 0); // Anchor to the top-right corner
-scoreText.x = 0; // Positioned at the right edge
-scoreText.y = 0; // Positioned at the top edge
+scoreText.x = 2048 - 50; // 50 pixels from the right edge
+scoreText.y = 0;
// Handle game updates
game.update = function () {
- scrollingBackground.update();
player.update();
- // Increase the number of enemies every minute
- if (LK.ticks % 3600 === 0) {
- // 60 ticks per second * 60 seconds = 3600 ticks per minute
- var additionalEnemy = new Enemy();
- additionalEnemy.x = 2048;
- additionalEnemy.y = Math.random() * (2732 / 2);
- enemies.push(additionalEnemy);
- game.addChild(additionalEnemy);
- }
- // Spawn leaves
- if (LK.ticks % 120 === 0) {
- // Every second
- var leaf = new Leaf();
- leaf.x = Math.random() * 2048; // Random x position across the screen
- leaf.y = -50; // Start above the screen
- game.addChild(leaf);
- }
// Spawn enemies
enemySpawnCounter++;
- if (enemySpawnCounter >= enemySpawnInterval && LK.ticks > 180) {
- // Delay enemy spawning for the first 3 seconds (180 ticks)
- if (LK.getScore() < 80 || LK.getScore() >= 160) {
- var enemy = new Enemy();
- enemy.x = 2048;
- enemy.y = Math.random() * (2732 / 2);
- enemies.push(enemy);
- game.addChild(enemy);
- } else if (LK.getScore() >= 80 && LK.getScore() < 160) {
- var enemy1 = new Enemy1();
- enemy1.x = 2048 / 2 + (Math.random() * 200 - 100); // Random x around center
- enemy1.y = 2732 / 2 + (Math.random() * 200 - 100); // Random y around center
- game.addChild(enemy1);
- enemies.push(enemy1);
- LK.setTimeout(function () {
- enemy1.destroy();
- enemies.splice(enemies.indexOf(enemy1), 1);
- }, 1000); // Remove after 1 second
- }
+ if (enemySpawnCounter >= enemySpawnInterval) {
+ var enemy = new Enemy();
+ enemy.x = 2048;
+ enemy.y = Math.random() * (2732 / 2);
+ enemies.push(enemy);
+ game.addChild(enemy);
// Decrease the spawn interval for the next enemy every 10 seconds
if (LK.ticks % 600 == 0 && enemySpawnInterval > 10) {
enemySpawnInterval -= 10;
}
enemySpawnCounter = 0;
}
// Update enemies
for (var j = enemies.length - 1; j >= 0; j--) {
- if (typeof enemies[j].update === 'function') {
- enemies[j].update();
- }
- if (player.intersects(enemies[j])) {
+ enemies[j].update();
+ if (player.intersects(enemies[j]) && Math.abs(player.x - enemies[j].x) < 50 && Math.abs(player.y - enemies[j].y) < 50) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
} else if (player.x > enemies[j].x && !enemies[j].passed) {
enemies[j].passed = true;
- // Calculate score increment based on the number of 'Oyuncu' images
- var oyuncuCount = game.children.filter(function (child) {
- return child instanceof Oyuncu;
- }).length;
- LK.setScore(LK.getScore() + 1 + oyuncuCount);
+ LK.setScore(LK.getScore() + 1);
var currentScore = LK.getScore();
storage.score = currentScore; // Save score to storage
- scoreText.setText(currentScore.toString()); // Update the score text display
- if (currentScore === 1) {
- var banBottomLeft = LK.getAsset('Ban', {
+ var scoreAssetId = 'Skor' + currentScore;
+ if (currentScore % 9 === 0) {
+ var cicekAsset = game.addChild(LK.getAsset('cicek', {
anchorX: 0.5,
anchorY: 0.5,
- x: 0 + 200,
- // Adjusted for half the width of the image
- y: 2732 - 200 // Adjusted for half the height of the image
- });
- game.addChild(banBottomLeft);
- var banBottomRight = LK.getAsset('Ban', {
- anchorX: 0.5,
- anchorY: 0.5,
- x: 2048 - 200,
- // Adjusted for half the width of the image
- y: 2732 - 200 // Adjusted for half the height of the image
- });
- game.addChild(banBottomRight);
- } else if (currentScore === 80) {
- // Add 'akra' as an enemy
- var akra = LK.getAsset('akra', {
- anchorX: 0.5,
- anchorY: 0.5,
- x: 2048 / 2 + (Math.random() * 200 - 100),
- // Random x around center
- y: 2732 / 2 + (Math.random() * 200 - 100) // Random y around center
- });
- game.addChild(akra);
- tween(akra, {
- x: 0,
- y: 2732
- }, {
- duration: 5000,
- easing: function easing(t) {
- return Math.sin(t * Math.PI * 2) * 0.5 + 0.5;
- },
- onFinish: function onFinish() {
- akra.destroy();
- }
- });
- // Rotate 'akra' around its center
- akra.update = function () {
- akra.rotation += 0.1; // Adjust rotation speed as needed
- };
- var level2Text = new Text2('Level 2', {
- size: 500,
- fill: 0xFFFFFF,
- font: "bold"
- });
- level2Text.anchor.set(0.5, 0.5);
- level2Text.x = 2048 / 2;
- level2Text.y = 2732 / 2;
- game.addChild(level2Text);
+ x: 2048 / 2,
+ y: 2732 / 2
+ }));
LK.setTimeout(function () {
- level2Text.destroy();
- }, 2000); // Display for 2 seconds
- // Change enemy graphics to 'enemy1'
- enemies.forEach(function (enemy) {
- enemy.children[0].setAsset('Enemy1');
- });
- // Animate 'Enemy1' from top-right to bottom-left in a sine wave
- var enemy1 = LK.getAsset('Enemy1', {
- anchorX: 0.5,
- anchorY: 0.5,
- x: 2048,
- y: 0
- });
- game.addChild(enemy1);
- tween(enemy1, {
- x: 0,
- y: 2732
- }, {
- duration: 5000,
- easing: function easing(t) {
- return Math.sin(t * Math.PI * 2) * 0.5 + 0.5;
- },
- onFinish: function onFinish() {
- enemy1.destroy();
+ cicekAsset.destroy();
+ }, 1000);
+ // Add 'oyuncu' image to the bottom-left corner
+ var oyuncu = game.addChild(new Oyuncu());
+ oyuncu.x = player.x + 10;
+ oyuncu.y = player.y;
+ }
+ if (currentScore === 9) {
+ LK.setScore(0);
+ currentScore = 0;
+ storage.score = currentScore; // Save reset score to storage
+ }
+ if (currentScore <= 9) {
+ game.children.forEach(function (child) {
+ if (child.assetId && child.assetId.startsWith('Skor')) {
+ child.destroy();
}
});
- } else if (currentScore % 9 === 0) {
- var cicekAsset = game.addChild(LK.getAsset('cicek', {
+ var scoreAsset = game.addChild(LK.getAsset(scoreAssetId, {
anchorX: 0.5,
- anchorY: 0.5,
+ anchorY: 1.0,
x: 2048 / 2,
- y: 2732 / 2
+ y: 2732
}));
- LK.setScore(LK.getScore() + 5); // Add 5 points to the score
- scoreText.setText(LK.getScore().toString()); // Update the score text display
LK.setTimeout(function () {
- cicekAsset.destroy();
+ scoreAsset.destroy();
}, 1000);
- // Add 'oyuncu' image to the bottom-left corner if less than 4 exist
- if (game.children.filter(function (child) {
- return child instanceof Oyuncu;
- }).length < 4) {
- var oyuncu = game.addChild(new Oyuncu());
- oyuncu.x = player.x + 10;
- oyuncu.y = player.y;
- }
+ } else {
+ scoreText.setText(currentScore);
}
- scoreText.setText(currentScore);
}
}
};
// Handle player jump