User prompt
la carretera de fondo sera infinita
User prompt
un menu de inicio con un boton en medio para empezar a jugar con un carro acelerando de fondo ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
el sonido de encendido sonara en el momento en el que se empiece a jugar.
User prompt
un maximo de 7 carros en la pantalla
User prompt
que haya mayor posibilidad de que aparezcan potenciadores
User prompt
poco a poco vayan apareciendo mayor cantidad de vehiculoshaya mayor posibilidad de que aparezca
User prompt
menor cantidad de obstaculos el potenciador esta quieto y al momento de tocar el potenciador tengo una mayor velocidad
User prompt
al tocar el objeto inmediatamente tendre una invencibilidad de 10 segundos
User prompt
el objeto especial es de color amarillo
User prompt
mayor cantidad de obstaculos probabilidad de aparecer un objeto especial que te hara inmortal por 5 segundos ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
menor cantidad de obstaculos tengo 2 vidas y me siguen muchos enemigos
Code edit (1 edits merged)
Please save this source code
User prompt
Speed Runner
Initial prompt
un juego de carreras en el que esquivo obstaculos
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var BackgroundRoad = Container.expand(function () {
var self = Container.call(this);
// Create road surface
var roadSurface = self.attachAsset('trackLine', {
anchorX: 0.5,
anchorY: 0.5
});
roadSurface.width = 1648; // Road width between boundaries
roadSurface.height = 2800; // Full screen height
roadSurface.tint = 0x34495e; // Dark road color
self.update = function () {
self.y += gameSpeed;
// Reset position for infinite scrolling
if (self.y > 2732) {
self.y = -2732;
}
};
return self;
});
var MenuCar = Container.expand(function () {
var self = Container.call(this);
var carGraphics = self.attachAsset('vehicle', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15;
self.update = function () {
self.y += self.speed;
// Reset position when off screen
if (self.y > 2800) {
self.y = -200;
self.x = 300 + Math.random() * 1448;
}
};
return self;
});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.update = function () {
self.y += self.speed + gameSpeed;
};
return self;
});
var PlayButton = Container.expand(function () {
var self = Container.call(this);
var buttonBg = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
buttonBg.tint = 0x27ae60;
var buttonText = new Text2('PLAY', {
size: 80,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.down = function (x, y, obj) {
// Start the game
startGame();
};
return self;
});
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerupGraphics = self.attachAsset('powerup', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.update = function () {
// Power-up stays stationary, only rotate for visual effect
powerupGraphics.rotation += 0.1;
};
return self;
});
var TrackLine = Container.expand(function () {
var self = Container.call(this);
var lineGraphics = self.attachAsset('trackLine', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.y += gameSpeed;
};
return self;
});
var Vehicle = Container.expand(function () {
var self = Container.call(this);
var vehicleGraphics = self.attachAsset('vehicle', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 0;
self.targetX = 0;
self.update = function () {
// Smooth movement toward target position
var dx = self.targetX - self.x;
if (Math.abs(dx) > 2) {
self.x += dx * 0.15;
} else {
self.x = self.targetX;
}
// Keep vehicle within bounds
var halfWidth = vehicleGraphics.width / 2;
if (self.x - halfWidth < 200) {
self.x = 200 + halfWidth;
self.targetX = self.x;
}
if (self.x + halfWidth > 1848) {
self.x = 1848 - halfWidth;
self.targetX = self.x;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2c3e50
});
/****
* Game Code
****/
var gameSpeed = 5;
var maxSpeed = 20;
var speedIncrement = 0.01;
var distanceTraveled = 0;
var obstacles = [];
var trackLines = [];
var powerups = [];
var vehicle = null;
var dragNode = null;
var gameRunning = false;
var showMenu = true;
var lives = 2;
var maxLives = 2;
var speedBoostActive = false;
var speedBoostEndTime = 0;
var originalSpeed = 5;
var menuCar = null;
var playButton = null;
var backgroundRoads = [];
// Create score display
var scoreTxt = new Text2('0', {
size: 100,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Create speed display
var speedTxt = new Text2('Speed: 5', {
size: 60,
fill: 0xFFFFFF
});
speedTxt.anchor.set(0, 0);
speedTxt.x = 50;
speedTxt.y = 50;
LK.gui.topLeft.addChild(speedTxt);
// Create lives display
var livesTxt = new Text2('Lives: 2', {
size: 60,
fill: 0xFFFFFF
});
livesTxt.anchor.set(1, 0);
livesTxt.x = 1998;
livesTxt.y = 50;
LK.gui.topRight.addChild(livesTxt);
// Initialize menu
function initializeMenu() {
// Create menu car for background animation
menuCar = game.addChild(new MenuCar());
menuCar.x = 1024;
menuCar.y = 1000;
// Create play button
playButton = game.addChild(new PlayButton());
playButton.x = 1024;
playButton.y = 1366;
// Animate play button with pulsing effect
tween(playButton, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(playButton, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (showMenu) {
tween(playButton, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: arguments.callee
});
}
}
});
}
});
}
function startGame() {
showMenu = false;
gameRunning = true;
// Remove menu elements
if (menuCar) {
menuCar.destroy();
menuCar = null;
}
if (playButton) {
playButton.destroy();
playButton = null;
}
// Create game vehicle
vehicle = game.addChild(new Vehicle());
vehicle.x = 1024;
vehicle.y = 2400;
vehicle.targetX = vehicle.x;
// Play startup sound
LK.getSound('startup').play();
}
// Initialize menu on start
initializeMenu();
// Create infinite scrolling background road
function createBackgroundRoad() {
// Create multiple road segments for seamless scrolling
for (var i = 0; i < 3; i++) {
var roadSegment = new BackgroundRoad();
roadSegment.x = 1024; // Center of screen
roadSegment.y = i * 2732 - 2732; // Offset vertically
backgroundRoads.push(roadSegment);
game.addChild(roadSegment);
}
}
// Create initial track lines
function createTrackLines() {
// Left boundary line
for (var i = 0; i < 20; i++) {
var leftLine = new TrackLine();
leftLine.x = 200;
leftLine.y = i * 300 - 600;
trackLines.push(leftLine);
game.addChild(leftLine);
}
// Right boundary line
for (var i = 0; i < 20; i++) {
var rightLine = new TrackLine();
rightLine.x = 1848;
rightLine.y = i * 300 - 600;
trackLines.push(rightLine);
game.addChild(rightLine);
}
// Center dashed line
for (var i = 0; i < 30; i++) {
var centerLine = new TrackLine();
centerLine.x = 1024;
centerLine.y = i * 200 - 600;
trackLines.push(centerLine);
game.addChild(centerLine);
}
}
createBackgroundRoad();
createTrackLines();
// Spawn obstacles
function spawnObstacle() {
if (!gameRunning) return;
var obstacle = new Obstacle();
// Random position within track bounds
obstacle.x = 300 + Math.random() * 1448;
obstacle.y = -100;
obstacles.push(obstacle);
game.addChild(obstacle);
}
// Update and clean up power-ups
for (var i = powerups.length - 1; i >= 0; i--) {
var powerup = powerups[i];
// Check if power-up went off screen
if (powerup.y > 2800) {
powerup.destroy();
powerups.splice(i, 1);
continue;
}
// Check collision with vehicle
if (powerup.intersects(vehicle)) {
// Activate speed boost
speedBoostActive = true;
speedBoostEndTime = LK.ticks + 600; // 10 seconds at 60 FPS
originalSpeed = gameSpeed;
gameSpeed = Math.min(gameSpeed + 10, maxSpeed); // Increase speed by 10
LK.getSound('powerup').play();
// Flash screen gold
LK.effects.flashScreen(0xffd700, 500);
// Animate vehicle with golden tint and pulsing effect
tween(vehicle, {
tint: 0xffd700
}, {
duration: 200
});
// Remove the power-up
powerup.destroy();
powerups.splice(i, 1);
continue;
}
}
// Update and clean up track lines
function spawnPowerUp() {
if (!gameRunning) return;
var powerup = new PowerUp();
// Random position within track bounds
powerup.x = 300 + Math.random() * 1448;
powerup.y = -100;
powerups.push(powerup);
game.addChild(powerup);
}
// Handle touch input
function handleMove(x, y, obj) {
if (showMenu || !gameRunning) return;
if (dragNode) {
// Convert touch position to vehicle target position
vehicle.targetX = x;
}
}
game.move = handleMove;
game.down = function (x, y, obj) {
if (showMenu || !gameRunning) return;
dragNode = vehicle;
handleMove(x, y, obj);
};
game.up = function (x, y, obj) {
if (showMenu) return;
dragNode = null;
};
// Main game loop
game.update = function () {
if (showMenu) {
// Only update menu car animation when in menu
return;
}
if (!gameRunning) return;
// Increase speed over time
if (gameSpeed < maxSpeed) {
gameSpeed += speedIncrement;
}
// Update distance traveled
distanceTraveled += gameSpeed;
// Update score based on distance
var score = Math.floor(distanceTraveled / 10);
LK.setScore(score);
scoreTxt.setText(score);
speedTxt.setText('Speed: ' + Math.floor(gameSpeed));
// Check if speed boost expired
if (speedBoostActive && LK.ticks > speedBoostEndTime) {
speedBoostActive = false;
// Restore normal speed (but keep natural progression)
gameSpeed = Math.max(originalSpeed, 5 + distanceTraveled / 10000 * speedIncrement);
// Stop tween and restore normal vehicle color
tween.stop(vehicle);
vehicle.tint = 0xffffff;
}
// Progressive obstacle spawning - gradually increase frequency and probability
var baseSpawnRate = Math.max(70 - Math.floor(gameSpeed * 2), 30); // Faster spawn rate
var progressMultiplier = Math.min(1 + distanceTraveled / 5000, 3); // Up to 3x more likely over time
var spawnProbability = Math.min(0.3 + distanceTraveled / 8000, 0.8); // Start at 30%, increase to 80%
if (LK.ticks % baseSpawnRate === 0 && obstacles.length < 7) {
// Multiple obstacle spawning based on progress
var numObstacles = Math.floor(progressMultiplier);
for (var spawns = 0; spawns < numObstacles; spawns++) {
if (Math.random() < spawnProbability && obstacles.length < 7) {
spawnObstacle();
}
}
}
// Spawn power-ups occasionally (15% chance when spawning obstacles)
if (LK.ticks % Math.max(60 - Math.floor(gameSpeed), 30) === 0 && Math.random() < 0.15) {
spawnPowerUp();
}
// Update and clean up obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
var obstacle = obstacles[i];
// Check if obstacle went off screen
if (obstacle.y > 2800) {
obstacle.destroy();
obstacles.splice(i, 1);
continue;
}
// Check collision with vehicle
if (obstacle.intersects(vehicle)) {
lives--;
livesTxt.setText('Lives: ' + lives);
LK.getSound('crash').play();
// Flash screen red
LK.effects.flashScreen(0xff0000, 500);
// Remove the obstacle that was hit
obstacle.destroy();
obstacles.splice(i, 1);
// Check if game over
if (lives <= 0) {
gameRunning = false;
LK.setTimeout(function () {
LK.showGameOver();
}, 500);
return;
}
continue;
}
}
// Update and clean up track lines
for (var i = trackLines.length - 1; i >= 0; i--) {
var line = trackLines[i];
// Respawn track lines that went off screen
if (line.y > 2800) {
line.y = -200;
}
}
// Update background road for infinite scrolling
for (var i = 0; i < backgroundRoads.length; i++) {
var road = backgroundRoads[i];
// Background roads update themselves through their update method
}
}; ===================================================================
--- original.js
+++ change.js
@@ -5,8 +5,27 @@
/****
* Classes
****/
+var BackgroundRoad = Container.expand(function () {
+ var self = Container.call(this);
+ // Create road surface
+ var roadSurface = self.attachAsset('trackLine', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ roadSurface.width = 1648; // Road width between boundaries
+ roadSurface.height = 2800; // Full screen height
+ roadSurface.tint = 0x34495e; // Dark road color
+ self.update = function () {
+ self.y += gameSpeed;
+ // Reset position for infinite scrolling
+ if (self.y > 2732) {
+ self.y = -2732;
+ }
+ };
+ return self;
+});
var MenuCar = Container.expand(function () {
var self = Container.call(this);
var carGraphics = self.attachAsset('vehicle', {
anchorX: 0.5,
@@ -135,8 +154,9 @@
var speedBoostEndTime = 0;
var originalSpeed = 5;
var menuCar = null;
var playButton = null;
+var backgroundRoads = [];
// Create score display
var scoreTxt = new Text2('0', {
size: 100,
fill: 0xFFFFFF
@@ -222,8 +242,19 @@
LK.getSound('startup').play();
}
// Initialize menu on start
initializeMenu();
+// Create infinite scrolling background road
+function createBackgroundRoad() {
+ // Create multiple road segments for seamless scrolling
+ for (var i = 0; i < 3; i++) {
+ var roadSegment = new BackgroundRoad();
+ roadSegment.x = 1024; // Center of screen
+ roadSegment.y = i * 2732 - 2732; // Offset vertically
+ backgroundRoads.push(roadSegment);
+ game.addChild(roadSegment);
+ }
+}
// Create initial track lines
function createTrackLines() {
// Left boundary line
for (var i = 0; i < 20; i++) {
@@ -249,8 +280,9 @@
trackLines.push(centerLine);
game.addChild(centerLine);
}
}
+createBackgroundRoad();
createTrackLines();
// Spawn obstacles
function spawnObstacle() {
if (!gameRunning) return;
@@ -401,5 +433,10 @@
if (line.y > 2800) {
line.y = -200;
}
}
+ // Update background road for infinite scrolling
+ for (var i = 0; i < backgroundRoads.length; i++) {
+ var road = backgroundRoads[i];
+ // Background roads update themselves through their update method
+ }
};
\ No newline at end of file
un propulsor turbo de carreras que expulse fuego con perspectiva hacia arriba In-Game asset. 2d. High contrast. No shadows
carretera oscura con perspectiva desde arriba. In-Game asset. 2d. High contrast. No shadows
carro azul deportivo con la perspectiva hacia arriba. In-Game asset. 2d. High contrast. No shadows hecho con pixeles acelerando con perspectiva trasera sin el rastro
un carro rojo deportivo con la perspectiva hacia arriba. In-Game asset. 2d. High contrast. No shadows hecho con pixeles
tres corazones hechos con pixeles. In-Game asset. 2d. High contrast. No shadows
un coche blanco deportivo hecho con pixeles con perspectiva desde arriba de la parte trasera. In-Game asset. 2d. High contrast. No shadows
tira de puas hecho con pixeles. In-Game asset. 2d. High contrast. No shadows
boton rojo hecho con pixeles con la palabra play en medio In-Game asset. 2d. High contrast. No shadows
un auto verde deportivo con perspectiva desde arriba hecho con pixeles. In-Game asset. 2d. High contrast. No shadows con perspectiva trasera
un auto amarillo deportivo con perspectiva desde arriba hecho con pixeles. In-Game asset. 2d. High contrast. No shadows con perspectiva trasera
un auto negro deportivo hecho con pixeles con la perspectiva desde arriba y trasera. In-Game asset. 2d. High contrast. No shadows
agujero de la calle hecho con pixeles. In-Game asset. 2d. High contrast. No shadows
un barril derramando petroleo negro hecho con pixeles In-Game asset. 2d. High contrast. No shadows
coche de policia hecho con pixeles con perspectiva desde arriba In-Game asset. 2d. High contrast. No shadows
motociclista de chaqueta negra hecha con pixeles con perspectiva desde arriba y trasera. In-Game asset. 2d. High contrast. No shadows
auto celeste deportivo con perspectiva desde arriba y trasera hecho con pixeles. In-Game asset. 2d. High contrast. No shadows
letras que dicen speed runner las letras speed tienen un color blanco con contorno negro y las letras runner un color celeste con un contorno azul todo hecho con pixeles y con una cursiva. In-Game asset. 2d. High contrast. No shadows