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 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 () {
// Handle dimension visibility
if (self.dimension === currentDimension) {
self.alpha += self.pulseDirection * 0.02;
if (self.alpha > 1.0) {
self.alpha = 1.0;
self.pulseDirection = -1;
} else if (self.alpha < 0.3) {
self.alpha = 0.3;
self.pulseDirection = 1;
}
} else {
self.alpha = 0.2;
}
// Moving interference fields
if (self.moveDirection !== undefined) {
self.x += self.moveDirection * 2;
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;
tween(self, {
alpha: 0,
scaleX: 0.1,
scaleY: 0.1
}, {
duration: 300,
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 () {
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;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000033
});
/****
* Game Code
****/
var currentDimension = 0;
var totalDimensions = 2;
var particles = [];
var portals = [];
var interferenceFields = [];
var quantumCore;
var draggedParticle = null;
var dragOffset = {
x: 0,
y: 0
};
var particlesCollected = 0;
var totalParticles = 0;
var level = 1;
var timeLimit = 15000; // 15 seconds in milliseconds
var timeRemaining = timeLimit;
var timerActive = false;
var dimensionSwitches = 0;
var maxDimensionSwitches = 10;
// 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: 15s', {
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();
}
particles = [];
portals = [];
interferenceFields = [];
particlesCollected = 0;
currentDimension = 0;
// Reset and start timer
timeRemaining = Math.max(10000, timeLimit - (level - 1) * 2000); // Decrease time each level
timerActive = true;
dimensionSwitches = 0;
maxDimensionSwitches = Math.max(3, 10 - level); // Fewer switches allowed at higher levels
// Create quantum core
if (quantumCore) {
quantumCore.destroy();
}
quantumCore = game.addChild(LK.getAsset('quantumCore', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 400
}));
// Level 1 setup
if (level === 1) {
// Simple particles in different dimensions
var particle1 = game.addChild(new Particle());
particle1.x = 300;
particle1.y = 1000;
particle1.setDimension(0);
particle1.lastCoreIntersecting = false;
particles.push(particle1);
var particle2 = game.addChild(new Particle());
particle2.x = 1700;
particle2.y = 1000;
particle2.setDimension(1);
particle2.lastCoreIntersecting = false;
particles.push(particle2);
// Portal to connect dimensions
var portal1 = game.addChild(new Portal());
portal1.x = 1024;
portal1.y = 1000;
portal1.dimension = 0;
portal1.targetDimension = 1;
portal1.setDimension(0);
portals.push(portal1);
totalParticles = 2;
} else {
// Progressive levels with more complexity
var numParticles = Math.min(level + 1, 4);
var numFields = Math.min(level - 1, 3);
for (var i = 0; i < numParticles; i++) {
var particle = game.addChild(new Particle());
particle.x = 200 + i * 300;
particle.y = 1200 + i % 2 * 300;
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 = 500 + i * 1000;
portal.y = 800;
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 = 400 + i * 400;
field.y = 600 + i % 2 * 200;
field.setDimension(i % totalDimensions);
// Add movement to interference fields for higher levels
if (level >= 2) {
field.moveDirection = i % 2 === 0 ? 1 : -1;
field.minX = 200;
field.maxX = 1800;
}
interferenceFields.push(field);
}
// Add additional moving barriers for higher levels
if (level >= 3) {
var movingField = game.addChild(new InterferenceField());
movingField.x = 1024;
movingField.y = 1000;
movingField.setDimension(0);
movingField.moveDirection = 1;
movingField.minX = 300;
movingField.maxX = 1700;
interferenceFields.push(movingField);
}
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];
indicator.alpha = i === currentDimension ? 1.0 : 0.3;
indicator.scaleX = i === currentDimension ? 1.5 : 1.0;
indicator.scaleY = i === currentDimension ? 1.5 : 1.0;
}
// Update all objects for dimension visibility
for (var i = 0; i < particles.length; i++) {
particles[i].alpha = particles[i].dimension === currentDimension ? 1.0 : 0.3;
}
for (var i = 0; i < portals.length; i++) {
portals[i].alpha = portals[i].dimension === currentDimension ? 1.0 : 0.2;
}
for (var i = 0; i < interferenceFields.length; i++) {
interferenceFields[i].alpha = interferenceFields[i].dimension === currentDimension ? 0.8 : 0.2;
}
}
function switchDimension() {
if (dimensionSwitches >= maxDimensionSwitches) {
LK.effects.flashScreen(0xFF0000, 200);
return; // No more switches allowed
}
dimensionSwitches++;
timeRemaining -= 1000; // Penalty: lose 1 second 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 > 5) {
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 < 50) {
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) {
draggedParticle.x = x - dragOffset.x;
draggedParticle.y = y - dragOffset.y;
// Keep particle within bounds
draggedParticle.x = Math.max(50, Math.min(1998, draggedParticle.x));
draggedParticle.y = Math.max(50, Math.min(2682, draggedParticle.y));
// Handle entangled particle movement
if (draggedParticle.entangledWith) {
draggedParticle.entangledWith.x = draggedParticle.x + 150;
draggedParticle.entangledWith.y = draggedParticle.y;
}
}
};
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');
// Change color when time is running out
if (seconds <= 5) {
timerText.fill = 0xFF0000;
} else if (seconds <= 10) {
timerText.fill = 0xFFFF00;
} else {
timerText.fill = 0xFFFFFF;
}
}
// Animate quantum core
if (quantumCore) {
quantumCore.rotation += 0.01;
var pulse = Math.sin(LK.ticks * 0.1) * 0.2 + 1.0;
quantumCore.scaleX = pulse;
quantumCore.scaleY = pulse;
}
// 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();
}
}
};
// Initialize first level
initializeLevel(); ===================================================================
--- original.js
+++ change.js
@@ -31,8 +31,15 @@
}
} else {
self.alpha = 0.2;
}
+ // Moving interference fields
+ if (self.moveDirection !== undefined) {
+ self.x += self.moveDirection * 2;
+ if (self.x <= self.minX || self.x >= self.maxX) {
+ self.moveDirection *= -1;
+ }
+ }
};
return self;
});
var Particle = Container.expand(function () {
@@ -168,8 +175,13 @@
};
var particlesCollected = 0;
var totalParticles = 0;
var level = 1;
+var timeLimit = 15000; // 15 seconds in milliseconds
+var timeRemaining = timeLimit;
+var timerActive = false;
+var dimensionSwitches = 0;
+var maxDimensionSwitches = 10;
// UI Elements
var dimensionText = new Text2('Dimension: 0', {
size: 60,
fill: 0xFFFFFF
@@ -188,8 +200,15 @@
fill: 0xCCCCCC
});
instructionText.anchor.set(0.5, 1);
LK.gui.bottom.addChild(instructionText);
+var timerText = new Text2('Time: 15s', {
+ 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', {
@@ -216,8 +235,13 @@
portals = [];
interferenceFields = [];
particlesCollected = 0;
currentDimension = 0;
+ // Reset and start timer
+ timeRemaining = Math.max(10000, timeLimit - (level - 1) * 2000); // Decrease time each level
+ timerActive = true;
+ dimensionSwitches = 0;
+ maxDimensionSwitches = Math.max(3, 10 - level); // Fewer switches allowed at higher levels
// Create quantum core
if (quantumCore) {
quantumCore.destroy();
}
@@ -281,19 +305,37 @@
// Create interference fields
for (var i = 0; i < numFields; i++) {
var field = game.addChild(new InterferenceField());
field.x = 400 + i * 400;
- field.y = 600;
+ field.y = 600 + i % 2 * 200;
field.setDimension(i % totalDimensions);
+ // Add movement to interference fields for higher levels
+ if (level >= 2) {
+ field.moveDirection = i % 2 === 0 ? 1 : -1;
+ field.minX = 200;
+ field.maxX = 1800;
+ }
interferenceFields.push(field);
}
+ // Add additional moving barriers for higher levels
+ if (level >= 3) {
+ var movingField = game.addChild(new InterferenceField());
+ movingField.x = 1024;
+ movingField.y = 1000;
+ movingField.setDimension(0);
+ movingField.moveDirection = 1;
+ movingField.minX = 300;
+ movingField.maxX = 1700;
+ interferenceFields.push(movingField);
+ }
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];
indicator.alpha = i === currentDimension ? 1.0 : 0.3;
indicator.scaleX = i === currentDimension ? 1.5 : 1.0;
@@ -310,15 +352,22 @@
interferenceFields[i].alpha = interferenceFields[i].dimension === currentDimension ? 0.8 : 0.2;
}
}
function switchDimension() {
+ if (dimensionSwitches >= maxDimensionSwitches) {
+ LK.effects.flashScreen(0xFF0000, 200);
+ return; // No more switches allowed
+ }
+ dimensionSwitches++;
+ timeRemaining -= 1000; // Penalty: lose 1 second 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 > 5) {
LK.showYouWin();
@@ -377,8 +426,26 @@
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');
+ // Change color when time is running out
+ if (seconds <= 5) {
+ timerText.fill = 0xFF0000;
+ } else if (seconds <= 10) {
+ timerText.fill = 0xFFFF00;
+ } else {
+ timerText.fill = 0xFFFFFF;
+ }
+ }
// Animate quantum core
if (quantumCore) {
quantumCore.rotation += 0.01;
var pulse = Math.sin(LK.ticks * 0.1) * 0.2 + 1.0;