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 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 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 vehicle = null; var dragNode = null; var gameRunning = true; // 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 vehicle vehicle = game.addChild(new Vehicle()); vehicle.x = 1024; vehicle.y = 2400; vehicle.targetX = vehicle.x; // 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); } } 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); } // Handle touch input function handleMove(x, y, obj) { if (!gameRunning) return; if (dragNode) { // Convert touch position to vehicle target position vehicle.targetX = x; } } game.move = handleMove; game.down = function (x, y, obj) { if (!gameRunning) return; dragNode = vehicle; handleMove(x, y, obj); }; game.up = function (x, y, obj) { dragNode = null; }; // Main game loop game.update = function () { 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)); // Spawn obstacles if (LK.ticks % Math.max(30 - Math.floor(gameSpeed), 15) === 0) { spawnObstacle(); } // 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)) { gameRunning = false; LK.getSound('crash').play(); // Flash screen red LK.effects.flashScreen(0xff0000, 1000); // Game over after brief delay LK.setTimeout(function () { LK.showGameOver(); }, 500); return; } } // 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; } } };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,205 @@
-/****
+/****
+* 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 = 8;
+ self.update = function () {
+ self.y += self.speed + gameSpeed;
+ };
+ 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: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x2c3e50
+});
+
+/****
+* Game Code
+****/
+var gameSpeed = 5;
+var maxSpeed = 20;
+var speedIncrement = 0.01;
+var distanceTraveled = 0;
+var obstacles = [];
+var trackLines = [];
+var vehicle = null;
+var dragNode = null;
+var gameRunning = true;
+// 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 vehicle
+vehicle = game.addChild(new Vehicle());
+vehicle.x = 1024;
+vehicle.y = 2400;
+vehicle.targetX = vehicle.x;
+// 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);
+ }
+}
+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);
+}
+// Handle touch input
+function handleMove(x, y, obj) {
+ if (!gameRunning) return;
+ if (dragNode) {
+ // Convert touch position to vehicle target position
+ vehicle.targetX = x;
+ }
+}
+game.move = handleMove;
+game.down = function (x, y, obj) {
+ if (!gameRunning) return;
+ dragNode = vehicle;
+ handleMove(x, y, obj);
+};
+game.up = function (x, y, obj) {
+ dragNode = null;
+};
+// Main game loop
+game.update = function () {
+ 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));
+ // Spawn obstacles
+ if (LK.ticks % Math.max(30 - Math.floor(gameSpeed), 15) === 0) {
+ spawnObstacle();
+ }
+ // 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)) {
+ gameRunning = false;
+ LK.getSound('crash').play();
+ // Flash screen red
+ LK.effects.flashScreen(0xff0000, 1000);
+ // Game over after brief delay
+ LK.setTimeout(function () {
+ LK.showGameOver();
+ }, 500);
+ return;
+ }
+ }
+ // 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;
+ }
+ }
+};
\ 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