User prompt
Debe de sonar cuándo el obstáculo y el jugador se toquen
User prompt
Sonido colision
User prompt
El sonido debe de estar en bucle
User prompt
El sonido del motor en bucle mientras se mueve y para cuando no se mueve
User prompt
Ruido al mover la nave, como si pasara un avión
User prompt
Cambialo el fuego al lado opuesto y que sean más grandes ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Siempre salga desde el mismo lado el fuego, gire a izquierda o derecha ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
El fuego que salga por un lateral ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Girala 90 grados
User prompt
La punta de la nave que mire hacia el centro
User prompt
La nave girala 90 grados a la izquierda
User prompt
Cambia el fuego de posición ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
El fuego lo está echando por la izquierda, cambialo a la parte trasera
User prompt
El player echa fuego por la parte trasera cuando se mueve ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Los obstáculos aparecen con distintos tamaños aleatoriamente
User prompt
Los obstáculos siguen la misma trayectoria, pero van rotando sobre si mismo ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Más alejado aún y solo se puede mover en una circunferencia imaginaria
User prompt
El player más alejado del centro
User prompt
Todo más cerca para que se vea todo más grande
User prompt
Un poco más cerca para que se vea más grande
User prompt
Dale media vuelta a la nave
User prompt
La punta de la nave siempre debe apuntar al centro ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
El player es una nave espacial
Code edit (1 edits merged)
Please save this source code
User prompt
Centro Dodge
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var FireParticle = Container.expand(function () {
var self = Container.call(this);
var particleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.6,
scaleY: 0.6,
tint: 0xff4500
});
self.life = 1.0;
self.velocityX = 0;
self.velocityY = 0;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
self.life -= 0.05;
particleGraphics.alpha = self.life;
particleGraphics.scaleX = self.life * 0.6;
particleGraphics.scaleY = self.life * 0.6;
if (self.life <= 0) {
self.destroy();
}
};
return self;
});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2
});
self.speed = 2;
self.targetX = 2048 / 2;
self.targetY = 2732 / 2;
self.update = function () {
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 5) {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
// Rotate obstacle continuously as it moves
obstacleGraphics.rotation += 0.1;
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
});
// Make it look more like a spaceship by rotating it to point upward
playerGraphics.rotation = -Math.PI * 1.5; // Rotated an additional 90 degrees
self.speed = 8;
self.targetX = self.x;
self.targetY = self.y;
self.lastX = self.x;
self.lastY = self.y;
self.fireParticles = [];
self.engineSoundPlaying = false;
self.update = function () {
// Store last position for movement detection
self.lastX = self.x;
self.lastY = self.y;
// Smooth movement toward target position
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
var isMoving = Math.abs(dx) > 1 || Math.abs(dy) > 1;
if (isMoving) {
self.x += dx * 0.15;
self.y += dy * 0.15;
// Play engine sound when moving
if (!self.engineSoundPlaying) {
self.engineSound = LK.getSound('engine');
self.engineSound.play();
self.engineSoundPlaying = true;
}
} else {
// Stop engine sound when not moving
if (self.engineSoundPlaying) {
if (self.engineSound) {
self.engineSound.stop();
}
self.engineSoundPlaying = false;
}
}
// Calculate angle to center and rotate spaceship to point toward it
var centerX = 2048 / 2;
var centerY = 2732 / 2;
var angleToCenter = Math.atan2(centerY - self.y, centerX - self.x);
var targetRotation = angleToCenter - Math.PI / 2; // Point toward center
// Smooth rotation toward target angle using tween
tween(playerGraphics, {
rotation: targetRotation
}, {
duration: 100,
easing: tween.easeOut
});
// Create fire particles when moving
if (isMoving) {
var particle = new FireParticle();
// Always position particle from the left side of player (consistent side)
var leftSideOffsetX = -35; // Fixed offset to the left
var leftSideOffsetY = 0;
particle.x = self.x + leftSideOffsetX;
particle.y = self.y + leftSideOffsetY;
// Add velocity toward the left side (consistent direction)
particle.velocityX = -2 - Math.random() * 2;
particle.velocityY = 0;
// Add some random spread
particle.velocityX += (Math.random() - 0.5) * 2;
particle.velocityY += (Math.random() - 0.5) * 2;
self.fireParticles.push(particle);
game.addChild(particle);
}
// Clean up dead particles
for (var i = self.fireParticles.length - 1; i >= 0; i--) {
if (self.fireParticles[i].life <= 0) {
self.fireParticles.splice(i, 1);
}
}
};
self.moveTo = function (x, y) {
// Keep player within central area bounds
var centerX = 2048 / 2;
var centerY = 2732 / 2;
var maxDistance = 400;
// Always constrain player to move only on the circular path at maxDistance
var angle = Math.atan2(y - centerY, x - centerX);
self.targetX = centerX + Math.cos(angle) * maxDistance;
self.targetY = centerY + Math.sin(angle) * maxDistance;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a2e
});
/****
* Game Code
****/
var player;
var obstacles = [];
var gameStarted = false;
var spawnTimer = 0;
var spawnRate = 120; // Initial spawn rate (ticks between spawns)
var difficultyTimer = 0;
var baseObstacleSpeed = 2;
// Create center circle indicator
var centerIndicator = LK.getAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3,
scaleY: 3,
alpha: 0.1
});
centerIndicator.x = 2048 / 2;
centerIndicator.y = 2732 / 2;
game.addChild(centerIndicator);
// Create player
player = new Player();
player.x = 2048 / 2;
player.y = 2732 / 2;
game.addChild(player);
// Score display
var scoreTxt = new Text2('0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Game instructions
var instructionTxt = new Text2('Touch to move around the center', {
size: 60,
fill: 0xCCCCCC
});
instructionTxt.anchor.set(0.5, 0.5);
instructionTxt.x = 2048 / 2;
instructionTxt.y = 2732 / 2 + 80;
game.addChild(instructionTxt);
function spawnObstacle() {
var obstacle = new Obstacle();
// Random spawn position along screen edges
var edge = Math.floor(Math.random() * 4);
switch (edge) {
case 0:
// Top edge
obstacle.x = Math.random() * 2048;
obstacle.y = -50;
break;
case 1:
// Right edge
obstacle.x = 2048 + 50;
obstacle.y = Math.random() * 2732;
break;
case 2:
// Bottom edge
obstacle.x = Math.random() * 2048;
obstacle.y = 2732 + 50;
break;
case 3:
// Left edge
obstacle.x = -50;
obstacle.y = Math.random() * 2732;
break;
}
// Add random size variation to obstacles
var randomScale = 0.5 + Math.random() * 1.5; // Random scale between 0.5x and 2x
obstacle.scaleX = randomScale;
obstacle.scaleY = randomScale;
// Set speed based on current difficulty
obstacle.speed = baseObstacleSpeed + difficultyTimer / 3600 * 2; // Increase speed over time
obstacles.push(obstacle);
game.addChild(obstacle);
}
function checkCollisions() {
for (var i = obstacles.length - 1; i >= 0; i--) {
var obstacle = obstacles[i];
if (player.intersects(obstacle)) {
// Game over
LK.getSound('collision').play();
LK.effects.flashScreen(0xff0000, 500);
LK.showGameOver();
return;
}
// Remove obstacles that reach the center
var distanceToCenter = Math.sqrt((obstacle.x - 2048 / 2) * (obstacle.x - 2048 / 2) + (obstacle.y - 2732 / 2) * (obstacle.y - 2732 / 2));
if (distanceToCenter < 30) {
obstacle.destroy();
obstacles.splice(i, 1);
}
}
}
function updateDifficulty() {
difficultyTimer++;
// Increase spawn rate every 5 seconds
if (difficultyTimer % 300 === 0 && spawnRate > 30) {
spawnRate -= 5;
}
}
game.down = function (x, y, obj) {
if (!gameStarted) {
gameStarted = true;
instructionTxt.destroy();
}
player.moveTo(x, y);
};
game.move = function (x, y, obj) {
if (gameStarted) {
player.moveTo(x, y);
}
};
game.update = function () {
if (!gameStarted) return;
// Update score based on survival time
var currentScore = Math.floor(LK.ticks / 60); // Score increases every second
LK.setScore(currentScore);
scoreTxt.setText(currentScore);
// Spawn obstacles
spawnTimer++;
if (spawnTimer >= spawnRate) {
spawnObstacle();
spawnTimer = 0;
}
// Update difficulty
updateDifficulty();
// Check for collisions
checkCollisions();
}; ===================================================================
--- original.js
+++ change.js
@@ -85,9 +85,8 @@
self.y += dy * 0.15;
// Play engine sound when moving
if (!self.engineSoundPlaying) {
self.engineSound = LK.getSound('engine');
- self.engineSound.loop = true;
self.engineSound.play();
self.engineSoundPlaying = true;
}
} else {
Botón rojo con dibujo de bala en el interior. In-Game asset. 2d. High contrast. No shadows
Planeta tierra. In-Game asset. 2d. High contrast. No shadows
Rodeado de un corazón rosa
Escudo azul. In-Game asset. 2d. High contrast. No shadows
Boss espacial. In-Game asset. 2d. High contrast. No shadows
Bala azul. In-Game asset. 2d. High contrast. No shadows
Amarillo