User prompt
tek tek çıksınlar
User prompt
1 saniye deyil 1.5 saniye sonra kay bolsun ve yok olunca hemen başka yerde çıksın best yazısını sağ üste al
User prompt
1 saniye sonra kaybolsunlarve skor taplosunu ekle en yüksek yaptı sayıyı görsün arkayıya asset ekle ↪💡 Consider importing and using the following plugins: @upit/storage.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Circle Chase - Random Pop Target Game
Initial prompt
ekranda raskele yerlere dayre çıkar 2 saniye sonra kaybaolsun kısaca eimlab
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Target = Container.expand(function () { var self = Container.call(this); var targetGraphics = self.attachAsset('target', { anchorX: 0.5, anchorY: 0.5 }); // Target lifespan is 2 seconds self.lifespan = 2000; self.spawnTime = Date.now(); self.isActive = true; // Visual feedback on spawn targetGraphics.alpha = 0; tween(targetGraphics, { alpha: 1 }, { duration: 200 }); // Auto-destroy after 2 seconds self.destroyTimer = LK.setTimeout(function () { if (self.isActive) { self.fadeOut(); } }, self.lifespan); self.fadeOut = function () { if (!self.isActive) return; self.isActive = false; tween(targetGraphics, { alpha: 0 }, { duration: 300, onFinish: function onFinish() { self.destroy(); // Remove from targets array for (var i = targets.length - 1; i >= 0; i--) { if (targets[i] === self) { targets.splice(i, 1); break; } } } }); }; // Handle tap self.down = function (x, y, obj) { if (!self.isActive) return; // Score point LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); // Play sound LK.getSound('pop').play(); // Visual feedback tween(targetGraphics, { scaleX: 1.3, scaleY: 1.3 }, { duration: 100, easing: tween.easeOut }); // Remove target self.isActive = false; LK.clearTimeout(self.destroyTimer); tween(targetGraphics, { alpha: 0, scaleX: 0.8, scaleY: 0.8 }, { duration: 200, onFinish: function onFinish() { self.destroy(); // Remove from targets array for (var i = targets.length - 1; i >= 0; i--) { if (targets[i] === self) { targets.splice(i, 1); break; } } } }); }; self.update = function () { if (!self.isActive) return; // Fade out effect as time runs out var timeLeft = self.lifespan - (Date.now() - self.spawnTime); if (timeLeft < 500) { var fadeRatio = timeLeft / 500; targetGraphics.alpha = Math.max(0.3, fadeRatio); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2E3440 }); /**** * Game Code ****/ // Game variables var targets = []; var spawnTimer = 0; var baseSpawnRate = 120; // Spawn every 2 seconds at 60fps var minSpawnRate = 30; // Minimum spawn interval (0.5 seconds) var spawnRateDecrease = 2; // How much to decrease spawn rate over time // Score display var scoreTxt = new Text2('0', { size: 120, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Position score text slightly down from top scoreTxt.y = 50; // Instructions text var instructionTxt = new Text2('Tap the circles before they disappear!', { size: 60, fill: 0xFFFFFF }); instructionTxt.anchor.set(0.5, 0.5); instructionTxt.x = 2048 / 2; instructionTxt.y = 2732 - 200; game.addChild(instructionTxt); // Fade out instructions after a few seconds LK.setTimeout(function () { tween(instructionTxt, { alpha: 0 }, { duration: 1000 }); }, 3000); function spawnTarget() { var target = new Target(); // Random position within safe bounds var margin = 100; target.x = margin + Math.random() * (2048 - 2 * margin); target.y = margin + Math.random() * (2732 - 2 * margin); // Make sure target doesn't spawn too close to existing targets var tooClose = false; for (var i = 0; i < targets.length; i++) { var distance = Math.sqrt(Math.pow(target.x - targets[i].x, 2) + Math.pow(target.y - targets[i].y, 2)); if (distance < 200) { tooClose = true; break; } } // If too close, try a different position if (tooClose && targets.length < 8) { target.x = margin + Math.random() * (2048 - 2 * margin); target.y = margin + Math.random() * (2732 - 2 * margin); } targets.push(target); game.addChild(target); } game.update = function () { spawnTimer++; // Calculate current spawn rate based on score (gets faster over time) var currentSpawnRate = Math.max(minSpawnRate, baseSpawnRate - Math.floor(LK.getScore() / 5) * spawnRateDecrease); // Spawn new targets if (spawnTimer >= currentSpawnRate) { spawnTimer = 0; // Chance to spawn multiple targets for increased difficulty var spawnCount = 1; if (LK.getScore() > 10 && Math.random() < 0.3) { spawnCount = 2; } if (LK.getScore() > 20 && Math.random() < 0.2) { spawnCount = 3; } for (var i = 0; i < spawnCount; i++) { if (targets.length < 10) { // Maximum targets on screen spawnTarget(); } } } // Update score display scoreTxt.setText(LK.getScore()); };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,189 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Target = Container.expand(function () {
+ var self = Container.call(this);
+ var targetGraphics = self.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Target lifespan is 2 seconds
+ self.lifespan = 2000;
+ self.spawnTime = Date.now();
+ self.isActive = true;
+ // Visual feedback on spawn
+ targetGraphics.alpha = 0;
+ tween(targetGraphics, {
+ alpha: 1
+ }, {
+ duration: 200
+ });
+ // Auto-destroy after 2 seconds
+ self.destroyTimer = LK.setTimeout(function () {
+ if (self.isActive) {
+ self.fadeOut();
+ }
+ }, self.lifespan);
+ self.fadeOut = function () {
+ if (!self.isActive) return;
+ self.isActive = false;
+ tween(targetGraphics, {
+ alpha: 0
+ }, {
+ duration: 300,
+ onFinish: function onFinish() {
+ self.destroy();
+ // Remove from targets array
+ for (var i = targets.length - 1; i >= 0; i--) {
+ if (targets[i] === self) {
+ targets.splice(i, 1);
+ break;
+ }
+ }
+ }
+ });
+ };
+ // Handle tap
+ self.down = function (x, y, obj) {
+ if (!self.isActive) return;
+ // Score point
+ LK.setScore(LK.getScore() + 1);
+ scoreTxt.setText(LK.getScore());
+ // Play sound
+ LK.getSound('pop').play();
+ // Visual feedback
+ tween(targetGraphics, {
+ scaleX: 1.3,
+ scaleY: 1.3
+ }, {
+ duration: 100,
+ easing: tween.easeOut
+ });
+ // Remove target
+ self.isActive = false;
+ LK.clearTimeout(self.destroyTimer);
+ tween(targetGraphics, {
+ alpha: 0,
+ scaleX: 0.8,
+ scaleY: 0.8
+ }, {
+ duration: 200,
+ onFinish: function onFinish() {
+ self.destroy();
+ // Remove from targets array
+ for (var i = targets.length - 1; i >= 0; i--) {
+ if (targets[i] === self) {
+ targets.splice(i, 1);
+ break;
+ }
+ }
+ }
+ });
+ };
+ self.update = function () {
+ if (!self.isActive) return;
+ // Fade out effect as time runs out
+ var timeLeft = self.lifespan - (Date.now() - self.spawnTime);
+ if (timeLeft < 500) {
+ var fadeRatio = timeLeft / 500;
+ targetGraphics.alpha = Math.max(0.3, fadeRatio);
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x2E3440
+});
+
+/****
+* Game Code
+****/
+// Game variables
+var targets = [];
+var spawnTimer = 0;
+var baseSpawnRate = 120; // Spawn every 2 seconds at 60fps
+var minSpawnRate = 30; // Minimum spawn interval (0.5 seconds)
+var spawnRateDecrease = 2; // How much to decrease spawn rate over time
+// Score display
+var scoreTxt = new Text2('0', {
+ size: 120,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+// Position score text slightly down from top
+scoreTxt.y = 50;
+// Instructions text
+var instructionTxt = new Text2('Tap the circles before they disappear!', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+instructionTxt.anchor.set(0.5, 0.5);
+instructionTxt.x = 2048 / 2;
+instructionTxt.y = 2732 - 200;
+game.addChild(instructionTxt);
+// Fade out instructions after a few seconds
+LK.setTimeout(function () {
+ tween(instructionTxt, {
+ alpha: 0
+ }, {
+ duration: 1000
+ });
+}, 3000);
+function spawnTarget() {
+ var target = new Target();
+ // Random position within safe bounds
+ var margin = 100;
+ target.x = margin + Math.random() * (2048 - 2 * margin);
+ target.y = margin + Math.random() * (2732 - 2 * margin);
+ // Make sure target doesn't spawn too close to existing targets
+ var tooClose = false;
+ for (var i = 0; i < targets.length; i++) {
+ var distance = Math.sqrt(Math.pow(target.x - targets[i].x, 2) + Math.pow(target.y - targets[i].y, 2));
+ if (distance < 200) {
+ tooClose = true;
+ break;
+ }
+ }
+ // If too close, try a different position
+ if (tooClose && targets.length < 8) {
+ target.x = margin + Math.random() * (2048 - 2 * margin);
+ target.y = margin + Math.random() * (2732 - 2 * margin);
+ }
+ targets.push(target);
+ game.addChild(target);
+}
+game.update = function () {
+ spawnTimer++;
+ // Calculate current spawn rate based on score (gets faster over time)
+ var currentSpawnRate = Math.max(minSpawnRate, baseSpawnRate - Math.floor(LK.getScore() / 5) * spawnRateDecrease);
+ // Spawn new targets
+ if (spawnTimer >= currentSpawnRate) {
+ spawnTimer = 0;
+ // Chance to spawn multiple targets for increased difficulty
+ var spawnCount = 1;
+ if (LK.getScore() > 10 && Math.random() < 0.3) {
+ spawnCount = 2;
+ }
+ if (LK.getScore() > 20 && Math.random() < 0.2) {
+ spawnCount = 3;
+ }
+ for (var i = 0; i < spawnCount; i++) {
+ if (targets.length < 10) {
+ // Maximum targets on screen
+ spawnTarget();
+ }
+ }
+ }
+ // Update score display
+ scoreTxt.setText(LK.getScore());
+};
\ No newline at end of file