User prompt
Space ship no se ve en ningún lado, parece no ejecutarse bien, no aparece en el centro,
User prompt
Crea un objeto llamado spaceship con el sistema de arrastre, que inicie en el sistema mas cercano al medio de la patalla. Agregale un rango de movimiento
User prompt
Hay unas líneas de codigo que hace que los sistemas cambien de color entre ellos y rompe el cambio suave de color
User prompt
Haz que los colores de los planetas sean rojo para pequeño, azul para grandes y amarillos para mediano. Que no cambien de color entre esos, solo cambien en variaciones de su color entre 3 y en bucle suavemente ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Arregla la animación de cambio de color ponlo en bucle y haz más suave los colores que cambia ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Haz que la variación de tamaño sea random. Siempre son amarillas y no debería ser así, la aleatoriedad no está bien aplicada con a semilla
User prompt
Arregla el sistema de cambiar de color y tamaño con variación andom según la semilla
Code edit (2 edits merged)
Please save this source code
User prompt
Integra las semillas random en la generación. La semilla es siempre la misma pero las ubicaciones d ellas estrellas no
User prompt
Agrega un texto en la parte superior para ver la semilla actual
Code edit (2 edits merged)
Please save this source code
User prompt
Agrega unión. Este es una linea que conectan las estrellas más cercanas entre ellas dentro de un rango.
User prompt
Mejora la generación de estrellas haciéndolos más natural y variados, con límites minimo de diferencias entre sí
User prompt
Agrega universe limiter con el asset área para tener una bici n de hasta donde llega el universo. Dale una animación de rotación en bucle lineal ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Crea un sistema de arrastre de pantalla, así navegar por el universo. Al mover desde arriba hacia abajo las estrellas irán para abajo. Así par cada dirección
User prompt
Mejora el sistema de espaciado entre planetas, agrega un mínimo entre la distancia permitida entre planetas (con el fin de evitar que estén muy cercas)
Code edit (1 edits merged)
Please save this source code
User prompt
Agruega un área límite de creación de estrellas en un rango circular de 4000 px
User prompt
Hagamos que las estrellas se creen aleatoriamente en un rango entre 5 a 8 con un mínimo de distancia con respecto a otros (600px)
User prompt
Agrega una seccion llamada "inicialización de objetos" así ordenar la posición que se mostrarán los objetos con respecto a otros
User prompt
Haz que la animación bump sea en bucle y suave en una velocidad lineal ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Agruega una animación bump suave a las estrellas ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Agruega hasta 5 variantes de tonos para cada estrella y dale una animación donde cambian suavemente de color en una pequeña variación de su tono original ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Agruegemos aleatoriedad al diseño de la estrella. Agruegemos tamaño entre 0.7 a 1.3 clasificados como pequeñas, medianas y grandes. Asignarles colores rojos, amarillos y azules correspondiente a su tamaño como en la vida real ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Crea un objeto llama Star con el asset solar sistema, ajusta su posición al centro del juego
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Connection = Container.expand(function () {
var self = Container.call(this);
// Create line graphics using shape asset
var lineGraphics = self.attachAsset('line', {
anchorX: 0,
anchorY: 0.5
});
// Set line properties
lineGraphics.height = 2; // Thin line
lineGraphics.alpha = 0.3; // Semi-transparent
lineGraphics.tint = 0x4444ff; // Blue color for connections
self.lineGraphics = lineGraphics;
// Method to update line between two points
self.updateLine = function (x1, y1, x2, y2) {
var distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
var angle = Math.atan2(y2 - y1, x2 - x1);
// Position line at start point
self.x = x1;
self.y = y1;
// Set line length and rotation
self.lineGraphics.width = distance;
self.rotation = angle;
};
return self;
});
var Spaceship = Container.expand(function () {
var self = Container.call(this);
var spaceshipGraphics = self.attachAsset('spaceShip', {
anchorX: 0.5,
anchorY: 0.5
});
// Scale the spaceship to appropriate size
spaceshipGraphics.scaleX = 1.5;
spaceshipGraphics.scaleY = 1.5;
self.spaceshipGraphics = spaceshipGraphics;
// Movement range limit
self.movementRange = 500; // pixels
self.originX = 0;
self.originY = 0;
// Set origin position for movement range calculation
self.setOrigin = function (x, y) {
self.originX = x;
self.originY = y;
};
// Check if position is within movement range
self.isWithinRange = function (x, y) {
var distance = Math.sqrt(Math.pow(x - self.originX, 2) + Math.pow(y - self.originY, 2));
return distance <= self.movementRange;
};
// Limit position to movement range
self.limitPosition = function (x, y) {
var distance = Math.sqrt(Math.pow(x - self.originX, 2) + Math.pow(y - self.originY, 2));
if (distance > self.movementRange) {
var angle = Math.atan2(y - self.originY, x - self.originX);
return {
x: self.originX + Math.cos(angle) * self.movementRange,
y: self.originY + Math.sin(angle) * self.movementRange
};
}
return {
x: x,
y: y
};
};
return self;
});
var Star = Container.expand(function () {
var self = Container.call(this);
var starGraphics = self.attachAsset('solarSystem', {
anchorX: 0.5,
anchorY: 0.5
});
// Use seeded random for scale and color
// If seededRandom is available, use it, otherwise fallback to Math.random
var randFunc = typeof seededRandom === "function" ? seededRandom : Math.random;
// Generate scale using seeded random (for fallback, will be overwritten in star creation loop)
var scale = 0.7 + randFunc() * 0.6;
starGraphics.scaleX = scale;
starGraphics.scaleY = scale;
// Assign color based on size with 3 main color groups and smooth variations
var colorVariations;
if (scale <= 0.9) {
// Small planets - red variations
colorVariations = [0xff3a2a,
// vivid red
0xff5c4d,
// soft red
0xff7a6a,
// pale red
0xff4a2a,
// deep red
0xff6a3a // muted red
];
} else if (scale <= 1.1) {
// Medium planets - yellow variations
colorVariations = [0xffe066,
// bright yellow
0xffd700,
// gold
0xfff380,
// pale yellow
0xffe94d,
// sun yellow
0xfff7a1 // soft yellow
];
} else {
// Large planets - blue variations
colorVariations = [0x3a6aff,
// vivid blue
0x4d8cff,
// soft blue
0x6aaaff,
// pale blue
0x2a4aff,
// deep blue
0x3a6aff // muted blue
];
}
// Set initial color using seededRandom if available, fallback to Math.random
var currentColorIndex = Math.floor(randFunc() * colorVariations.length);
starGraphics.tint = colorVariations[currentColorIndex];
// Store color data for animation
self.colorVariations = colorVariations;
self.currentColorIndex = currentColorIndex;
self.starGraphics = starGraphics;
// Start color animation with smoother transitions
self.animateColor = function () {
var nextColorIndex = (self.currentColorIndex + 1) % self.colorVariations.length;
tween(self.starGraphics, {
tint: self.colorVariations[nextColorIndex]
}, {
duration: 3000 + randFunc() * 2000,
// Longer, smoother transitions
easing: tween.easeInOut,
onFinish: function onFinish() {
self.currentColorIndex = nextColorIndex;
// Restart animation loop immediately for seamless cycling
self.animateColor();
}
});
};
// Bump animation: smoothly scale up and then back to original in continuous loop
self.bump = function () {
// Cancel any ongoing scale tweens
tween.stop(self.starGraphics, {
scaleX: true,
scaleY: true
});
var originalScaleX = self.starGraphics.scaleX;
var originalScaleY = self.starGraphics.scaleY;
// Scale up
tween(self.starGraphics, {
scaleX: originalScaleX * 1.15,
scaleY: originalScaleY * 1.15
}, {
duration: 1000,
easing: tween.linear,
onFinish: function onFinish() {
// Scale back down
tween(self.starGraphics, {
scaleX: originalScaleX,
scaleY: originalScaleY
}, {
duration: 1000,
easing: tween.linear,
onFinish: function onFinish() {
// Loop the animation by calling bump again
self.bump();
}
});
}
});
};
// Start the animation
self.animateColor();
// Optionally, trigger bump on creation for a lively effect
self.bump();
return self;
});
/****
* Initialize Game
****/
// Create star object and position at center
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Camera position for navigation
var cameraX = 0;
var cameraY = 0;
var isDragging = false;
var lastDragX = 0;
var lastDragY = 0;
/****
* Inicialización de objetos
****/
// Define the current seed (could be random or fixed for now)
var currentSeed = 99999999; // Cambia este valor para probar diferentes semillas
function makeSeededRandom(seed) {
var m = 0x80000000; // 2**31
var a = 1103515245;
var c = 12345;
var state = seed ? seed : Math.floor(Math.random() * (m - 1));
return function () {
state = (a * state + c) % m;
return state / (m - 1);
};
// Find the star closest to screen center and create spaceship there
function findClosestStarToCenter() {
var screenCenterX = 2048 / 2;
var screenCenterY = 2732 / 2;
var closestStar = null;
var closestDistance = Infinity;
for (var i = 0; i < stars.length; i++) {
var star = stars[i];
var distance = Math.sqrt(Math.pow(star.x - screenCenterX, 2) + Math.pow(star.y - screenCenterY, 2));
if (distance < closestDistance) {
closestDistance = distance;
closestStar = star;
}
}
return closestStar;
}
// Create spaceship at closest star to center
var closestStar = findClosestStarToCenter();
if (closestStar) {
spaceship = game.addChild(new Spaceship());
spaceship.x = closestStar.x;
spaceship.y = closestStar.y;
spaceship.setOrigin(closestStar.x, closestStar.y);
}
;
}
// Mostrar la semilla actual en la parte superior central
var seedText = new Text2("Semilla: " + currentSeed, {
size: 70,
fill: 0xFFFFFF
});
seedText.anchor.set(0.5, 0); // Centrado arriba
LK.gui.top.addChild(seedText);
// Array to store all stars
var stars = [];
// Array to store connections between stars
var connections = [];
// Spaceship instance
var spaceship = null;
// Create seeded random generator for this session
var seededRandom = makeSeededRandom(currentSeed);
// Generate random number of stars between 60 and 104 using seeded random
var numStars = 60 + Math.floor(seededRandom() * 45);
// Function to check if position is valid with size-based minimum distance
function isValidPosition(x, y, newStarScale) {
// Check distance from all existing stars
for (var i = 0; i < stars.length; i++) {
var star = stars[i];
var distance = Math.sqrt(Math.pow(x - star.x, 2) + Math.pow(y - star.y, 2));
// Calculate dynamic minimum distance based on both stars' sizes
var existingStarSize = (star.starGraphics ? star.starGraphics.width * star.starGraphics.scaleX : 100) / 2;
var newStarSize = 100 * newStarScale / 2; // Assuming base star size is 100px
// Minimum distance varies based on star sizes: larger stars need more space
var baseDist = 300; // Base minimum distance
var sizeFactor = (existingStarSize + newStarSize) * 2; // Additional space based on combined sizes
var requiredDistance = baseDist + sizeFactor;
if (distance < requiredDistance) {
return false;
}
}
return true;
}
// Function to create connections between nearby stars
function createConnections() {
// Clear existing connections
for (var i = 0; i < connections.length; i++) {
connections[i].destroy();
}
connections = [];
var connectionRange = 800; // Maximum distance for connections
// Check each star against every other star
for (var i = 0; i < stars.length; i++) {
var star1 = stars[i];
for (var j = i + 1; j < stars.length; j++) {
var star2 = stars[j];
// Calculate distance between stars
var distance = Math.sqrt(Math.pow(star2.x - star1.x, 2) + Math.pow(star2.y - star1.y, 2));
// Create connection if within range
if (distance <= connectionRange) {
var connection = game.addChild(new Connection());
connection.updateLine(star1.x, star1.y, star2.x, star2.y);
connections.push(connection);
}
}
// Create connections between nearby stars after all stars are generated
createConnections();
}
}
// Drag navigation system
var dragMode = 'camera'; // 'camera' or 'spaceship'
var spaceshipDrag = false;
game.down = function (x, y, obj) {
// Check if clicking on spaceship
if (spaceship && spaceship.intersects({
x: x,
y: y,
width: 1,
height: 1
})) {
dragMode = 'spaceship';
spaceshipDrag = true;
} else {
dragMode = 'camera';
isDragging = true;
}
lastDragX = x;
lastDragY = y;
};
game.move = function (x, y, obj) {
if (dragMode === 'spaceship' && spaceshipDrag && spaceship) {
// Move spaceship within range
var newPos = spaceship.limitPosition(x, y);
spaceship.x = newPos.x;
spaceship.y = newPos.y;
} else if (dragMode === 'camera' && isDragging) {
var deltaX = x - lastDragX;
var deltaY = y - lastDragY;
// Update camera position (inverted for natural drag feel)
cameraX -= deltaX;
cameraY -= deltaY;
// Update all stars positions
for (var i = 0; i < stars.length; i++) {
stars[i].x += deltaX;
stars[i].y += deltaY;
}
// Update all connections positions
for (var i = 0; i < connections.length; i++) {
connections[i].x += deltaX;
connections[i].y += deltaY;
}
// Update spaceship position if it exists
if (spaceship) {
spaceship.x += deltaX;
spaceship.y += deltaY;
spaceship.originX += deltaX;
spaceship.originY += deltaY;
}
lastDragX = x;
lastDragY = y;
}
};
game.up = function (x, y, obj) {
isDragging = false;
spaceshipDrag = false;
};
// Create stars with natural clustering and varied placement
for (var i = 0; i < numStars; i++) {
var attempts = 0;
var maxAttempts = 200; // More attempts for better placement
var validPosition = false;
var x, y, scale;
// Pre-generate star scale to use in position validation
scale = 0.7 + seededRandom() * 0.6;
// Try to find a valid position
while (!validPosition && attempts < maxAttempts) {
// Generate position with natural clustering tendency
var centerX = 2048 / 2;
var centerY = 2732 / 2;
var angle = seededRandom() * 2 * Math.PI;
// Create natural distribution - more stars in middle, fewer at edges
var radiusRandom = seededRandom();
var radius = Math.pow(radiusRandom, 1.5) * 4000; // Power curve for natural distribution
// Add some variation to avoid perfect circles
var radiusVariation = (seededRandom() - 0.5) * 300;
radius += radiusVariation;
radius = Math.max(200, Math.min(4000, radius)); // Clamp within bounds
x = centerX + Math.cos(angle) * radius;
y = centerY + Math.sin(angle) * radius;
validPosition = isValidPosition(x, y, scale);
attempts++;
}
// Only create star if valid position was found
if (validPosition) {
var star = game.addChild(new Star());
star.x = x;
star.y = y;
// Apply the pre-generated scale to maintain consistency
star.starGraphics.scaleX = scale;
star.starGraphics.scaleY = scale;
stars.push(star);
} else {
// If we couldn't find a valid position after max attempts, reduce requirements and try once more
if (i > numStars * 0.7) {
// Only for the last 30% of stars
scale = 0.7; // Use smaller scale for difficult placements
var relaxedAttempts = 0;
while (!validPosition && relaxedAttempts < 50) {
var centerX = 2048 / 2;
var centerY = 2732 / 2;
var angle = seededRandom() * 2 * Math.PI;
var radius = 3000 + seededRandom() * 1000; // Place at outer edges
x = centerX + Math.cos(angle) * radius;
y = centerY + Math.sin(angle) * radius;
validPosition = isValidPosition(x, y, scale);
relaxedAttempts++;
}
if (validPosition) {
var star = game.addChild(new Star());
star.x = x;
star.y = y;
star.starGraphics.scaleX = scale;
star.starGraphics.scaleY = scale;
stars.push(star);
}
}
}
} ===================================================================
--- original.js
+++ change.js