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 = []; // 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 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); // 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
@@ -1,6 +1,121 @@
-/****
+/****
+* 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: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x1a1a1a
+});
+
+/****
+* Game Code
+****/
+// Game variables
+var clickCount = 0;
+var startTime = Date.now();
+var currentCPS = 0;
+var lastSecondClicks = [];
+var ripples = [];
+// 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 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);
+ // 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);
+ }
+ }
+};
\ No newline at end of file