User prompt
Particles of word shoild have random colors but allt he particles of a word the same color amonst them
User prompt
Particles in word shoild have rabdom colors
User prompt
The color of the particles of the words should be random but all have tge same color
User prompt
But the prticles of the word should have the same cllor
User prompt
The particles in the word should also have random colors every time they are formed
User prompt
Words letters should also be random
User prompt
Each particle shoild have a different random bright fluor color, even the unused ones
User prompt
Down word is still not centered. Fix it please
User prompt
Center Down word too
User prompt
Center the word Left
User prompt
Center the unused particles
User prompt
Up left and down are not centered. Plase center them.
User prompt
Right does not fit in the screen adjust it please
User prompt
Direction words are not very clear can you make them more reqdable. Also add a lot of colour
User prompt
Remove the text that says wipe the direction and also cneter the text that tells qhich direction
User prompt
Use the paricle and the movement but end up forming the word up down left or rigth and player has to swipe that way to add a pount ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
I just want a simple tap game, using all this tween effects. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Remix started
Copy Tween toy
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Particle = Container.expand(function () { var self = Container.call(this); var particleGraphics = self.attachAsset('particle', { anchorX: 0.5, anchorY: 0.5 }); self.tint = 0xffffff * Math.random(); self.rotation = Math.PI * 2 * Math.random(); particleGraphics.blendMode = 1; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ var scoreDisplay; var currentDirection = null; var swipeStartX = null; var swipeStartY = null; var isCorrectSwipe = false; var canSwipe = true; for (var i = 0; i < 500; i++) { var particle = game.addChild(new Particle()); var angle = Math.random() * Math.PI * 2; var radius = Math.random() * 200; particle.x = 1024 + Math.cos(angle) * radius; particle.y = 1366 + Math.sin(angle) * radius; particle.scale.set(4, 4); } var instructionText = new Text2('Swipe the direction!', { size: 120, fill: 0xFFFFFF, weight: 800 }); instructionText.anchor.set(0.5, 0.5); instructionText.x = 2048 / 2; instructionText.y = 800; game.addChild(instructionText); // Create letter positions for directional words var letterPositions = { UP: [ // U { x: 700, y: 1200 }, { x: 700, y: 1300 }, { x: 700, y: 1400 }, { x: 700, y: 1500 }, { x: 800, y: 1500 }, { x: 900, y: 1500 }, { x: 1000, y: 1200 }, { x: 1000, y: 1300 }, { x: 1000, y: 1400 }, { x: 1000, y: 1500 }, // P { x: 1200, y: 1200 }, { x: 1200, y: 1300 }, { x: 1200, y: 1400 }, { x: 1200, y: 1500 }, { x: 1300, y: 1200 }, { x: 1400, y: 1200 }, { x: 1400, y: 1300 }, { x: 1300, y: 1350 }, { x: 1400, y: 1350 }], DOWN: [ // D { x: 500, y: 1200 }, { x: 500, y: 1300 }, { x: 500, y: 1400 }, { x: 500, y: 1500 }, { x: 600, y: 1200 }, { x: 700, y: 1250 }, { x: 700, y: 1450 }, { x: 600, y: 1500 }, // O { x: 900, y: 1250 }, { x: 900, y: 1450 }, { x: 950, y: 1200 }, { x: 1050, y: 1200 }, { x: 1100, y: 1250 }, { x: 1100, y: 1450 }, { x: 950, y: 1500 }, { x: 1050, y: 1500 }, // W { x: 1300, y: 1200 }, { x: 1320, y: 1300 }, { x: 1340, y: 1400 }, { x: 1360, y: 1500 }, { x: 1450, y: 1400 }, { x: 1540, y: 1400 }, { x: 1560, y: 1500 }, { x: 1580, y: 1400 }, { x: 1600, y: 1300 }, { x: 1620, y: 1200 }, // N { x: 1750, y: 1200 }, { x: 1750, y: 1300 }, { x: 1750, y: 1400 }, { x: 1750, y: 1500 }, { x: 1820, y: 1280 }, { x: 1890, y: 1360 }, { x: 1960, y: 1440 }, { x: 2030, y: 1200 }, { x: 2030, y: 1300 }, { x: 2030, y: 1400 }, { x: 2030, y: 1500 }], LEFT: [ // L { x: 600, y: 1200 }, { x: 600, y: 1300 }, { x: 600, y: 1400 }, { x: 600, y: 1500 }, { x: 700, y: 1500 }, { x: 800, y: 1500 }, // E { x: 1000, y: 1200 }, { x: 1000, y: 1300 }, { x: 1000, y: 1400 }, { x: 1000, y: 1500 }, { x: 1100, y: 1200 }, { x: 1200, y: 1200 }, { x: 1100, y: 1350 }, { x: 1100, y: 1500 }, { x: 1200, y: 1500 }, // F { x: 1400, y: 1200 }, { x: 1400, y: 1300 }, { x: 1400, y: 1400 }, { x: 1400, y: 1500 }, { x: 1500, y: 1200 }, { x: 1600, y: 1200 }, { x: 1500, y: 1350 }, // T { x: 1800, y: 1200 }, { x: 1900, y: 1200 }, { x: 2000, y: 1200 }, { x: 1900, y: 1300 }, { x: 1900, y: 1400 }, { x: 1900, y: 1500 }], RIGHT: [ // R { x: 400, y: 1200 }, { x: 400, y: 1300 }, { x: 400, y: 1400 }, { x: 400, y: 1500 }, { x: 500, y: 1200 }, { x: 600, y: 1200 }, { x: 600, y: 1300 }, { x: 500, y: 1350 }, { x: 600, y: 1400 }, { x: 700, y: 1500 }, // I { x: 900, y: 1200 }, { x: 1000, y: 1200 }, { x: 1100, y: 1200 }, { x: 1000, y: 1300 }, { x: 1000, y: 1400 }, { x: 900, y: 1500 }, { x: 1000, y: 1500 }, { x: 1100, y: 1500 }, // G { x: 1300, y: 1250 }, { x: 1350, y: 1200 }, { x: 1450, y: 1200 }, { x: 1500, y: 1200 }, { x: 1300, y: 1350 }, { x: 1300, y: 1450 }, { x: 1350, y: 1500 }, { x: 1450, y: 1500 }, { x: 1500, y: 1450 }, { x: 1500, y: 1400 }, { x: 1450, y: 1400 }, // H { x: 1700, y: 1200 }, { x: 1700, y: 1300 }, { x: 1700, y: 1400 }, { x: 1700, y: 1500 }, { x: 1800, y: 1350 }, { x: 1900, y: 1350 }, { x: 2000, y: 1200 }, { x: 2000, y: 1300 }, { x: 2000, y: 1400 }, { x: 2000, y: 1500 }, // T { x: 2150, y: 1200 }, { x: 2250, y: 1200 }, { x: 2350, y: 1200 }, { x: 2250, y: 1300 }, { x: 2250, y: 1400 }, { x: 2250, y: 1500 }] }; // Initialize score display scoreDisplay = new Text2(LK.getScore().toString(), { size: 100, // Set a nice size for the score fill: 0xFFFFFF // White color for visibility }); scoreDisplay.anchor.set(0.5, 0); // Anchor to its top-center point LK.gui.top.addChild(scoreDisplay); // Add to the GUI at the top-center of the screen game.move = function (x, y) { // Not used for swipe detection, but required by engine }; game.up = function (x, y) { if (!canSwipe || swipeStartX === null || swipeStartY === null) return; var swipeDeltaX = x - swipeStartX; var swipeDeltaY = y - swipeStartY; var swipeThreshold = 100; var detectedDirection = null; if (Math.abs(swipeDeltaX) > Math.abs(swipeDeltaY)) { if (swipeDeltaX > swipeThreshold) { detectedDirection = 'RIGHT'; } else if (swipeDeltaX < -swipeThreshold) { detectedDirection = 'LEFT'; } } else { if (swipeDeltaY > swipeThreshold) { detectedDirection = 'DOWN'; } else if (swipeDeltaY < -swipeThreshold) { detectedDirection = 'UP'; } } if (detectedDirection === currentDirection) { // Correct swipe! isCorrectSwipe = true; LK.setScore(LK.getScore() + 1); scoreDisplay.setText(LK.getScore().toString()); // Flash green for correct LK.effects.flashScreen(0x00FF00, 300); // Check win condition if (LK.getScore() >= 20) { LK.showYouWin(); return; } // Start next round canSwipe = false; showNextDirection(); } else if (detectedDirection !== null) { // Wrong swipe LK.effects.flashScreen(0xFF0000, 300); } swipeStartX = null; swipeStartY = null; }; function showNextDirection() { // Choose random direction var directions = ['UP', 'DOWN', 'LEFT', 'RIGHT']; currentDirection = directions[Math.floor(Math.random() * directions.length)]; // Get particles var particles = []; for (var i = 0; i < game.children.length; i++) { if (game.children[i] instanceof Particle) { particles.push(game.children[i]); } } // Animate particles to scatter first var scatterDuration = 500; particles.forEach(function (particle, index) { var angle = Math.random() * Math.PI * 2; var radius = 300 + Math.random() * 700; tween(particle, { x: 1024 + Math.cos(angle) * radius, y: 1366 + Math.sin(angle) * radius, scaleX: 0.5, scaleY: 0.5, rotation: Math.random() * Math.PI * 2, tint: 0x666666 }, { duration: scatterDuration, easing: tween.easeOut }); }); // After scatter, form the word LK.setTimeout(function () { var positions = letterPositions[currentDirection]; var tweenFunctions = [tween.easeIn, tween.easeOut, tween.elasticOut, tween.bounceOut, tween.easeInOut]; var randomTweenFunction = tweenFunctions[Math.floor(Math.random() * tweenFunctions.length)]; particles.forEach(function (particle, index) { if (index < positions.length) { // Form letter tween(particle, { x: positions[index].x, y: positions[index].y, scaleX: 0.8, scaleY: 0.8, rotation: 0, tint: 0xFFFFFF }, { duration: 800, easing: randomTweenFunction, delay: index * 10 }); } else { // Extra particles float around var angle = Math.random() * Math.PI * 2; var radius = 200 + Math.random() * 300; tween(particle, { x: 1024 + Math.cos(angle) * radius, y: 600 + Math.sin(angle) * radius, scaleX: 0.2, scaleY: 0.2, rotation: Math.random() * Math.PI * 2, tint: 0x444444 }, { duration: 1000, easing: tween.linear }); } }); // Enable swiping after animation LK.setTimeout(function () { canSwipe = true; }, 900); }, scatterDuration + 100); } // Start the first round showNextDirection(); game.down = function (x, y) { if (!canSwipe) return; swipeStartX = x; swipeStartY = y; isCorrectSwipe = false; };
===================================================================
--- original.js
+++ change.js
@@ -27,125 +27,581 @@
/****
* Game Code
****/
var scoreDisplay;
+var currentDirection = null;
+var swipeStartX = null;
+var swipeStartY = null;
+var isCorrectSwipe = false;
+var canSwipe = true;
for (var i = 0; i < 500; i++) {
var particle = game.addChild(new Particle());
var angle = Math.random() * Math.PI * 2;
var radius = Math.random() * 200;
particle.x = 1024 + Math.cos(angle) * radius;
particle.y = 1366 + Math.sin(angle) * radius;
particle.scale.set(4, 4);
}
-var clickMeText = new Text2('Click Me', {
- size: 150,
- fill: 0x000000,
+var instructionText = new Text2('Swipe the direction!', {
+ size: 120,
+ fill: 0xFFFFFF,
weight: 800
});
-clickMeText.anchor.set(0.5, 0.5);
-clickMeText.x = 2048 / 2;
-clickMeText.y = 2732 / 2;
-game.addChild(clickMeText);
-// Create a grid of positions for the particles
-var gridPositions = [];
-var gridSize = 13;
-var elementWidth = 150; // width of the particle element
-for (var i = 0; i < gridSize; i++) {
- for (var j = 0; j < gridSize + 4; j++) {
- gridPositions.push({
- x: i * elementWidth + elementWidth / 2 + (2048 - elementWidth * gridSize) / 2,
- y: j * elementWidth + elementWidth / 2 + (2732 - elementWidth * (gridSize + 4)) / 2
- });
- }
-}
+instructionText.anchor.set(0.5, 0.5);
+instructionText.x = 2048 / 2;
+instructionText.y = 800;
+game.addChild(instructionText);
+// Create letter positions for directional words
+var letterPositions = {
+ UP: [
+ // U
+ {
+ x: 700,
+ y: 1200
+ }, {
+ x: 700,
+ y: 1300
+ }, {
+ x: 700,
+ y: 1400
+ }, {
+ x: 700,
+ y: 1500
+ }, {
+ x: 800,
+ y: 1500
+ }, {
+ x: 900,
+ y: 1500
+ }, {
+ x: 1000,
+ y: 1200
+ }, {
+ x: 1000,
+ y: 1300
+ }, {
+ x: 1000,
+ y: 1400
+ }, {
+ x: 1000,
+ y: 1500
+ },
+ // P
+ {
+ x: 1200,
+ y: 1200
+ }, {
+ x: 1200,
+ y: 1300
+ }, {
+ x: 1200,
+ y: 1400
+ }, {
+ x: 1200,
+ y: 1500
+ }, {
+ x: 1300,
+ y: 1200
+ }, {
+ x: 1400,
+ y: 1200
+ }, {
+ x: 1400,
+ y: 1300
+ }, {
+ x: 1300,
+ y: 1350
+ }, {
+ x: 1400,
+ y: 1350
+ }],
+ DOWN: [
+ // D
+ {
+ x: 500,
+ y: 1200
+ }, {
+ x: 500,
+ y: 1300
+ }, {
+ x: 500,
+ y: 1400
+ }, {
+ x: 500,
+ y: 1500
+ }, {
+ x: 600,
+ y: 1200
+ }, {
+ x: 700,
+ y: 1250
+ }, {
+ x: 700,
+ y: 1450
+ }, {
+ x: 600,
+ y: 1500
+ },
+ // O
+ {
+ x: 900,
+ y: 1250
+ }, {
+ x: 900,
+ y: 1450
+ }, {
+ x: 950,
+ y: 1200
+ }, {
+ x: 1050,
+ y: 1200
+ }, {
+ x: 1100,
+ y: 1250
+ }, {
+ x: 1100,
+ y: 1450
+ }, {
+ x: 950,
+ y: 1500
+ }, {
+ x: 1050,
+ y: 1500
+ },
+ // W
+ {
+ x: 1300,
+ y: 1200
+ }, {
+ x: 1320,
+ y: 1300
+ }, {
+ x: 1340,
+ y: 1400
+ }, {
+ x: 1360,
+ y: 1500
+ }, {
+ x: 1450,
+ y: 1400
+ }, {
+ x: 1540,
+ y: 1400
+ }, {
+ x: 1560,
+ y: 1500
+ }, {
+ x: 1580,
+ y: 1400
+ }, {
+ x: 1600,
+ y: 1300
+ }, {
+ x: 1620,
+ y: 1200
+ },
+ // N
+ {
+ x: 1750,
+ y: 1200
+ }, {
+ x: 1750,
+ y: 1300
+ }, {
+ x: 1750,
+ y: 1400
+ }, {
+ x: 1750,
+ y: 1500
+ }, {
+ x: 1820,
+ y: 1280
+ }, {
+ x: 1890,
+ y: 1360
+ }, {
+ x: 1960,
+ y: 1440
+ }, {
+ x: 2030,
+ y: 1200
+ }, {
+ x: 2030,
+ y: 1300
+ }, {
+ x: 2030,
+ y: 1400
+ }, {
+ x: 2030,
+ y: 1500
+ }],
+ LEFT: [
+ // L
+ {
+ x: 600,
+ y: 1200
+ }, {
+ x: 600,
+ y: 1300
+ }, {
+ x: 600,
+ y: 1400
+ }, {
+ x: 600,
+ y: 1500
+ }, {
+ x: 700,
+ y: 1500
+ }, {
+ x: 800,
+ y: 1500
+ },
+ // E
+ {
+ x: 1000,
+ y: 1200
+ }, {
+ x: 1000,
+ y: 1300
+ }, {
+ x: 1000,
+ y: 1400
+ }, {
+ x: 1000,
+ y: 1500
+ }, {
+ x: 1100,
+ y: 1200
+ }, {
+ x: 1200,
+ y: 1200
+ }, {
+ x: 1100,
+ y: 1350
+ }, {
+ x: 1100,
+ y: 1500
+ }, {
+ x: 1200,
+ y: 1500
+ },
+ // F
+ {
+ x: 1400,
+ y: 1200
+ }, {
+ x: 1400,
+ y: 1300
+ }, {
+ x: 1400,
+ y: 1400
+ }, {
+ x: 1400,
+ y: 1500
+ }, {
+ x: 1500,
+ y: 1200
+ }, {
+ x: 1600,
+ y: 1200
+ }, {
+ x: 1500,
+ y: 1350
+ },
+ // T
+ {
+ x: 1800,
+ y: 1200
+ }, {
+ x: 1900,
+ y: 1200
+ }, {
+ x: 2000,
+ y: 1200
+ }, {
+ x: 1900,
+ y: 1300
+ }, {
+ x: 1900,
+ y: 1400
+ }, {
+ x: 1900,
+ y: 1500
+ }],
+ RIGHT: [
+ // R
+ {
+ x: 400,
+ y: 1200
+ }, {
+ x: 400,
+ y: 1300
+ }, {
+ x: 400,
+ y: 1400
+ }, {
+ x: 400,
+ y: 1500
+ }, {
+ x: 500,
+ y: 1200
+ }, {
+ x: 600,
+ y: 1200
+ }, {
+ x: 600,
+ y: 1300
+ }, {
+ x: 500,
+ y: 1350
+ }, {
+ x: 600,
+ y: 1400
+ }, {
+ x: 700,
+ y: 1500
+ },
+ // I
+ {
+ x: 900,
+ y: 1200
+ }, {
+ x: 1000,
+ y: 1200
+ }, {
+ x: 1100,
+ y: 1200
+ }, {
+ x: 1000,
+ y: 1300
+ }, {
+ x: 1000,
+ y: 1400
+ }, {
+ x: 900,
+ y: 1500
+ }, {
+ x: 1000,
+ y: 1500
+ }, {
+ x: 1100,
+ y: 1500
+ },
+ // G
+ {
+ x: 1300,
+ y: 1250
+ }, {
+ x: 1350,
+ y: 1200
+ }, {
+ x: 1450,
+ y: 1200
+ }, {
+ x: 1500,
+ y: 1200
+ }, {
+ x: 1300,
+ y: 1350
+ }, {
+ x: 1300,
+ y: 1450
+ }, {
+ x: 1350,
+ y: 1500
+ }, {
+ x: 1450,
+ y: 1500
+ }, {
+ x: 1500,
+ y: 1450
+ }, {
+ x: 1500,
+ y: 1400
+ }, {
+ x: 1450,
+ y: 1400
+ },
+ // H
+ {
+ x: 1700,
+ y: 1200
+ }, {
+ x: 1700,
+ y: 1300
+ }, {
+ x: 1700,
+ y: 1400
+ }, {
+ x: 1700,
+ y: 1500
+ }, {
+ x: 1800,
+ y: 1350
+ }, {
+ x: 1900,
+ y: 1350
+ }, {
+ x: 2000,
+ y: 1200
+ }, {
+ x: 2000,
+ y: 1300
+ }, {
+ x: 2000,
+ y: 1400
+ }, {
+ x: 2000,
+ y: 1500
+ },
+ // T
+ {
+ x: 2150,
+ y: 1200
+ }, {
+ x: 2250,
+ y: 1200
+ }, {
+ x: 2350,
+ y: 1200
+ }, {
+ x: 2250,
+ y: 1300
+ }, {
+ x: 2250,
+ y: 1400
+ }, {
+ x: 2250,
+ y: 1500
+ }]
+};
// Initialize score display
scoreDisplay = new Text2(LK.getScore().toString(), {
size: 100,
// Set a nice size for the score
fill: 0xFFFFFF // White color for visibility
});
scoreDisplay.anchor.set(0.5, 0); // Anchor to its top-center point
LK.gui.top.addChild(scoreDisplay); // Add to the GUI at the top-center of the screen
-game.down = function () {
- // Increment score
- LK.setScore(LK.getScore() + 1);
- // Update score display (ensure scoreDisplay is initialized and LK.getScore() is converted to string)
- if (scoreDisplay) {
+game.move = function (x, y) {
+ // Not used for swipe detection, but required by engine
+};
+game.up = function (x, y) {
+ if (!canSwipe || swipeStartX === null || swipeStartY === null) return;
+ var swipeDeltaX = x - swipeStartX;
+ var swipeDeltaY = y - swipeStartY;
+ var swipeThreshold = 100;
+ var detectedDirection = null;
+ if (Math.abs(swipeDeltaX) > Math.abs(swipeDeltaY)) {
+ if (swipeDeltaX > swipeThreshold) {
+ detectedDirection = 'RIGHT';
+ } else if (swipeDeltaX < -swipeThreshold) {
+ detectedDirection = 'LEFT';
+ }
+ } else {
+ if (swipeDeltaY > swipeThreshold) {
+ detectedDirection = 'DOWN';
+ } else if (swipeDeltaY < -swipeThreshold) {
+ detectedDirection = 'UP';
+ }
+ }
+ if (detectedDirection === currentDirection) {
+ // Correct swipe!
+ isCorrectSwipe = true;
+ LK.setScore(LK.getScore() + 1);
scoreDisplay.setText(LK.getScore().toString());
+ // Flash green for correct
+ LK.effects.flashScreen(0x00FF00, 300);
+ // Check win condition
+ if (LK.getScore() >= 20) {
+ LK.showYouWin();
+ return;
+ }
+ // Start next round
+ canSwipe = false;
+ showNextDirection();
+ } else if (detectedDirection !== null) {
+ // Wrong swipe
+ LK.effects.flashScreen(0xFF0000, 300);
}
- // Check for win condition (e.g., score of 10)
- if (LK.getScore() >= 10) {
- LK.showYouWin();
- return; // Stop further execution if game is won
- }
- if (clickMeText) {
- tween(clickMeText, {
- y: -200
- }, {
- duration: 500,
- easing: tween.easeIn,
- onFinish: function onFinish() {
- if (clickMeText) {
- clickMeText.destroy();
- clickMeText = null;
- }
- }
- });
- }
- var tweenFunctions = [tween.linear, tween.easeIn, tween.easeOut, tween.elasticIn, tween.elasticOut, tween.bounceIn, tween.bounceOut, tween.easeInOut, tween.bounceInOut, tween.elasticInOut];
- var randomTweenFunction = tweenFunctions[Math.floor(Math.random() * tweenFunctions.length)];
- var setupType = Math.random();
- var sizeRand = Math.random() * 2;
- var radius = Math.random() * 1000; // Radius for the circular particle formation
- var tweenLength = 1200 * Math.random() + 300;
- var tweenDelay = Math.random() * 3;
- // Filter game.children to get only Particle instances for robust animation logic
+ swipeStartX = null;
+ swipeStartY = null;
+};
+function showNextDirection() {
+ // Choose random direction
+ var directions = ['UP', 'DOWN', 'LEFT', 'RIGHT'];
+ currentDirection = directions[Math.floor(Math.random() * directions.length)];
+ // Get particles
var particles = [];
- for (var k = 0; k < game.children.length; k++) {
- if (game.children[k] instanceof Particle) {
- particles.push(game.children[k]);
+ for (var i = 0; i < game.children.length; i++) {
+ if (game.children[i] instanceof Particle) {
+ particles.push(game.children[i]);
}
}
- var numParticles = particles.length;
- particles.forEach(function (child, particleIndex) {
- // particleIndex is 0 to numParticles-1
- var size = Math.random() * sizeRand;
- var targetPosition;
- // One third of the time, use a grid position, one third random, one third circle
- if (setupType < 0.33) {
- // Use particleIndex for grid assignment
- if (gridPositions.length > 0) {
- targetPosition = gridPositions[particleIndex % gridPositions.length];
- } else {
- // Fallback if gridPositions is somehow empty
- targetPosition = {
- x: Math.random() * 2048,
- y: Math.random() * 2732
- };
- }
- } else if (setupType < 0.66) {
- targetPosition = {
- x: Math.random() * 2048,
- y: Math.random() * 2732
- };
- } else {
- // Use numParticles and particleIndex for accurate circular arrangement
- var angle = numParticles > 0 ? 2 * Math.PI * particleIndex / numParticles : 0;
- targetPosition = {
- x: 1024 + radius * Math.cos(angle),
- y: 1366 + radius * Math.sin(angle)
- };
- }
- tween(child, {
- x: targetPosition.x,
- y: targetPosition.y,
- scaleX: size,
- scaleY: size,
+ // Animate particles to scatter first
+ var scatterDuration = 500;
+ particles.forEach(function (particle, index) {
+ var angle = Math.random() * Math.PI * 2;
+ var radius = 300 + Math.random() * 700;
+ tween(particle, {
+ x: 1024 + Math.cos(angle) * radius,
+ y: 1366 + Math.sin(angle) * radius,
+ scaleX: 0.5,
+ scaleY: 0.5,
rotation: Math.random() * Math.PI * 2,
- tint: Math.random() * 0xffffff
+ tint: 0x666666
}, {
- duration: tweenLength,
- easing: randomTweenFunction,
- delay: particleIndex * tweenDelay // Use particleIndex for consistent delay
+ duration: scatterDuration,
+ easing: tween.easeOut
});
- }); //{y} // Note: original line id {x} for the `if (child instanceof Particle)` block's closing brace is removed as the filter makes it redundant.
+ });
+ // After scatter, form the word
+ LK.setTimeout(function () {
+ var positions = letterPositions[currentDirection];
+ var tweenFunctions = [tween.easeIn, tween.easeOut, tween.elasticOut, tween.bounceOut, tween.easeInOut];
+ var randomTweenFunction = tweenFunctions[Math.floor(Math.random() * tweenFunctions.length)];
+ particles.forEach(function (particle, index) {
+ if (index < positions.length) {
+ // Form letter
+ tween(particle, {
+ x: positions[index].x,
+ y: positions[index].y,
+ scaleX: 0.8,
+ scaleY: 0.8,
+ rotation: 0,
+ tint: 0xFFFFFF
+ }, {
+ duration: 800,
+ easing: randomTweenFunction,
+ delay: index * 10
+ });
+ } else {
+ // Extra particles float around
+ var angle = Math.random() * Math.PI * 2;
+ var radius = 200 + Math.random() * 300;
+ tween(particle, {
+ x: 1024 + Math.cos(angle) * radius,
+ y: 600 + Math.sin(angle) * radius,
+ scaleX: 0.2,
+ scaleY: 0.2,
+ rotation: Math.random() * Math.PI * 2,
+ tint: 0x444444
+ }, {
+ duration: 1000,
+ easing: tween.linear
+ });
+ }
+ });
+ // Enable swiping after animation
+ LK.setTimeout(function () {
+ canSwipe = true;
+ }, 900);
+ }, scatterDuration + 100);
+}
+// Start the first round
+showNextDirection();
+game.down = function (x, y) {
+ if (!canSwipe) return;
+ swipeStartX = x;
+ swipeStartY = y;
+ isCorrectSwipe = false;
};
\ No newline at end of file