User prompt
play button particles should remain the same as the game beginning, even wen coming bakc
User prompt
increase the spacing so that the size of the level map grid is a little bigger and so its numbers
User prompt
add a ! in the end of swipe
User prompt
nice, a little more
User prompt
add a littl more space between the particles in swipe title
User prompt
also the babck button
User prompt
add animations to the partiles in level select βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
play should never change color nehither the frame
User prompt
when you go back, play sould not be yellow
User prompt
move play button more down
User prompt
add also a fram arround swipe like play has
User prompt
nice! now lets add colors again
User prompt
try smaller size of particles
User prompt
Do it
User prompt
add more particles to swipe title for better readability
User prompt
make swipe title particles size a little smaller
User prompt
Before level 1 add a small tutorial that say, just swipe in the direction you are told to (you can also improve the text)
User prompt
make swipe a little more readable
User prompt
Please fix the bug: 'RangeError: Maximum call stack size exceeded' in or related to this line: 'arguments.callee.call(this);' Line Number: 427
User prompt
remove exit from main menu and center and animate play βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
I cant read either the swipe or play, can you fix that please?
User prompt
Please fix the bug: 'storage.get is not a function' in or related to this line: 'var savedProgress = storage.get('unlockedLevels');' Line Number: 501 βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'storage is not defined' in or related to this line: 'var timerRadius = 150; // Radius of the timer ring around score' Line Number: 247
User prompt
Please fix the bug: 'storage is not defined' in or related to this line: 'var savedProgress = storage.get('unlockedLevels');' Line Number: 248 βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
create a game main menu and a level strcuture. also a level map screen, with a list of all the levels in a grid.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var LevelButton = Container.expand(function () { var self = Container.call(this); self.particles = []; self.levelNumber = 1; self.isUnlocked = false; self.buttonSize = 150; self.onClick = null; self.createLevelButton = function (levelNumber, isUnlocked, onClick) { self.levelNumber = levelNumber; self.isUnlocked = isUnlocked; self.onClick = onClick; // Create square outline with particles var particleSpacing = 20; var halfSize = self.buttonSize / 2; // Create square border for (var i = 0; i <= self.buttonSize; i += particleSpacing) { // Top edge var topParticle = self.addChild(new Particle()); topParticle.x = -halfSize + i; topParticle.y = -halfSize; topParticle.scale.set(0.3, 0.3); topParticle.tint = isUnlocked ? 0x00FF00 : 0x808080; self.particles.push(topParticle); // Bottom edge var bottomParticle = self.addChild(new Particle()); bottomParticle.x = -halfSize + i; bottomParticle.y = halfSize; bottomParticle.scale.set(0.3, 0.3); bottomParticle.tint = isUnlocked ? 0x00FF00 : 0x808080; self.particles.push(bottomParticle); // Left edge if (i > 0 && i < self.buttonSize) { var leftParticle = self.addChild(new Particle()); leftParticle.x = -halfSize; leftParticle.y = -halfSize + i; leftParticle.scale.set(0.3, 0.3); leftParticle.tint = isUnlocked ? 0x00FF00 : 0x808080; self.particles.push(leftParticle); } // Right edge if (i > 0 && i < self.buttonSize) { var rightParticle = self.addChild(new Particle()); rightParticle.x = halfSize; rightParticle.y = -halfSize + i; rightParticle.scale.set(0.3, 0.3); rightParticle.tint = isUnlocked ? 0x00FF00 : 0x808080; self.particles.push(rightParticle); } } // Add level number in center var numberString = levelNumber.toString(); var digitSpacing = 40; var startX = -(numberString.length - 1) * digitSpacing / 2; for (var digitIndex = 0; digitIndex < numberString.length; digitIndex++) { var digit = numberString[digitIndex]; if (characterPatterns[digit]) { var pattern = characterPatterns[digit]; var digitX = startX + digitIndex * digitSpacing; for (var row = 0; row < pattern.length; row++) { for (var col = 0; col < pattern[row].length; col++) { if (pattern[row][col] === 1) { var particle = self.addChild(new Particle()); particle.x = digitX + (col - 2) * 8; particle.y = (row - 3) * 8; particle.scale.set(0.2, 0.2); particle.tint = isUnlocked ? 0xFFFFFF : 0x404040; self.particles.push(particle); } } } } } }; self.down = function (x, y) { if (self.isUnlocked && self.onClick) { // Pulse effect self.particles.forEach(function (particle) { tween(particle, { scaleX: particle.scale.x * 1.2, scaleY: particle.scale.y * 1.2 }, { duration: 150, easing: tween.easeOut, onComplete: function onComplete() { tween(particle, { scaleX: particle.scale.x / 1.2, scaleY: particle.scale.y / 1.2 }, { duration: 150, easing: tween.easeIn }); } }); }); self.onClick(self.levelNumber); } }; return self; }); var MenuButton = Container.expand(function () { var self = Container.call(this); self.particles = []; self.buttonText = ''; self.buttonWidth = 600; self.buttonHeight = 120; self.onClick = null; self.createButton = function (text, onClick) { self.buttonText = text; self.onClick = onClick; // Create button outline with particles var particleSpacing = 30; // Top edge for (var x = -self.buttonWidth / 2; x <= self.buttonWidth / 2; x += particleSpacing) { var particle = self.addChild(new Particle()); particle.x = x; particle.y = -self.buttonHeight / 2; particle.scale.set(0.5, 0.5); self.particles.push(particle); } // Bottom edge for (var x = -self.buttonWidth / 2; x <= self.buttonWidth / 2; x += particleSpacing) { var particle = self.addChild(new Particle()); particle.x = x; particle.y = self.buttonHeight / 2; particle.scale.set(0.5, 0.5); self.particles.push(particle); } // Left edge for (var y = -self.buttonHeight / 2 + particleSpacing; y < self.buttonHeight / 2; y += particleSpacing) { var particle = self.addChild(new Particle()); particle.x = -self.buttonWidth / 2; particle.y = y; particle.scale.set(0.5, 0.5); self.particles.push(particle); } // Right edge for (var y = -self.buttonHeight / 2 + particleSpacing; y < self.buttonHeight / 2; y += particleSpacing) { var particle = self.addChild(new Particle()); particle.x = self.buttonWidth / 2; particle.y = y; particle.scale.set(0.5, 0.5); self.particles.push(particle); } // Create text with particles self.createTextParticles(text); }; self.createTextParticles = function (text) { var letterSpacing = 100; var startX = -(text.length - 1) * letterSpacing / 2; for (var i = 0; i < text.length; i++) { var letter = text[i]; if (characterPatterns[letter]) { var pattern = characterPatterns[letter]; var letterX = startX + i * letterSpacing; // Create particles based on pattern for (var row = 0; row < pattern.length; row++) { for (var col = 0; col < pattern[row].length; col++) { if (pattern[row][col] === 1) { var particle = self.addChild(new Particle()); particle.x = letterX + (col - 2) * 12; particle.y = (row - 3) * 12; particle.scale.set(0.4, 0.4); particle.tint = 0xFFFFFF; particle.originalTint = 0xFFFFFF; self.particles.push(particle); } } } } } }; self.down = function (x, y) { if (self.onClick) { // Flash effect self.particles.forEach(function (particle) { tween(particle, { scaleX: 0.8, scaleY: 0.8, tint: 0xFFFF00 }, { duration: 100, easing: tween.easeOut, onComplete: function onComplete() { tween(particle, { scaleX: particle.scale.x, scaleY: particle.scale.y, tint: particle.originalTint }, { duration: 100, easing: tween.easeIn }); } }); }); self.onClick(); } }; return self; }); var Particle = Container.expand(function () { var self = Container.call(this); var particleGraphics = self.attachAsset('particle', { anchorX: 0.5, anchorY: 0.5 }); self.originalTint = getRandomFluorescentColor(); self.tint = self.originalTint; 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 ****/ // Game state management var gameState = 'menu'; // 'menu', 'levelSelect', 'playing' var currentLevel = 1; var unlockedLevels = 1; var menuContainer = null; var levelSelectContainer = null; var gameContainer = null; // Game variables var scoreDisplay; var currentDirection = null; var swipeStartX = null; var swipeStartY = null; var isCorrectSwipe = false; var canSwipe = true; // Array to store score particles var scoreParticles = []; // Timer variables var timerParticles = []; var timerDuration = 5000; // 5 seconds per round in milliseconds var roundStartTime = 0; var timerRadius = 150; // Radius of the timer ring around score // Function to generate bright fluorescent colors function getRandomFluorescentColor() { var fluorColors = [0xFF00FF, // Magenta 0x00FFFF, // Cyan 0xFFFF00, // Yellow 0x00FF00, // Lime 0xFF0080, // Hot Pink 0x80FF00, // Chartreuse 0xFF8000, // Orange 0x00FF80, // Spring Green 0x8000FF, // Purple 0xFF0040, // Rose 0x40FF00, // Green Yellow 0x00FFBF // Turquoise ]; return fluorColors[Math.floor(Math.random() * fluorColors.length)]; } // Character patterns for particles (5x7 grid for each character) var characterPatterns = { // Digits '0': [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]], '1': [[0, 0, 1, 0, 0], [0, 1, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [1, 1, 1, 1, 1]], '2': [[1, 1, 1, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 1], [1, 1, 1, 1, 1], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 1, 1, 1]], '3': [[1, 1, 1, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 1], [1, 1, 1, 1, 1]], '4': [[1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 1]], '5': [[1, 1, 1, 1, 1], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 1], [1, 1, 1, 1, 1]], '6': [[1, 1, 1, 1, 1], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]], '7': [[1, 1, 1, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 1, 0, 0, 0]], '8': [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]], '9': [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 1], [1, 1, 1, 1, 1]], // Letters 'S': [[1, 1, 1, 1, 1], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 1], [1, 1, 1, 1, 1]], 'W': [[1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [1, 1, 0, 1, 1], [1, 0, 0, 0, 1]], 'I': [[1, 1, 1, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [1, 1, 1, 1, 1]], 'P': [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0]], 'E': [[1, 1, 1, 1, 1], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 1, 1, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 1, 1, 1]], 'L': [[1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 1, 1, 1]], 'A': [[0, 1, 1, 1, 0], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1]], 'Y': [[1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0]], 'X': [[1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1]], 'T': [[1, 1, 1, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0]], 'B': [[1, 1, 1, 1, 0], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 0], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 0]], 'C': [[0, 1, 1, 1, 1], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [0, 1, 1, 1, 1]], 'K': [[1, 0, 0, 0, 1], [1, 0, 0, 1, 0], [1, 0, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 1, 0, 0], [1, 0, 0, 1, 0], [1, 0, 0, 0, 1]], 'V': [[1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0]] }; // Keep digitPatterns as alias for backward compatibility var digitPatterns = characterPatterns; function updateScoreDisplay(score) { // Clear existing score particles scoreParticles.forEach(function (particle) { particle.destroy(); }); scoreParticles = []; var scoreString = score.toString(); var digitSpacing = 80; // Space between digits var particleSize = 12; // Size of each particle in the digit var startX = -(scoreString.length - 1) * digitSpacing / 2; // Create particles for each digit for (var digitIndex = 0; digitIndex < scoreString.length; digitIndex++) { var digit = scoreString[digitIndex]; var pattern = characterPatterns[digit]; var digitX = startX + digitIndex * digitSpacing; // Create particles based on pattern for (var row = 0; row < pattern.length; row++) { for (var col = 0; col < pattern[row].length; col++) { if (pattern[row][col] === 1) { var particle = scoreContainer.addChild(new Particle()); particle.x = digitX + (col - 2) * particleSize; particle.y = (row - 3) * particleSize; particle.scale.set(0.3, 0.3); particle.tint = 0xFFFFFF; // White color for score scoreParticles.push(particle); } } } } } // Initialize containers menuContainer = new Container(); levelSelectContainer = new Container(); gameContainer = new Container(); // Initialize score display container within game container var scoreContainer = new Container(); scoreContainer.x = 1024; // Center horizontally scoreContainer.y = 250; // Position lower to accommodate timer ring gameContainer.addChild(scoreContainer); // Create main menu function createMainMenu() { // Clear existing menu items while (menuContainer.children.length > 0) { menuContainer.children[0].destroy(); } // Title particles with proper letter shapes var titleY = 600; var titleText = "SWIPE"; var letterSpacing = 200; var startX = 1024 - (titleText.length - 1) * letterSpacing / 2; for (var i = 0; i < titleText.length; i++) { var letter = titleText[i]; if (characterPatterns[letter]) { var pattern = characterPatterns[letter]; var letterX = startX + i * letterSpacing; // Create particles based on pattern for (var row = 0; row < pattern.length; row++) { for (var col = 0; col < pattern[row].length; col++) { if (pattern[row][col] === 1) { var particle = menuContainer.addChild(new Particle()); particle.x = letterX + (col - 2) * 25; // Larger spacing for title particle.y = titleY + (row - 3) * 25; particle.scale.set(1.2, 1.2); // Store base position for floating animation particle.baseX = particle.x; particle.baseY = particle.y; particle.floatOffset = Math.random() * Math.PI * 2; // Floating animation particle.update = function () { this.x = this.baseX + Math.sin(Date.now() * 0.001 + this.floatOffset) * 10; this.y = this.baseY + Math.sin(Date.now() * 0.002 + this.floatOffset) * 15; this.rotation += 0.01; }; } } } } } // Play button var playButton = menuContainer.addChild(new MenuButton()); playButton.x = 1024; playButton.y = 1200; playButton.createButton("PLAY", function () { showLevelSelect(); }); // Exit button (placeholder) var exitButton = menuContainer.addChild(new MenuButton()); exitButton.x = 1024; exitButton.y = 1400; exitButton.createButton("EXIT", function () { // Exit functionality handled by platform }); } // Create level select screen function createLevelSelect() { // Clear existing items while (levelSelectContainer.children.length > 0) { levelSelectContainer.children[0].destroy(); } // Title var titleParticles = []; var titleText = "LEVELS"; var letterSpacing = 120; var startX = 1024 - (titleText.length - 1) * letterSpacing / 2; for (var i = 0; i < titleText.length; i++) { for (var j = 0; j < 8; j++) { var particle = levelSelectContainer.addChild(new Particle()); particle.x = startX + i * letterSpacing + (Math.random() - 0.5) * 30; particle.y = 300 + (Math.random() - 0.5) * 30; particle.scale.set(1, 1); particle.tint = 0x00FFFF; titleParticles.push(particle); } } // Level grid var levelsPerRow = 4; var totalLevels = 20; var gridStartX = 1024 - (levelsPerRow - 1) * 200 / 2; var gridStartY = 600; var spacing = 200; for (var level = 1; level <= totalLevels; level++) { var row = Math.floor((level - 1) / levelsPerRow); var col = (level - 1) % levelsPerRow; var levelButton = levelSelectContainer.addChild(new LevelButton()); levelButton.x = gridStartX + col * spacing; levelButton.y = gridStartY + row * spacing; levelButton.createLevelButton(level, level <= unlockedLevels, function (selectedLevel) { startLevel(selectedLevel); }); } // Back button var backButton = levelSelectContainer.addChild(new MenuButton()); backButton.x = 1024; backButton.y = 2200; backButton.createButton("BACK", function () { showMainMenu(); }); } // Show main menu function showMainMenu() { gameState = 'menu'; game.removeChild(levelSelectContainer); game.removeChild(gameContainer); game.addChild(menuContainer); if (menuContainer.children.length === 0) { createMainMenu(); } } // Show level select function showLevelSelect() { gameState = 'levelSelect'; game.removeChild(menuContainer); game.removeChild(gameContainer); game.addChild(levelSelectContainer); createLevelSelect(); } // Start a specific level function startLevel(level) { currentLevel = level; gameState = 'playing'; game.removeChild(menuContainer); game.removeChild(levelSelectContainer); game.addChild(gameContainer); // Reset game state LK.setScore(0); updateScoreDisplay(0); canSwipe = true; // Adjust difficulty based on level timerDuration = Math.max(2000, 5000 - (level - 1) * 200); // Gets harder each level // Create game particles initializeGameParticles(); // Start first round showNextDirection(); } // Initialize game particles function initializeGameParticles() { // Clear existing game particles for (var i = gameContainer.children.length - 1; i >= 0; i--) { var child = gameContainer.children[i]; if (child instanceof Particle) { child.destroy(); } } // Create background particles for (var i = 0; i < 500; i++) { var particle = gameContainer.addChild(new Particle()); var angle = Math.random() * Math.PI * 2; var radius = Math.random() * 300; particle.x = 1024 + Math.cos(angle) * radius; particle.y = 1366 + Math.sin(angle) * radius; particle.scale.set(4, 4); // Initialize cloud movement parameters particle.cloudAngle = angle; particle.cloudRadius = radius; particle.cloudSpeed = 0.01 + Math.random() * 0.02; particle.driftSpeed = 0.5 + Math.random() * 1; } } // Function to create timer ring function createTimerRing() { // Clear existing timer particles timerParticles.forEach(function (particle) { particle.destroy(); }); timerParticles = []; // Create particles in a circle var particleCount = 60; // Number of particles in the ring for (var i = 0; i < particleCount; i++) { // Start from top (-PI/2) and go clockwise var angle = -Math.PI / 2 + i / particleCount * Math.PI * 2; var particle = scoreContainer.addChild(new Particle()); // Position in circle around score particle.x = Math.cos(angle) * timerRadius; particle.y = Math.sin(angle) * timerRadius; particle.scale.set(0.2, 0.2); particle.tint = 0x00FF00; // Start with green particle.timerIndex = i; particle.baseAngle = angle; timerParticles.push(particle); } } // Initialize score display updateScoreDisplay(0); // Initialize timer ring createTimerRing(); // Load saved progress var savedProgress = storage.unlockedLevels; if (savedProgress) { unlockedLevels = savedProgress; } // Start with main menu showMainMenu(); // Create arrow positions for directional indicators - centered on screen var arrowPositions = { UP: [ // Arrow pointing up (β) // Vertical line { x: 1024, y: 1200 }, { x: 1024, y: 1280 }, { x: 1024, y: 1360 }, { x: 1024, y: 1440 }, { x: 1024, y: 1520 }, // Arrowhead { x: 944, y: 1280 }, { x: 974, y: 1240 }, { x: 1004, y: 1200 }, { x: 1044, y: 1200 }, { x: 1074, y: 1240 }, { x: 1104, y: 1280 }], DOWN: [ // Arrow pointing down (β) // Vertical line { x: 1024, y: 1200 }, { x: 1024, y: 1280 }, { x: 1024, y: 1360 }, { x: 1024, y: 1440 }, { x: 1024, y: 1520 }, // Arrowhead { x: 944, y: 1440 }, { x: 974, y: 1480 }, { x: 1004, y: 1520 }, { x: 1044, y: 1520 }, { x: 1074, y: 1480 }, { x: 1104, y: 1440 }], LEFT: [ // Arrow pointing left (β) // Horizontal line { x: 824, y: 1360 }, { x: 904, y: 1360 }, { x: 984, y: 1360 }, { x: 1064, y: 1360 }, { x: 1144, y: 1360 }, { x: 1224, y: 1360 }, // Arrowhead { x: 904, y: 1280 }, { x: 864, y: 1320 }, { x: 824, y: 1360 }, { x: 864, y: 1400 }, { x: 904, y: 1440 }], RIGHT: [ // Arrow pointing right (β) // Horizontal line { x: 824, y: 1360 }, { x: 904, y: 1360 }, { x: 984, y: 1360 }, { x: 1064, y: 1360 }, { x: 1144, y: 1360 }, { x: 1224, y: 1360 }, // Arrowhead { x: 1144, y: 1280 }, { x: 1184, y: 1320 }, { x: 1224, y: 1360 }, { x: 1184, y: 1400 }, { x: 1144, y: 1440 }] }; game.move = function (x, y) { // Only handle move in game state if (gameState === 'playing') { // 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'; } } // Check if swipe matches the required direction var isCorrect = detectedDirection === currentDirection; if (isCorrect) { // Correct swipe! isCorrectSwipe = true; LK.setScore(LK.getScore() + 1); updateScoreDisplay(LK.getScore()); // Flash green for correct LK.effects.flashScreen(0x00FF00, 300); // Check win condition - scale with level var targetScore = 10 + currentLevel * 5; if (LK.getScore() >= targetScore) { // Level complete! if (currentLevel >= unlockedLevels) { unlockedLevels = currentLevel + 1; storage.unlockedLevels = unlockedLevels; } LK.effects.flashScreen(0x00FF00, 1000); // Return to level select after a delay LK.setTimeout(function () { showLevelSelect(); }, 1500); return; } // Start next round canSwipe = false; showNextDirection(); } else if (detectedDirection !== null) { // Wrong swipe - game over LK.effects.flashScreen(0xFF0000, 300); // Return to level select after a delay LK.setTimeout(function () { showLevelSelect(); }, 1500); } swipeStartX = null; swipeStartY = null; }; function showNextDirection() { // Reset timer for new round roundStartTime = Date.now(); // Reset timer particles to full visibility timerParticles.forEach(function (particle) { particle.alpha = 1; particle.scale.set(0.2, 0.2); particle.tint = 0x00FF00; // Reset to green }); // Choose random direction var directions = ['UP', 'DOWN', 'LEFT', 'RIGHT']; currentDirection = directions[Math.floor(Math.random() * directions.length)]; var directionColors = { UP: 0xFFFF00, // Bright Yellow DOWN: 0x00FFFF, // Bright Cyan LEFT: 0x00FF00, // Bright Green RIGHT: 0xFF00FF // Bright Magenta }; // Get particles from game container var particles = []; for (var i = 0; i < gameContainer.children.length; i++) { if (gameContainer.children[i] instanceof Particle) { particles.push(gameContainer.children[i]); } } // Animate particles to scatter first var scatterDuration = 500; particles.forEach(function (particle, index) { var angle = Math.random() * Math.PI * 2; var radius = 400 + Math.random() * 800; 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: particle.originalTint }, { duration: scatterDuration, easing: tween.easeOut }); }); // After scatter, form the word LK.setTimeout(function () { // Get arrow positions for the current direction var positions = arrowPositions[currentDirection].slice(); // Clone and shuffle the positions var shuffledPositions = positions.slice(); for (var i = shuffledPositions.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = shuffledPositions[i]; shuffledPositions[i] = shuffledPositions[j]; shuffledPositions[j] = temp; } var tweenFunctions = [tween.easeIn, tween.easeOut, tween.elasticOut, tween.bounceOut, tween.easeInOut]; var randomTweenFunction = tweenFunctions[Math.floor(Math.random() * tweenFunctions.length)]; // Use direction color for the word var wordColor = directionColors[currentDirection]; particles.forEach(function (particle, index) { if (index < shuffledPositions.length) { // Form letter // Clear cloud parameters so particle is identified as word particle delete particle.cloudAngle; delete particle.cloudRadius; delete particle.cloudSpeed; delete particle.driftSpeed; tween(particle, { x: shuffledPositions[index].x, y: shuffledPositions[index].y, scaleX: 1.2, // Increased scale for better readability scaleY: 1.2, // Increased scale for better readability rotation: 0, tint: wordColor // Same color for all particles in the word }, { duration: 800, easing: randomTweenFunction, delay: index * 10 }); } else { // Extra particles float around in cloud-like motion var angle = Math.random() * Math.PI * 2; var radius = 300 + Math.random() * 400; var targetX = 1024 + Math.cos(angle) * radius; var targetY = 1366 + Math.sin(angle) * radius; // Store cloud movement parameters on particle particle.cloudAngle = angle; particle.cloudRadius = radius; particle.cloudSpeed = 0.01 + Math.random() * 0.02; particle.driftSpeed = 0.5 + Math.random() * 1; tween(particle, { x: targetX, y: targetY, scaleX: 0.2, scaleY: 0.2, rotation: Math.random() * Math.PI * 2, tint: particle.originalTint }, { duration: 1000, easing: tween.linear }); } }); // Enable swiping after animation LK.setTimeout(function () { canSwipe = true; }, 900); }, scatterDuration + 100); } // Add continuous movement for background particles game.update = function () { // Update menu particles if (gameState === 'menu' && menuContainer) { for (var i = 0; i < menuContainer.children.length; i++) { var child = menuContainer.children[i]; if (child.update) { child.update(); } } } // Only update game particles when playing if (gameState !== 'playing') return; // Move particles that are in cloud formation for (var i = 0; i < gameContainer.children.length; i++) { var particle = gameContainer.children[i]; if (particle instanceof Particle) { // Check if particle is part of the word (not in cloud formation) if (particle.cloudAngle === undefined) { // Add small wiggle to word particles var wiggleX = Math.sin(Date.now() * 0.003 + i) * 0.15; var wiggleY = Math.cos(Date.now() * 0.003 + i) * 0.15; particle.x = particle.x + wiggleX; particle.y = particle.y + wiggleY; } else { // Original cloud movement for background particles // Update cloud angle for circular drift particle.cloudAngle += particle.cloudSpeed; // Calculate new position within cloud shape var centerX = 1024; var centerY = 1366; var cloudX = centerX + Math.cos(particle.cloudAngle) * particle.cloudRadius; var cloudY = centerY + Math.sin(particle.cloudAngle) * particle.cloudRadius; // Add some drift movement var driftX = Math.sin(Date.now() * 0.001 * particle.driftSpeed) * 20; var driftY = Math.cos(Date.now() * 0.001 * particle.driftSpeed) * 15; // Apply movement particle.x = cloudX + driftX; particle.y = cloudY + driftY; // Gentle rotation particle.rotation += 0.01; } } } // Add wiggle effect to score particles scoreParticles.forEach(function (particle, index) { var wiggleX = Math.sin(Date.now() * 0.002 + index * 0.1) * 0.3; var wiggleY = Math.cos(Date.now() * 0.002 + index * 0.1) * 0.3; particle.x = particle.x + wiggleX; particle.y = particle.y + wiggleY; }); // Update timer ring if (canSwipe && roundStartTime > 0) { var elapsedTime = Date.now() - roundStartTime; var timeRemaining = Math.max(0, timerDuration - elapsedTime); var progress = timeRemaining / timerDuration; // Update timer particles timerParticles.forEach(function (particle, index) { // Calculate threshold for this particle (inverted so it depletes clockwise from top) var threshold = 1 - index / timerParticles.length; if (threshold > progress) { particle.alpha = 0.1; // Fade out depleted particles particle.scale.set(0.1, 0.1); } else { particle.alpha = 1; particle.scale.set(0.2, 0.2); // Change color based on time remaining if (progress < 0.2) { particle.tint = 0xFF0000; // Red when low on time } else if (progress < 0.5) { particle.tint = 0xFFFF00; // Yellow when half time } else { particle.tint = 0x00FF00; // Green when plenty of time } // Add pulsing effect when time is low if (progress < 0.2) { var pulse = Math.sin(Date.now() * 0.01) * 0.1 + 0.2; particle.scale.set(pulse, pulse); } } // Add gentle orbital movement var orbitOffset = Math.sin(Date.now() * 0.001 + index * 0.1) * 5; particle.x = Math.cos(particle.baseAngle) * (timerRadius + orbitOffset); particle.y = Math.sin(particle.baseAngle) * (timerRadius + orbitOffset); }); // Check if time ran out if (timeRemaining === 0 && canSwipe) { // Time's up - return to level select canSwipe = false; LK.effects.flashScreen(0xFF0000, 500); LK.setTimeout(function () { showLevelSelect(); }, 1500); } } }; // First round will be started when entering a level game.down = function (x, y) { if (gameState === 'playing') { if (!canSwipe) return; swipeStartX = x; swipeStartY = y; isCorrectSwipe = false; } };
===================================================================
--- original.js
+++ change.js
@@ -61,10 +61,10 @@
var digitSpacing = 40;
var startX = -(numberString.length - 1) * digitSpacing / 2;
for (var digitIndex = 0; digitIndex < numberString.length; digitIndex++) {
var digit = numberString[digitIndex];
- if (digitPatterns[digit]) {
- var pattern = digitPatterns[digit];
+ if (characterPatterns[digit]) {
+ var pattern = characterPatterns[digit];
var digitX = startX + digitIndex * digitSpacing;
for (var row = 0; row < pattern.length; row++) {
for (var col = 0; col < pattern[row].length; col++) {
if (pattern[row][col] === 1) {
@@ -153,20 +153,29 @@
// Create text with particles
self.createTextParticles(text);
};
self.createTextParticles = function (text) {
- var letterSpacing = 80;
+ var letterSpacing = 100;
var startX = -(text.length - 1) * letterSpacing / 2;
for (var i = 0; i < text.length; i++) {
- var letterX = startX + i * letterSpacing;
- // Simple representation - just vertical lines for now
- for (var y = -20; y <= 20; y += 10) {
- var particle = self.addChild(new Particle());
- particle.x = letterX;
- particle.y = y;
- particle.scale.set(0.3, 0.3);
- particle.tint = 0xFFFFFF;
- self.particles.push(particle);
+ var letter = text[i];
+ if (characterPatterns[letter]) {
+ var pattern = characterPatterns[letter];
+ var letterX = startX + i * letterSpacing;
+ // Create particles based on pattern
+ for (var row = 0; row < pattern.length; row++) {
+ for (var col = 0; col < pattern[row].length; col++) {
+ if (pattern[row][col] === 1) {
+ var particle = self.addChild(new Particle());
+ particle.x = letterX + (col - 2) * 12;
+ particle.y = (row - 3) * 12;
+ particle.scale.set(0.4, 0.4);
+ particle.tint = 0xFFFFFF;
+ particle.originalTint = 0xFFFFFF;
+ self.particles.push(particle);
+ }
+ }
+ }
}
}
};
self.down = function (x, y) {
@@ -267,10 +276,11 @@
0x00FFBF // Turquoise
];
return fluorColors[Math.floor(Math.random() * fluorColors.length)];
}
-// Digit patterns for particles (5x7 grid for each digit)
-var digitPatterns = {
+// Character patterns for particles (5x7 grid for each character)
+var characterPatterns = {
+ // Digits
'0': [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]],
'1': [[0, 0, 1, 0, 0], [0, 1, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [1, 1, 1, 1, 1]],
'2': [[1, 1, 1, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 1], [1, 1, 1, 1, 1], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 1, 1, 1]],
'3': [[1, 1, 1, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 1], [1, 1, 1, 1, 1]],
@@ -278,10 +288,27 @@
'5': [[1, 1, 1, 1, 1], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 1], [1, 1, 1, 1, 1]],
'6': [[1, 1, 1, 1, 1], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]],
'7': [[1, 1, 1, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 1, 0, 0, 0]],
'8': [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]],
- '9': [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 1], [1, 1, 1, 1, 1]]
+ '9': [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 1], [1, 1, 1, 1, 1]],
+ // Letters
+ 'S': [[1, 1, 1, 1, 1], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 1], [1, 1, 1, 1, 1]],
+ 'W': [[1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [1, 1, 0, 1, 1], [1, 0, 0, 0, 1]],
+ 'I': [[1, 1, 1, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [1, 1, 1, 1, 1]],
+ 'P': [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0]],
+ 'E': [[1, 1, 1, 1, 1], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 1, 1, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 1, 1, 1]],
+ 'L': [[1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 1, 1, 1]],
+ 'A': [[0, 1, 1, 1, 0], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1]],
+ 'Y': [[1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0]],
+ 'X': [[1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1]],
+ 'T': [[1, 1, 1, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0]],
+ 'B': [[1, 1, 1, 1, 0], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 0], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 0]],
+ 'C': [[0, 1, 1, 1, 1], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [0, 1, 1, 1, 1]],
+ 'K': [[1, 0, 0, 0, 1], [1, 0, 0, 1, 0], [1, 0, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 1, 0, 0], [1, 0, 0, 1, 0], [1, 0, 0, 0, 1]],
+ 'V': [[1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0]]
};
+// Keep digitPatterns as alias for backward compatibility
+var digitPatterns = characterPatterns;
function updateScoreDisplay(score) {
// Clear existing score particles
scoreParticles.forEach(function (particle) {
particle.destroy();
@@ -293,9 +320,9 @@
var startX = -(scoreString.length - 1) * digitSpacing / 2;
// Create particles for each digit
for (var digitIndex = 0; digitIndex < scoreString.length; digitIndex++) {
var digit = scoreString[digitIndex];
- var pattern = digitPatterns[digit];
+ var pattern = characterPatterns[digit];
var digitX = startX + digitIndex * digitSpacing;
// Create particles based on pattern
for (var row = 0; row < pattern.length; row++) {
for (var col = 0; col < pattern[row].length; col++) {
@@ -325,25 +352,39 @@
// Clear existing menu items
while (menuContainer.children.length > 0) {
menuContainer.children[0].destroy();
}
- // Title particles
+ // Title particles with proper letter shapes
var titleY = 600;
var titleText = "SWIPE";
- var letterSpacing = 150;
+ var letterSpacing = 200;
var startX = 1024 - (titleText.length - 1) * letterSpacing / 2;
for (var i = 0; i < titleText.length; i++) {
- for (var j = 0; j < 10; j++) {
- var particle = menuContainer.addChild(new Particle());
- particle.x = startX + i * letterSpacing + (Math.random() - 0.5) * 40;
- particle.y = titleY + (Math.random() - 0.5) * 40;
- particle.scale.set(1.5, 1.5);
- // Floating animation
- var floatY = particle.y;
- particle.update = function () {
- this.y = floatY + Math.sin(Date.now() * 0.002 + this.x * 0.01) * 20;
- this.rotation += 0.02;
- };
+ var letter = titleText[i];
+ if (characterPatterns[letter]) {
+ var pattern = characterPatterns[letter];
+ var letterX = startX + i * letterSpacing;
+ // Create particles based on pattern
+ for (var row = 0; row < pattern.length; row++) {
+ for (var col = 0; col < pattern[row].length; col++) {
+ if (pattern[row][col] === 1) {
+ var particle = menuContainer.addChild(new Particle());
+ particle.x = letterX + (col - 2) * 25; // Larger spacing for title
+ particle.y = titleY + (row - 3) * 25;
+ particle.scale.set(1.2, 1.2);
+ // Store base position for floating animation
+ particle.baseX = particle.x;
+ particle.baseY = particle.y;
+ particle.floatOffset = Math.random() * Math.PI * 2;
+ // Floating animation
+ particle.update = function () {
+ this.x = this.baseX + Math.sin(Date.now() * 0.001 + this.floatOffset) * 10;
+ this.y = this.baseY + Math.sin(Date.now() * 0.002 + this.floatOffset) * 15;
+ this.rotation += 0.01;
+ };
+ }
+ }
+ }
}
}
// Play button
var playButton = menuContainer.addChild(new MenuButton());