User prompt
Oyunun üstüne coin ele ekrana her tıkladında üsteki coin 0.01 artsın
Code edit (1 edits merged)
Please save this source code
User prompt
Click Speed Test - CPS Challenge
Initial prompt
Cps oyunu yap saniyede kac defa ekrana tıklarsanız üste score Sayaç ona göre saniyede kac defa tıkladını göstersin ve ekrana tıkladında beyazlık dalgası olursun
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var RippleEffect = Container.expand(function () { var self = Container.call(this); var rippleGraphics = self.attachAsset('ripple', { anchorX: 0.5, anchorY: 0.5, alpha: 0.8, scaleX: 0.1, scaleY: 0.1 }); self.animate = function () { // Animate the ripple expanding and fading out tween(rippleGraphics, { scaleX: 2, scaleY: 2, alpha: 0 }, { duration: 800, easing: tween.easeOut, onFinish: function onFinish() { self.destroy(); } }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a1a }); /**** * Game Code ****/ // Game variables var clickCount = 0; var startTime = Date.now(); var currentCPS = 0; var lastSecondClicks = []; var ripples = []; var coins = 0; // Create CPS display text var cpsText = new Text2('CPS: 0.00', { size: 120, fill: 0xFFFFFF }); cpsText.anchor.set(0.5, 0); LK.gui.top.addChild(cpsText); cpsText.y = 150; // Position below the top menu area // Create coin display text var coinText = new Text2('Coins: 0.00', { size: 100, fill: 0xFFD700 }); coinText.anchor.set(0.5, 0); LK.gui.top.addChild(coinText); coinText.y = 50; // Position above CPS text // Create instruction text var instructionText = new Text2('Tap anywhere to test your clicking speed!', { size: 80, fill: 0xCCCCCC }); instructionText.anchor.set(0.5, 0.5); instructionText.x = 2048 / 2; instructionText.y = 2732 / 2; game.addChild(instructionText); // Function to calculate CPS based on clicks in the last second function calculateCPS() { var now = Date.now(); var oneSecondAgo = now - 1000; // Remove clicks older than 1 second lastSecondClicks = lastSecondClicks.filter(function (clickTime) { return clickTime > oneSecondAgo; }); // Return the count of clicks in the last second return lastSecondClicks.length; } // Function to update CPS display function updateCPSDisplay() { currentCPS = calculateCPS(); cpsText.setText('CPS: ' + currentCPS.toFixed(2)); // Update the score to reflect current CPS LK.setScore(Math.floor(currentCPS * 100)); // Multiply by 100 for better scoring } // Function to create ripple effect at tap location function createRipple(x, y) { var ripple = new RippleEffect(); ripple.x = x; ripple.y = y; game.addChild(ripple); ripples.push(ripple); ripple.animate(); } // Handle screen taps game.down = function (x, y, obj) { clickCount++; var now = Date.now(); lastSecondClicks.push(now); // Increment coins by 0.01 for each click coins += 0.01; coinText.setText('Coins: ' + coins.toFixed(2)); // Create ripple effect at tap location createRipple(x, y); // Hide instruction text after first click if (clickCount === 1 && instructionText.parent) { instructionText.parent.removeChild(instructionText); } // Update CPS immediately updateCPSDisplay(); }; // Update game state game.update = function () { // Update CPS display every few frames for smooth updates if (LK.ticks % 10 === 0) { updateCPSDisplay(); } // Clean up destroyed ripples from array for (var i = ripples.length - 1; i >= 0; i--) { if (!ripples[i].parent) { ripples.splice(i, 1); } } };
===================================================================
--- original.js
+++ change.js
@@ -47,16 +47,25 @@
var startTime = Date.now();
var currentCPS = 0;
var lastSecondClicks = [];
var ripples = [];
+var coins = 0;
// Create CPS display text
var cpsText = new Text2('CPS: 0.00', {
size: 120,
fill: 0xFFFFFF
});
cpsText.anchor.set(0.5, 0);
LK.gui.top.addChild(cpsText);
cpsText.y = 150; // Position below the top menu area
+// Create coin display text
+var coinText = new Text2('Coins: 0.00', {
+ size: 100,
+ fill: 0xFFD700
+});
+coinText.anchor.set(0.5, 0);
+LK.gui.top.addChild(coinText);
+coinText.y = 50; // Position above CPS text
// Create instruction text
var instructionText = new Text2('Tap anywhere to test your clicking speed!', {
size: 80,
fill: 0xCCCCCC
@@ -96,8 +105,11 @@
game.down = function (x, y, obj) {
clickCount++;
var now = Date.now();
lastSecondClicks.push(now);
+ // Increment coins by 0.01 for each click
+ coins += 0.01;
+ coinText.setText('Coins: ' + coins.toFixed(2));
// Create ripple effect at tap location
createRipple(x, y);
// Hide instruction text after first click
if (clickCount === 1 && instructionText.parent) {