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 Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
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;
}
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
// Make it look more like a spaceship by rotating it to point upward
playerGraphics.rotation = -Math.PI / 2; // Point upward like a spaceship
self.speed = 8;
self.targetX = self.x;
self.targetY = self.y;
self.update = function () {
// Smooth movement toward target position
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
if (Math.abs(dx) > 1 || Math.abs(dy) > 1) {
self.x += dx * 0.15;
self.y += dy * 0.15;
}
// 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; // Adjust for spaceship pointing upward by default
// Smooth rotation toward target angle using tween
tween(playerGraphics, {
rotation: targetRotation
}, {
duration: 100,
easing: tween.easeOut
});
};
self.moveTo = function (x, y) {
// Keep player within central area bounds
var centerX = 2048 / 2;
var centerY = 2732 / 2;
var maxDistance = 200;
var distanceFromCenter = Math.sqrt((x - centerX) * (x - centerX) + (y - centerY) * (y - centerY));
if (distanceFromCenter > maxDistance) {
var angle = Math.atan2(y - centerY, x - centerX);
self.targetX = centerX + Math.cos(angle) * maxDistance;
self.targetY = centerY + Math.sin(angle) * maxDistance;
} else {
self.targetX = x;
self.targetY = y;
}
};
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: 6,
scaleY: 6,
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 + 150;
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;
}
// 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
@@ -44,8 +44,20 @@
if (Math.abs(dx) > 1 || Math.abs(dy) > 1) {
self.x += dx * 0.15;
self.y += dy * 0.15;
}
+ // 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; // Adjust for spaceship pointing upward by default
+ // Smooth rotation toward target angle using tween
+ tween(playerGraphics, {
+ rotation: targetRotation
+ }, {
+ duration: 100,
+ easing: tween.easeOut
+ });
};
self.moveTo = function (x, y) {
// Keep player within central area bounds
var centerX = 2048 / 2;
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