User prompt
add some power ups ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
add more assets
User prompt
fix the lag
User prompt
make it smooth @upit/tween.v1 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
make it smooth ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
add more level
User prompt
add more time
User prompt
make the assets more big ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
make it harder
User prompt
make the map bigger
User prompt
make the assets across around the map ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
make the time 20 second
User prompt
make the map more fancy ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
make the assets more smooth ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
make it harder
User prompt
not working
User prompt
dimension not working
User prompt
game not working
Code edit (1 edits merged)
Please save this source code
User prompt
Quantum Paradox
Initial prompt
impres me
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var BackgroundStar = Container.expand(function () { var self = Container.call(this); var starGraphics = self.attachAsset('star', { anchorX: 0.5, anchorY: 0.5 }); self.twinkleSpeed = 0.02 + Math.random() * 0.03; self.twinkleOffset = Math.random() * Math.PI * 2; self.baseAlpha = 0.3 + Math.random() * 0.7; self.update = function () { // Direct property updates instead of creating tweens every frame var twinkle = Math.sin(LK.ticks * self.twinkleSpeed + self.twinkleOffset) * 0.3 + 0.7; self.alpha = self.baseAlpha * twinkle; // Direct position updates for smooth movement self.x += Math.sin(LK.ticks * 0.01 + self.twinkleOffset) * 0.02; self.y += Math.cos(LK.ticks * 0.008 + self.twinkleOffset) * 0.015; }; return self; }); var EnergyCrystal = Container.expand(function () { var self = Container.call(this); var crystalGraphics = self.attachAsset('energyCrystal', { anchorX: 0.5, anchorY: 0.5 }); self.dimension = 0; self.isCollected = false; self.pulsePhase = Math.random() * Math.PI * 2; self.setDimension = function (dim) { self.dimension = dim; self.alpha = 1.0; }; self.collect = function () { self.isCollected = true; LK.getSound('crystalSound').play(); // Spinning collection animation tween(crystalGraphics, { rotation: crystalGraphics.rotation + Math.PI * 4 }, { duration: 800, easing: tween.easeOut }); tween(self, { scaleX: 2.0, scaleY: 2.0, alpha: 0 }, { duration: 800, easing: tween.easeOut, onFinish: function onFinish() { self.visible = false; } }); }; self.update = function () { if (self.isCollected) return; // Pulsing glow effect self.pulsePhase += 0.1; var pulse = Math.sin(self.pulsePhase) * 0.3 + 0.7; crystalGraphics.alpha = pulse; // Floating motion crystalGraphics.y += Math.sin(self.pulsePhase * 0.5) * 0.5; crystalGraphics.rotation += 0.03; // Visibility based on dimension if (self.dimension === currentDimension) { self.alpha = 1.0; } else { self.alpha = 0.3; } }; return self; }); var InterferenceField = Container.expand(function () { var self = Container.call(this); var fieldGraphics = self.attachAsset('interferenceField', { anchorX: 0.5, anchorY: 0.5 }); self.dimension = 0; self.pulseDirection = 1; self.setDimension = function (dim) { self.dimension = dim; self.alpha = 0.8; }; self.update = function () { // Direct rotation update fieldGraphics.rotation += 0.015; // Direct alpha updates instead of creating tweens every frame if (self.dimension === currentDimension) { self.alpha = 0.7 + Math.sin(LK.ticks * 0.05) * 0.3; } else { self.alpha = 0.2; } // Direct position updates for moving fields if (self.moveDirection !== undefined) { self.x += self.moveDirection * 4; if (self.x <= self.minX || self.x >= self.maxX) { self.moveDirection *= -1; } } }; return self; }); var Particle = Container.expand(function () { var self = Container.call(this); var particleGraphics = self.attachAsset('particle', { anchorX: 0.5, anchorY: 0.5 }); self.dimension = 0; self.originalPosition = { x: 0, y: 0 }; self.isBeingDragged = false; self.isCollected = false; self.entangledWith = null; self.setDimension = function (dim) { self.dimension = dim; self.alpha = 1.0; }; self.startDrag = function () { self.isBeingDragged = true; tween(particleGraphics, { scaleX: 1.2, scaleY: 1.2 }, { duration: 200 }); }; self.stopDrag = function () { self.isBeingDragged = false; tween(particleGraphics, { scaleX: 1.0, scaleY: 1.0 }, { duration: 200 }); }; self.collect = function () { self.isCollected = true; // Enhanced collection animation with bounce effect tween(self, { scaleX: 1.5, scaleY: 1.5 }, { duration: 150, easing: tween.easeOut, onFinish: function onFinish() { tween(self, { alpha: 0, scaleX: 0.1, scaleY: 0.1 }, { duration: 200, easing: tween.easeIn, onFinish: function onFinish() { self.visible = false; } }); } }); }; self.update = function () { if (self.isCollected) return; // Initialize collision tracking if (self.lastCoreIntersecting === undefined) { self.lastCoreIntersecting = false; } // Check collision with quantum core - only trigger on first contact var currentCoreIntersecting = self.dimension === currentDimension && quantumCore && self.intersects(quantumCore); if (!self.lastCoreIntersecting && currentCoreIntersecting) { self.collect(); LK.getSound('collectSound').play(); particlesCollected++; checkWinCondition(); } self.lastCoreIntersecting = currentCoreIntersecting; // Check collision with interference fields for (var i = 0; i < interferenceFields.length; i++) { var field = interferenceFields[i]; if (field.dimension === self.dimension && self.intersects(field)) { resetLevel(); return; } } // Handle entanglement if (self.entangledWith && !self.isBeingDragged && self.entangledWith.isBeingDragged) { self.x = self.entangledWith.x + 150; self.y = self.entangledWith.y; } }; self.down = function (x, y, obj) { // Drag handling is now managed by game.down event handler }; return self; }); var Portal = Container.expand(function () { var self = Container.call(this); var portalGraphics = self.attachAsset('portal', { anchorX: 0.5, anchorY: 0.5 }); self.dimension = 0; self.targetDimension = 1; self.setDimension = function (dim) { self.dimension = dim; self.alpha = 1.0; }; self.update = function () { // Direct rotation update portalGraphics.rotation += 0.02; // Check if particles are transported through portal for (var i = 0; i < particles.length; i++) { var particle = particles[i]; if (particle.dimension === self.dimension && self.intersects(particle) && !particle.isBeingDragged) { particle.setDimension(self.targetDimension); LK.getSound('portalSound').play(); LK.effects.flashObject(self, 0xffffff, 300); } } }; return self; }); var PowerOrb = Container.expand(function () { var self = Container.call(this); var orbGraphics = self.attachAsset('powerOrb', { anchorX: 0.5, anchorY: 0.5 }); self.dimension = 0; self.isCollected = false; self.energyPhase = Math.random() * Math.PI * 2; self.setDimension = function (dim) { self.dimension = dim; self.alpha = 1.0; }; self.collect = function () { self.isCollected = true; LK.getSound('powerUpSound').play(); // Burst effect tween(self, { scaleX: 3.0, scaleY: 3.0, alpha: 0 }, { duration: 600, easing: tween.easeOut, onFinish: function onFinish() { self.visible = false; } }); // Add time bonus timeRemaining += 5000; // 5 seconds bonus LK.effects.flashScreen(0xffff00, 300); }; self.update = function () { if (self.isCollected) return; // Energy crackling effect self.energyPhase += 0.15; var energy = Math.sin(self.energyPhase) * 0.5 + 0.5; orbGraphics.scaleX = 0.8 + energy * 0.4; orbGraphics.scaleY = 0.8 + energy * 0.4; orbGraphics.rotation += 0.05; // Visibility based on dimension if (self.dimension === currentDimension) { self.alpha = 1.0; } else { self.alpha = 0.3; } }; return self; }); var Vortex = Container.expand(function () { var self = Container.call(this); var vortexGraphics = self.attachAsset('vortex', { anchorX: 0.5, anchorY: 0.5 }); self.dimension = 0; self.isActive = true; self.rotationSpeed = 0.08; self.setDimension = function (dim) { self.dimension = dim; self.alpha = 0.6; }; self.update = function () { if (!self.isActive) return; // Swirling vortex animation vortexGraphics.rotation += self.rotationSpeed; // Pulsing size effect var pulse = Math.sin(LK.ticks * 0.06) * 0.2 + 0.8; vortexGraphics.scaleX = pulse; vortexGraphics.scaleY = pulse; // Visibility based on dimension if (self.dimension === currentDimension) { self.alpha = 0.6; } else { self.alpha = 0.1; } // Attract nearby particles if (self.dimension === currentDimension) { for (var i = 0; i < particles.length; i++) { var particle = particles[i]; if (particle.dimension === self.dimension && !particle.isBeingDragged) { var dx = self.x - particle.x; var dy = self.y - particle.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < 300 && distance > 100) { var force = 0.5; particle.x += dx * force / distance; particle.y += dy * force / distance; } } } } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000033 }); /**** * Game Code ****/ var currentDimension = 0; var totalDimensions = 2; var particles = []; var portals = []; var interferenceFields = []; var energyCrystals = []; var powerOrbs = []; var vortexes = []; var shieldBubbles = []; var darkMatterClouds = []; var quantumCore; var draggedParticle = null; var dragOffset = { x: 0, y: 0 }; var particlesCollected = 0; var totalParticles = 0; var level = 1; var timeLimit = 25000; // 25 seconds in milliseconds var timeRemaining = timeLimit; var timerActive = false; var dimensionSwitches = 0; var maxDimensionSwitches = 5; var backgroundStars = []; var crystalsCollected = 0; var totalCrystals = 0; // UI Elements var dimensionText = new Text2('Dimension: 0', { size: 60, fill: 0xFFFFFF }); dimensionText.anchor.set(0.5, 0); LK.gui.top.addChild(dimensionText); var levelText = new Text2('Level: 1', { size: 50, fill: 0xFFFFFF }); levelText.anchor.set(0.5, 0); levelText.y = 100; LK.gui.top.addChild(levelText); var instructionText = new Text2('Tap to switch dimensions', { size: 40, fill: 0xCCCCCC }); instructionText.anchor.set(0.5, 1); LK.gui.bottom.addChild(instructionText); var timerText = new Text2('Time: 25s', { size: 50, fill: 0xFFFFFF }); timerText.anchor.set(0.5, 0); timerText.y = 160; LK.gui.top.addChild(timerText); // Create dimension indicators var dimensionIndicators = []; for (var d = 0; d < totalDimensions; d++) { var indicator = LK.getAsset('dimensionIndicator', { anchorX: 0.5, anchorY: 0.5, x: 1024 + d * 60, y: 150 }); dimensionIndicators.push(indicator); LK.gui.addChild(indicator); } function initializeLevel() { // Clear existing elements for (var i = 0; i < particles.length; i++) { particles[i].destroy(); } for (var i = 0; i < portals.length; i++) { portals[i].destroy(); } for (var i = 0; i < interferenceFields.length; i++) { interferenceFields[i].destroy(); } for (var i = 0; i < backgroundStars.length; i++) { backgroundStars[i].destroy(); } for (var i = 0; i < energyCrystals.length; i++) { energyCrystals[i].destroy(); } for (var i = 0; i < powerOrbs.length; i++) { powerOrbs[i].destroy(); } for (var i = 0; i < vortexes.length; i++) { vortexes[i].destroy(); } for (var i = 0; i < shieldBubbles.length; i++) { shieldBubbles[i].destroy(); } for (var i = 0; i < darkMatterClouds.length; i++) { darkMatterClouds[i].destroy(); } backgroundStars = []; particles = []; portals = []; interferenceFields = []; energyCrystals = []; powerOrbs = []; vortexes = []; shieldBubbles = []; darkMatterClouds = []; particlesCollected = 0; crystalsCollected = 0; currentDimension = 0; // Reset and start timer timeRemaining = Math.max(8000, timeLimit - (level - 1) * 1500); // More aggressive time reduction timerActive = true; dimensionSwitches = 0; maxDimensionSwitches = Math.max(1, 6 - level); // Fewer switches allowed at higher levels, minimum 1 // Create quantum core if (quantumCore) { quantumCore.destroy(); } quantumCore = game.addChild(LK.getAsset('quantumCore', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 800 })); // Create background star field var numStars = 80 + level * 15; for (var i = 0; i < numStars; i++) { var star = game.addChild(new BackgroundStar()); star.x = Math.random() * 2048; star.y = Math.random() * 2732; star.scaleX = 0.5 + Math.random() * 1.5; star.scaleY = star.scaleX; backgroundStars.push(star); } // Create orbital particles around quantum core for (var i = 0; i < 8; i++) { var orbitalStar = game.addChild(new BackgroundStar()); var angle = i / 8 * Math.PI * 2; var radius = 200 + Math.random() * 100; orbitalStar.x = quantumCore.x + Math.cos(angle) * radius; orbitalStar.y = quantumCore.y + Math.sin(angle) * radius; orbitalStar.scaleX = 1.5; orbitalStar.scaleY = 1.5; orbitalStar.orbitalAngle = angle; orbitalStar.orbitalRadius = radius; orbitalStar.orbitalSpeed = 0.01 + Math.random() * 0.02; backgroundStars.push(orbitalStar); } // Level 1 setup if (level === 1) { // Simple particles in different dimensions var particle1 = game.addChild(new Particle()); particle1.x = 300; particle1.y = 1600; particle1.setDimension(0); particle1.lastCoreIntersecting = false; particles.push(particle1); var particle2 = game.addChild(new Particle()); particle2.x = 1700; particle2.y = 1600; particle2.setDimension(1); particle2.lastCoreIntersecting = false; particles.push(particle2); // Portal to connect dimensions var portal1 = game.addChild(new Portal()); portal1.x = 1024; portal1.y = 1600; portal1.dimension = 0; portal1.targetDimension = 1; portal1.setDimension(0); portals.push(portal1); // Add energy crystals var crystal1 = game.addChild(new EnergyCrystal()); crystal1.x = 500; crystal1.y = 1400; crystal1.setDimension(0); energyCrystals.push(crystal1); var crystal2 = game.addChild(new EnergyCrystal()); crystal2.x = 1500; crystal2.y = 1400; crystal2.setDimension(1); energyCrystals.push(crystal2); // Add power orb var orb1 = game.addChild(new PowerOrb()); orb1.x = 1024; orb1.y = 1200; orb1.setDimension(0); powerOrbs.push(orb1); totalParticles = 2; totalCrystals = 2; } else { // Progressive levels with more complexity var numParticles = Math.min(level + 1, 4); var numFields = Math.min(level, 5); // More interference fields for (var i = 0; i < numParticles; i++) { var particle = game.addChild(new Particle()); particle.x = 200 + i * 400; particle.y = 1800 + i % 2 * 400; particle.setDimension(i % totalDimensions); particle.lastCoreIntersecting = false; particles.push(particle); } // Create entangled pairs for higher levels if (level >= 3 && particles.length >= 2) { particles[0].entangledWith = particles[1]; particles[1].entangledWith = particles[0]; } // Create portals for (var i = 0; i < 2; i++) { var portal = game.addChild(new Portal()); portal.x = 400 + i * 1200; portal.y = 1200; portal.dimension = i; portal.targetDimension = (i + 1) % totalDimensions; portal.setDimension(i); portals.push(portal); } // Create interference fields for (var i = 0; i < numFields; i++) { var field = game.addChild(new InterferenceField()); field.x = 300 + i * 600; field.y = 1000 + i % 2 * 400; field.setDimension(i % totalDimensions); // Add movement to interference fields for higher levels if (level >= 2) { field.moveDirection = i % 2 === 0 ? 1 : -1; field.minX = 100; field.maxX = 1948; } interferenceFields.push(field); } // Add additional moving barriers for higher levels if (level >= 2) { var movingField = game.addChild(new InterferenceField()); movingField.x = 1024; movingField.y = 1400; movingField.setDimension(0); movingField.moveDirection = 1; movingField.minX = 200; movingField.maxX = 1848; interferenceFields.push(movingField); } // Add second moving barrier for level 3+ if (level >= 3) { var movingField2 = game.addChild(new InterferenceField()); movingField2.x = 500; movingField2.y = 2000; movingField2.setDimension(1); movingField2.moveDirection = -1; movingField2.minX = 100; movingField2.maxX = 1948; interferenceFields.push(movingField2); } // Add third moving barrier for level 4+ if (level >= 4) { var movingField3 = game.addChild(new InterferenceField()); movingField3.x = 1500; movingField3.y = 1600; movingField3.setDimension(0); movingField3.moveDirection = 1; movingField3.minX = 300; movingField3.maxX = 1700; interferenceFields.push(movingField3); } // Add fourth moving barrier for level 5+ if (level >= 5) { var movingField4 = game.addChild(new InterferenceField()); movingField4.x = 800; movingField4.y = 1800; movingField4.setDimension(1); movingField4.moveDirection = -1; movingField4.minX = 200; movingField4.maxX = 1800; interferenceFields.push(movingField4); } // Add energy crystals for higher levels var numCrystals = Math.min(level, 4); for (var c = 0; c < numCrystals; c++) { var crystal = game.addChild(new EnergyCrystal()); crystal.x = 400 + c * 400; crystal.y = 1300 + c % 2 * 300; crystal.setDimension(c % totalDimensions); energyCrystals.push(crystal); } totalCrystals = numCrystals; // Add power orbs for levels 3+ if (level >= 3) { var numOrbs = Math.min(level - 2, 3); for (var o = 0; o < numOrbs; o++) { var orb = game.addChild(new PowerOrb()); orb.x = 600 + o * 300; orb.y = 1100 + o % 2 * 200; orb.setDimension(o % totalDimensions); powerOrbs.push(orb); } } // Add vortexes for levels 4+ if (level >= 4) { var numVortexes = Math.min(level - 3, 2); for (var v = 0; v < numVortexes; v++) { var vortex = game.addChild(new Vortex()); vortex.x = 300 + v * 1400; vortex.y = 1500; vortex.setDimension(v % totalDimensions); vortexes.push(vortex); } } // Advanced levels 6-10 with additional challenges if (level >= 6) { // Add more particles for higher levels var extraParticles = Math.min(level - 5, 3); for (var j = 0; j < extraParticles; j++) { var extraParticle = game.addChild(new Particle()); extraParticle.x = 400 + j * 300; extraParticle.y = 2200 + j % 2 * 200; extraParticle.setDimension(j % totalDimensions); extraParticle.lastCoreIntersecting = false; particles.push(extraParticle); } totalParticles += extraParticles; // Add additional moving barriers var numExtraFields = Math.min(level - 5, 4); for (var k = 0; k < numExtraFields; k++) { var extraField = game.addChild(new InterferenceField()); extraField.x = 200 + k * 400; extraField.y = 1300 + k % 2 * 300; extraField.setDimension(k % totalDimensions); extraField.moveDirection = k % 2 === 0 ? 1 : -1; extraField.minX = 100; extraField.maxX = 1948; interferenceFields.push(extraField); } } // Level 8+ gets faster moving barriers if (level >= 8) { for (var m = 0; m < interferenceFields.length; m++) { if (interferenceFields[m].moveDirection !== undefined) { // Increase speed for level 8+ var originalUpdate = interferenceFields[m].update; interferenceFields[m].update = function () { // Handle dimension visibility if (this.dimension === currentDimension) { this.alpha += this.pulseDirection * 0.02; if (this.alpha > 1.0) { this.alpha = 1.0; this.pulseDirection = -1; } else if (this.alpha < 0.3) { this.alpha = 0.3; this.pulseDirection = 1; } } else { this.alpha = 0.2; } // Faster moving interference fields for level 8+ if (this.moveDirection !== undefined) { this.x += this.moveDirection * 6; // Increased speed from 4 to 6 if (this.x <= this.minX || this.x >= this.maxX) { this.moveDirection *= -1; } } }; } } } // Level 10 gets entangled triplets if (level >= 10 && particles.length >= 3) { particles[0].entangledWith = particles[1]; particles[1].entangledWith = particles[2]; particles[2].entangledWith = particles[0]; } totalParticles = numParticles; } updateDimensionDisplay(); levelText.setText('Level: ' + level); } function updateDimensionDisplay() { dimensionText.setText('Dimension: ' + currentDimension); instructionText.setText('Switches: ' + dimensionSwitches + '/' + maxDimensionSwitches); for (var i = 0; i < dimensionIndicators.length; i++) { var indicator = dimensionIndicators[i]; tween(indicator, { alpha: i === currentDimension ? 1.0 : 0.3, scaleX: i === currentDimension ? 1.5 : 1.0, scaleY: i === currentDimension ? 1.5 : 1.0 }, { duration: 300, easing: tween.easeOut }); } // Update all objects for dimension visibility for (var i = 0; i < particles.length; i++) { tween(particles[i], { alpha: particles[i].dimension === currentDimension ? 1.0 : 0.3 }, { duration: 250, easing: tween.easeInOut }); } for (var i = 0; i < portals.length; i++) { tween(portals[i], { alpha: portals[i].dimension === currentDimension ? 1.0 : 0.2 }, { duration: 250, easing: tween.easeInOut }); } for (var i = 0; i < interferenceFields.length; i++) { tween(interferenceFields[i], { alpha: interferenceFields[i].dimension === currentDimension ? 0.8 : 0.2 }, { duration: 250, easing: tween.easeInOut }); } } function switchDimension() { if (dimensionSwitches >= maxDimensionSwitches) { LK.effects.flashScreen(0xFF0000, 200); return; // No more switches allowed } dimensionSwitches++; timeRemaining -= 2000; // Penalty: lose 2 seconds per switch currentDimension = (currentDimension + 1) % totalDimensions; updateDimensionDisplay(); LK.getSound('dimensionShift').play(); LK.effects.flashScreen(0x440088, 200); } function checkWinCondition() { if (particlesCollected >= totalParticles) { timerActive = false; // Stop timer when level complete level++; LK.setTimeout(function () { if (level > 10) { LK.showYouWin(); } else { initializeLevel(); } }, 1000); } } function resetLevel() { LK.effects.flashScreen(0xff0000, 500); LK.setTimeout(function () { initializeLevel(); }, 600); } // Event handlers game.down = function (x, y, obj) { var hitParticle = false; for (var i = 0; i < particles.length; i++) { var particle = particles[i]; if (particle.dimension === currentDimension && !particle.isCollected) { var dx = x - particle.x; var dy = y - particle.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < 80) { draggedParticle = particle; particle.startDrag(); dragOffset.x = x - particle.x; dragOffset.y = y - particle.y; hitParticle = true; break; } } } if (!hitParticle) { switchDimension(); } }; game.move = function (x, y, obj) { if (draggedParticle && !draggedParticle.isCollected) { var targetX = x - dragOffset.x; var targetY = y - dragOffset.y; // Keep particle within bounds targetX = Math.max(80, Math.min(1968, targetX)); targetY = Math.max(80, Math.min(2652, targetY)); // Direct position update for responsive dragging draggedParticle.x = targetX; draggedParticle.y = targetY; // Reduce trail effect frequency to improve performance if (LK.ticks % 10 === 0) { var trailStar = game.addChild(new BackgroundStar()); trailStar.x = draggedParticle.x + (Math.random() - 0.5) * 20; trailStar.y = draggedParticle.y + (Math.random() - 0.5) * 20; trailStar.scaleX = 0.8; trailStar.scaleY = 0.8; trailStar.alpha = 0.8; // Fade out trail particle tween(trailStar, { alpha: 0, scaleX: 0.1, scaleY: 0.1 }, { duration: 1000, easing: tween.easeOut, onFinish: function onFinish() { trailStar.destroy(); } }); } // Handle entangled particle movement with direct updates if (draggedParticle.entangledWith) { draggedParticle.entangledWith.x = targetX + 150; draggedParticle.entangledWith.y = targetY; } } }; game.up = function (x, y, obj) { if (draggedParticle) { draggedParticle.stopDrag(); draggedParticle = null; } }; game.update = function () { // Handle timer countdown if (timerActive) { timeRemaining -= 16.67; // Approximately 1/60th second if (timeRemaining <= 0) { resetLevel(); return; } var seconds = Math.ceil(timeRemaining / 1000); timerText.setText('Time: ' + seconds + 's'); // Smooth color transitions when time is running out if (seconds <= 5) { tween(timerText, { tint: 0xFF0000 }, { duration: 200, easing: tween.easeOut }); } else if (seconds <= 10) { tween(timerText, { tint: 0xFFFF00 }, { duration: 200, easing: tween.easeOut }); } else { tween(timerText, { tint: 0xFFFFFF }, { duration: 200, easing: tween.easeOut }); } } // Animate quantum core with direct property updates if (quantumCore) { // Direct rotation update quantumCore.rotation += 0.02; // Direct pulsing animation var pulse = Math.sin(LK.ticks * 0.08) * 0.15 + 1.0; quantumCore.scaleX = pulse; quantumCore.scaleY = pulse; // Reduced frequency color cycling if (LK.ticks % 60 === 0) { var colorPhase = LK.ticks * 0.015; var r = Math.sin(colorPhase) * 0.4 + 0.6; var g = Math.sin(colorPhase + 2) * 0.4 + 0.6; var b = Math.sin(colorPhase + 4) * 0.4 + 0.6; var color = Math.floor(r * 255) << 16 | Math.floor(g * 255) << 8 | Math.floor(b * 255); quantumCore.tint = color; } } // Update all particles for (var i = 0; i < particles.length; i++) { if (particles[i].update) { particles[i].update(); } } // Update all portals for (var i = 0; i < portals.length; i++) { if (portals[i].update) { portals[i].update(); } } // Update all interference fields for (var i = 0; i < interferenceFields.length; i++) { if (interferenceFields[i].update) { interferenceFields[i].update(); } } // Update all energy crystals for (var i = 0; i < energyCrystals.length; i++) { if (energyCrystals[i].update) { energyCrystals[i].update(); } // Check collection if (energyCrystals[i].dimension === currentDimension && !energyCrystals[i].isCollected) { for (var j = 0; j < particles.length; j++) { if (particles[j].dimension === currentDimension && energyCrystals[i].intersects(particles[j])) { energyCrystals[i].collect(); crystalsCollected++; break; } } } } // Update all power orbs for (var i = 0; i < powerOrbs.length; i++) { if (powerOrbs[i].update) { powerOrbs[i].update(); } // Check collection if (powerOrbs[i].dimension === currentDimension && !powerOrbs[i].isCollected) { for (var j = 0; j < particles.length; j++) { if (particles[j].dimension === currentDimension && powerOrbs[i].intersects(particles[j])) { powerOrbs[i].collect(); break; } } } } // Update all vortexes for (var i = 0; i < vortexes.length; i++) { if (vortexes[i].update) { vortexes[i].update(); } } // Update background stars for (var i = 0; i < backgroundStars.length; i++) { var star = backgroundStars[i]; if (star.update) { star.update(); } // Handle orbital motion for core particles if (star.orbitalAngle !== undefined && quantumCore) { star.orbitalAngle += star.orbitalSpeed; star.x = quantumCore.x + Math.cos(star.orbitalAngle) * star.orbitalRadius; star.y = quantumCore.y + Math.sin(star.orbitalAngle) * star.orbitalRadius; } } }; // Initialize first level initializeLevel();
===================================================================
--- original.js
+++ change.js
@@ -24,8 +24,61 @@
self.y += Math.cos(LK.ticks * 0.008 + self.twinkleOffset) * 0.015;
};
return self;
});
+var EnergyCrystal = Container.expand(function () {
+ var self = Container.call(this);
+ var crystalGraphics = self.attachAsset('energyCrystal', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.dimension = 0;
+ self.isCollected = false;
+ self.pulsePhase = Math.random() * Math.PI * 2;
+ self.setDimension = function (dim) {
+ self.dimension = dim;
+ self.alpha = 1.0;
+ };
+ self.collect = function () {
+ self.isCollected = true;
+ LK.getSound('crystalSound').play();
+ // Spinning collection animation
+ tween(crystalGraphics, {
+ rotation: crystalGraphics.rotation + Math.PI * 4
+ }, {
+ duration: 800,
+ easing: tween.easeOut
+ });
+ tween(self, {
+ scaleX: 2.0,
+ scaleY: 2.0,
+ alpha: 0
+ }, {
+ duration: 800,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ self.visible = false;
+ }
+ });
+ };
+ self.update = function () {
+ if (self.isCollected) return;
+ // Pulsing glow effect
+ self.pulsePhase += 0.1;
+ var pulse = Math.sin(self.pulsePhase) * 0.3 + 0.7;
+ crystalGraphics.alpha = pulse;
+ // Floating motion
+ crystalGraphics.y += Math.sin(self.pulsePhase * 0.5) * 0.5;
+ crystalGraphics.rotation += 0.03;
+ // Visibility based on dimension
+ if (self.dimension === currentDimension) {
+ self.alpha = 1.0;
+ } else {
+ self.alpha = 0.3;
+ }
+ };
+ return self;
+});
var InterferenceField = Container.expand(function () {
var self = Container.call(this);
var fieldGraphics = self.attachAsset('interferenceField', {
anchorX: 0.5,
@@ -176,8 +229,103 @@
}
};
return self;
});
+var PowerOrb = Container.expand(function () {
+ var self = Container.call(this);
+ var orbGraphics = self.attachAsset('powerOrb', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.dimension = 0;
+ self.isCollected = false;
+ self.energyPhase = Math.random() * Math.PI * 2;
+ self.setDimension = function (dim) {
+ self.dimension = dim;
+ self.alpha = 1.0;
+ };
+ self.collect = function () {
+ self.isCollected = true;
+ LK.getSound('powerUpSound').play();
+ // Burst effect
+ tween(self, {
+ scaleX: 3.0,
+ scaleY: 3.0,
+ alpha: 0
+ }, {
+ duration: 600,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ self.visible = false;
+ }
+ });
+ // Add time bonus
+ timeRemaining += 5000; // 5 seconds bonus
+ LK.effects.flashScreen(0xffff00, 300);
+ };
+ self.update = function () {
+ if (self.isCollected) return;
+ // Energy crackling effect
+ self.energyPhase += 0.15;
+ var energy = Math.sin(self.energyPhase) * 0.5 + 0.5;
+ orbGraphics.scaleX = 0.8 + energy * 0.4;
+ orbGraphics.scaleY = 0.8 + energy * 0.4;
+ orbGraphics.rotation += 0.05;
+ // Visibility based on dimension
+ if (self.dimension === currentDimension) {
+ self.alpha = 1.0;
+ } else {
+ self.alpha = 0.3;
+ }
+ };
+ return self;
+});
+var Vortex = Container.expand(function () {
+ var self = Container.call(this);
+ var vortexGraphics = self.attachAsset('vortex', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.dimension = 0;
+ self.isActive = true;
+ self.rotationSpeed = 0.08;
+ self.setDimension = function (dim) {
+ self.dimension = dim;
+ self.alpha = 0.6;
+ };
+ self.update = function () {
+ if (!self.isActive) return;
+ // Swirling vortex animation
+ vortexGraphics.rotation += self.rotationSpeed;
+ // Pulsing size effect
+ var pulse = Math.sin(LK.ticks * 0.06) * 0.2 + 0.8;
+ vortexGraphics.scaleX = pulse;
+ vortexGraphics.scaleY = pulse;
+ // Visibility based on dimension
+ if (self.dimension === currentDimension) {
+ self.alpha = 0.6;
+ } else {
+ self.alpha = 0.1;
+ }
+ // Attract nearby particles
+ if (self.dimension === currentDimension) {
+ for (var i = 0; i < particles.length; i++) {
+ var particle = particles[i];
+ if (particle.dimension === self.dimension && !particle.isBeingDragged) {
+ var dx = self.x - particle.x;
+ var dy = self.y - particle.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance < 300 && distance > 100) {
+ var force = 0.5;
+ particle.x += dx * force / distance;
+ particle.y += dy * force / distance;
+ }
+ }
+ }
+ }
+ };
+ return self;
+});
/****
* Initialize Game
****/
@@ -192,8 +340,13 @@
var totalDimensions = 2;
var particles = [];
var portals = [];
var interferenceFields = [];
+var energyCrystals = [];
+var powerOrbs = [];
+var vortexes = [];
+var shieldBubbles = [];
+var darkMatterClouds = [];
var quantumCore;
var draggedParticle = null;
var dragOffset = {
x: 0,
@@ -207,8 +360,10 @@
var timerActive = false;
var dimensionSwitches = 0;
var maxDimensionSwitches = 5;
var backgroundStars = [];
+var crystalsCollected = 0;
+var totalCrystals = 0;
// UI Elements
var dimensionText = new Text2('Dimension: 0', {
size: 60,
fill: 0xFFFFFF
@@ -260,13 +415,34 @@
}
for (var i = 0; i < backgroundStars.length; i++) {
backgroundStars[i].destroy();
}
+ for (var i = 0; i < energyCrystals.length; i++) {
+ energyCrystals[i].destroy();
+ }
+ for (var i = 0; i < powerOrbs.length; i++) {
+ powerOrbs[i].destroy();
+ }
+ for (var i = 0; i < vortexes.length; i++) {
+ vortexes[i].destroy();
+ }
+ for (var i = 0; i < shieldBubbles.length; i++) {
+ shieldBubbles[i].destroy();
+ }
+ for (var i = 0; i < darkMatterClouds.length; i++) {
+ darkMatterClouds[i].destroy();
+ }
backgroundStars = [];
particles = [];
portals = [];
interferenceFields = [];
+ energyCrystals = [];
+ powerOrbs = [];
+ vortexes = [];
+ shieldBubbles = [];
+ darkMatterClouds = [];
particlesCollected = 0;
+ crystalsCollected = 0;
currentDimension = 0;
// Reset and start timer
timeRemaining = Math.max(8000, timeLimit - (level - 1) * 1500); // More aggressive time reduction
timerActive = true;
@@ -328,9 +504,27 @@
portal1.dimension = 0;
portal1.targetDimension = 1;
portal1.setDimension(0);
portals.push(portal1);
+ // Add energy crystals
+ var crystal1 = game.addChild(new EnergyCrystal());
+ crystal1.x = 500;
+ crystal1.y = 1400;
+ crystal1.setDimension(0);
+ energyCrystals.push(crystal1);
+ var crystal2 = game.addChild(new EnergyCrystal());
+ crystal2.x = 1500;
+ crystal2.y = 1400;
+ crystal2.setDimension(1);
+ energyCrystals.push(crystal2);
+ // Add power orb
+ var orb1 = game.addChild(new PowerOrb());
+ orb1.x = 1024;
+ orb1.y = 1200;
+ orb1.setDimension(0);
+ powerOrbs.push(orb1);
totalParticles = 2;
+ totalCrystals = 2;
} else {
// Progressive levels with more complexity
var numParticles = Math.min(level + 1, 4);
var numFields = Math.min(level, 5); // More interference fields
@@ -414,8 +608,40 @@
movingField4.minX = 200;
movingField4.maxX = 1800;
interferenceFields.push(movingField4);
}
+ // Add energy crystals for higher levels
+ var numCrystals = Math.min(level, 4);
+ for (var c = 0; c < numCrystals; c++) {
+ var crystal = game.addChild(new EnergyCrystal());
+ crystal.x = 400 + c * 400;
+ crystal.y = 1300 + c % 2 * 300;
+ crystal.setDimension(c % totalDimensions);
+ energyCrystals.push(crystal);
+ }
+ totalCrystals = numCrystals;
+ // Add power orbs for levels 3+
+ if (level >= 3) {
+ var numOrbs = Math.min(level - 2, 3);
+ for (var o = 0; o < numOrbs; o++) {
+ var orb = game.addChild(new PowerOrb());
+ orb.x = 600 + o * 300;
+ orb.y = 1100 + o % 2 * 200;
+ orb.setDimension(o % totalDimensions);
+ powerOrbs.push(orb);
+ }
+ }
+ // Add vortexes for levels 4+
+ if (level >= 4) {
+ var numVortexes = Math.min(level - 3, 2);
+ for (var v = 0; v < numVortexes; v++) {
+ var vortex = game.addChild(new Vortex());
+ vortex.x = 300 + v * 1400;
+ vortex.y = 1500;
+ vortex.setDimension(v % totalDimensions);
+ vortexes.push(vortex);
+ }
+ }
// Advanced levels 6-10 with additional challenges
if (level >= 6) {
// Add more particles for higher levels
var extraParticles = Math.min(level - 5, 3);
@@ -690,8 +916,45 @@
if (interferenceFields[i].update) {
interferenceFields[i].update();
}
}
+ // Update all energy crystals
+ for (var i = 0; i < energyCrystals.length; i++) {
+ if (energyCrystals[i].update) {
+ energyCrystals[i].update();
+ }
+ // Check collection
+ if (energyCrystals[i].dimension === currentDimension && !energyCrystals[i].isCollected) {
+ for (var j = 0; j < particles.length; j++) {
+ if (particles[j].dimension === currentDimension && energyCrystals[i].intersects(particles[j])) {
+ energyCrystals[i].collect();
+ crystalsCollected++;
+ break;
+ }
+ }
+ }
+ }
+ // Update all power orbs
+ for (var i = 0; i < powerOrbs.length; i++) {
+ if (powerOrbs[i].update) {
+ powerOrbs[i].update();
+ }
+ // Check collection
+ if (powerOrbs[i].dimension === currentDimension && !powerOrbs[i].isCollected) {
+ for (var j = 0; j < particles.length; j++) {
+ if (particles[j].dimension === currentDimension && powerOrbs[i].intersects(particles[j])) {
+ powerOrbs[i].collect();
+ break;
+ }
+ }
+ }
+ }
+ // Update all vortexes
+ for (var i = 0; i < vortexes.length; i++) {
+ if (vortexes[i].update) {
+ vortexes[i].update();
+ }
+ }
// Update background stars
for (var i = 0; i < backgroundStars.length; i++) {
var star = backgroundStars[i];
if (star.update) {