User prompt
The player should have a 0.5 larger hitbox, accommodate the player skin I have provided you
User prompt
The player is a car, the obstacles are spikes and the platforms are asphalt.
User prompt
The player has a car skin, car spike obstacles and street or asphalt platforms.
User prompt
The player must be on top of the platforms just as the obstacles must be on top not in the center
User prompt
Platform textures should be finer, the size of their hitbox.
User prompt
Platforms should have a finer texture or a larger hitbox.
User prompt
The platforms will have a stone texture, the player will be a cart and the obstacles will be small and Mediums will be peaks on the ground and large ones will be birds flying ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Every 0.5 seconds is 1 point
User prompt
Remove the record section and change it to "score" Each point is equivalent to 1 second. 1 second = 1 point
User prompt
Large obstacles must appear at least 3 times every 150 points
User prompt
Obstacles tend to appear on the platform where the player is standing. The big obstacle will be a wall that will cover 2 platforms
User prompt
The indicator where the obstacles will emerge from should appear 0.5 seconds before the obstacle appears. The obstacles will have 3 sizes: small, medium and large, the large one will occupy 2 of the 3 platforms ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make an arrow appear where the obstacles come out . Make obstacles increase their speed by 1 for every 100 points
User prompt
That the character moves between the 3 platforms and can go up or down with an arrow button There will be some obstacles that will pass through the platforms.
Code edit (1 edits merged)
Please save this source code
User prompt
Jump Runner - Infinite Obstacle Course
Initial prompt
Create a game where the character runs infinitely but has to jump over obstacles which will come from 3 directions: top, middle and bottom, those below and middle can be jumped over.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Obstacle = Container.expand(function (lane) {
var self = Container.call(this);
self.lane = lane || 'middle';
self.speed = 8;
var assetName = 'obstacleMiddle';
if (self.lane === 'top') assetName = 'obstacleTop';else if (self.lane === 'bottom') assetName = 'obstacleBottom';
var obstacleGraphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.x -= 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
});
self.currentLane = 1; // 0=top, 1=middle, 2=bottom
self.isMoving = false;
self.targetY = 0;
self.moveSpeed = 12;
self.moveUp = function () {
if (!self.isMoving && self.currentLane > 0) {
self.currentLane--;
self.isMoving = true;
if (self.currentLane === 0) self.targetY = topLaneY;else if (self.currentLane === 1) self.targetY = middleLaneY;
LK.getSound('platformSwitch').play();
}
};
self.moveDown = function () {
if (!self.isMoving && self.currentLane < 2) {
self.currentLane++;
self.isMoving = true;
if (self.currentLane === 1) self.targetY = middleLaneY;else if (self.currentLane === 2) self.targetY = bottomLaneY;
LK.getSound('platformSwitch').play();
}
};
self.update = function () {
if (self.isMoving) {
var diff = self.targetY - self.y;
if (Math.abs(diff) < self.moveSpeed) {
self.y = self.targetY;
self.isMoving = false;
} else {
self.y += diff > 0 ? self.moveSpeed : -self.moveSpeed;
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Game dimensions: 2048x2732
var gameWidth = 2048;
var gameHeight = 2732;
// Lane positions
var topLaneY = gameHeight * 0.3;
var middleLaneY = gameHeight * 0.5;
var bottomLaneY = gameHeight * 0.7;
// Game variables
var player;
var obstacles = [];
var gameSpeed = 1;
var spawnTimer = 0;
var spawnInterval = 120; // frames between spawns
var distanceTraveled = 0;
var speedIncreaseInterval = 600; // increase speed every 10 seconds at 60fps
// Initialize score display
var scoreTxt = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Initialize distance display
var distanceTxt = new Text2('Distance: 0m', {
size: 50,
fill: 0xFFFFFF
});
distanceTxt.anchor.set(0, 0);
distanceTxt.x = 50;
distanceTxt.y = 150;
LK.gui.topLeft.addChild(distanceTxt);
// Create player
player = game.addChild(new Player());
player.x = gameWidth * 0.2;
player.y = middleLaneY;
// Create arrow buttons
var arrowUp = LK.getAsset('arrowUp', {
anchorX: 0.5,
anchorY: 0.5
});
arrowUp.x = gameWidth - 150;
arrowUp.y = gameHeight - 300;
LK.gui.addChild(arrowUp);
var arrowDown = LK.getAsset('arrowDown', {
anchorX: 0.5,
anchorY: 0.5
});
arrowDown.x = gameWidth - 150;
arrowDown.y = gameHeight - 150;
LK.gui.addChild(arrowDown);
// Arrow button event handlers
arrowUp.down = function (x, y, obj) {
player.moveUp();
};
arrowDown.down = function (x, y, obj) {
player.moveDown();
};
// Draw lane indicators (simple visual guides)
var topLane = LK.getAsset('obstacleTop', {
anchorX: 0,
anchorY: 0.5,
alpha: 0.2,
scaleX: 30,
scaleY: 0.5
});
topLane.x = 0;
topLane.y = topLaneY;
game.addChild(topLane);
var middleLane = LK.getAsset('obstacleMiddle', {
anchorX: 0,
anchorY: 0.5,
alpha: 0.2,
scaleX: 30,
scaleY: 0.5
});
middleLane.x = 0;
middleLane.y = middleLaneY;
game.addChild(middleLane);
var bottomLane = LK.getAsset('obstacleBottom', {
anchorX: 0,
anchorY: 0.5,
alpha: 0.2,
scaleX: 30,
scaleY: 0.5
});
bottomLane.x = 0;
bottomLane.y = bottomLaneY;
game.addChild(bottomLane);
function spawnObstacle() {
var lanes = ['top', 'middle', 'bottom'];
var randomLane = lanes[Math.floor(Math.random() * lanes.length)];
var obstacle = new Obstacle(randomLane);
obstacle.x = gameWidth + 50;
if (randomLane === 'top') {
obstacle.y = topLaneY;
} else if (randomLane === 'middle') {
obstacle.y = middleLaneY;
} else {
obstacle.y = bottomLaneY;
}
obstacle.speed = 8 * gameSpeed;
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)) {
LK.getSound('collision').play();
LK.effects.flashScreen(0xFF0000, 1000);
LK.showGameOver();
return;
}
}
}
// Touch controls for platform switching
var touchStartY = 0;
game.down = function (x, y, obj) {
touchStartY = y;
};
game.up = function (x, y, obj) {
var swipeDistance = y - touchStartY;
if (Math.abs(swipeDistance) > 100) {
if (swipeDistance < 0) {
// Swipe up
player.moveUp();
} else {
// Swipe down
player.moveDown();
}
}
};
// Main game loop
game.update = function () {
// Update distance traveled
distanceTraveled += gameSpeed;
var distanceMeters = Math.floor(distanceTraveled / 10);
distanceTxt.setText('Distance: ' + distanceMeters + 'm');
// Update score based on distance and obstacles passed
var newScore = distanceMeters + (obstacles.length - obstacles.filter(function (obs) {
return obs.x > player.x;
}).length) * 10;
LK.setScore(newScore);
scoreTxt.setText('Score: ' + LK.getScore());
// Increase game speed over time
if (LK.ticks % speedIncreaseInterval === 0) {
gameSpeed += 0.1;
if (spawnInterval > 60) {
spawnInterval -= 5;
}
}
// Spawn obstacles
spawnTimer++;
if (spawnTimer >= spawnInterval) {
spawnObstacle();
spawnTimer = 0;
}
// Update obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
var obstacle = obstacles[i];
obstacle.speed = 8 * gameSpeed;
// Remove obstacles that are off screen
if (obstacle.x < -100) {
obstacle.destroy();
obstacles.splice(i, 1);
}
}
// Check for collisions
checkCollisions();
}; ===================================================================
--- original.js
+++ change.js
@@ -24,31 +24,38 @@
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
- anchorY: 1.0
+ anchorY: 0.5
});
- self.groundY = 0;
- self.jumpHeight = 200;
- self.jumpSpeed = 15;
- self.isJumping = false;
- self.velocityY = 0;
- self.gravity = 0.8;
- self.jump = function () {
- if (!self.isJumping) {
- self.isJumping = true;
- self.velocityY = -self.jumpSpeed;
- LK.getSound('jump').play();
+ self.currentLane = 1; // 0=top, 1=middle, 2=bottom
+ self.isMoving = false;
+ self.targetY = 0;
+ self.moveSpeed = 12;
+ self.moveUp = function () {
+ if (!self.isMoving && self.currentLane > 0) {
+ self.currentLane--;
+ self.isMoving = true;
+ if (self.currentLane === 0) self.targetY = topLaneY;else if (self.currentLane === 1) self.targetY = middleLaneY;
+ LK.getSound('platformSwitch').play();
}
};
+ self.moveDown = function () {
+ if (!self.isMoving && self.currentLane < 2) {
+ self.currentLane++;
+ self.isMoving = true;
+ if (self.currentLane === 1) self.targetY = middleLaneY;else if (self.currentLane === 2) self.targetY = bottomLaneY;
+ LK.getSound('platformSwitch').play();
+ }
+ };
self.update = function () {
- if (self.isJumping) {
- self.velocityY += self.gravity;
- self.y += self.velocityY;
- if (self.y >= self.groundY) {
- self.y = self.groundY;
- self.isJumping = false;
- self.velocityY = 0;
+ if (self.isMoving) {
+ var diff = self.targetY - self.y;
+ if (Math.abs(diff) < self.moveSpeed) {
+ self.y = self.targetY;
+ self.isMoving = false;
+ } else {
+ self.y += diff > 0 ? self.moveSpeed : -self.moveSpeed;
}
}
};
return self;
@@ -98,9 +105,30 @@
// Create player
player = game.addChild(new Player());
player.x = gameWidth * 0.2;
player.y = middleLaneY;
-player.groundY = middleLaneY;
+// Create arrow buttons
+var arrowUp = LK.getAsset('arrowUp', {
+ anchorX: 0.5,
+ anchorY: 0.5
+});
+arrowUp.x = gameWidth - 150;
+arrowUp.y = gameHeight - 300;
+LK.gui.addChild(arrowUp);
+var arrowDown = LK.getAsset('arrowDown', {
+ anchorX: 0.5,
+ anchorY: 0.5
+});
+arrowDown.x = gameWidth - 150;
+arrowDown.y = gameHeight - 150;
+LK.gui.addChild(arrowDown);
+// Arrow button event handlers
+arrowUp.down = function (x, y, obj) {
+ player.moveUp();
+};
+arrowDown.down = function (x, y, obj) {
+ player.moveDown();
+};
// Draw lane indicators (simple visual guides)
var topLane = LK.getAsset('obstacleTop', {
anchorX: 0,
anchorY: 0.5,
@@ -157,12 +185,25 @@
return;
}
}
}
-// Touch controls
+// Touch controls for platform switching
+var touchStartY = 0;
game.down = function (x, y, obj) {
- player.jump();
+ touchStartY = y;
};
+game.up = function (x, y, obj) {
+ var swipeDistance = y - touchStartY;
+ if (Math.abs(swipeDistance) > 100) {
+ if (swipeDistance < 0) {
+ // Swipe up
+ player.moveUp();
+ } else {
+ // Swipe down
+ player.moveDown();
+ }
+ }
+};
// Main game loop
game.update = function () {
// Update distance traveled
distanceTraveled += gameSpeed;