User prompt
Delete ground and recode it because this is a parkour game and there needs to be space in between
User prompt
Place a border at the end of the finishLine and when the player touches it, he is eliminated.
User prompt
At the beginning and when you pass to finishLine, put a 3-second timer and the game will start after 3 seconds. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Keep distance between coins and spikes
User prompt
Increase the spacing between spikes. Enlarge the platform and increase the distance from one platform to another. Two platforms should not be next to each other and should not touch each other. Reduce the spike spawn rate.
User prompt
Make game over menu
User prompt
Oyuncu hızını arttır, oyuncuyu küçült, platform yatay uzunluğunu arttır ve bir platform ile başka bir platform aralığı 85 yap
User prompt
Bir platform başka bir platform ile en az 50 px uzaklıkta olmalı
User prompt
Add to player more speed and make objets bigger
User prompt
Make coins and player more bigger
User prompt
Make lava infinite
User prompt
Platformun aşağısına lav koy ve yerçekimini düzelt
User prompt
Make objects bigger
User prompt
Aşağı düşünce ölsün
Code edit (1 edits merged)
Please save this source code
User prompt
Cube Rush - 2D Parkour Adventure
Initial prompt
Cube parkour game 2d
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Coin = Container.expand(function () {
var self = Container.call(this);
var coinGraphics = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
self.collected = false;
self.update = function () {
if (!self.collected) {
coinGraphics.rotation += 0.1;
}
};
return self;
});
var FinishLine = Container.expand(function () {
var self = Container.call(this);
var finishGraphics = self.attachAsset('finishLine', {
anchorX: 0.5,
anchorY: 1.0
});
return self;
});
var Ground = Container.expand(function () {
var self = Container.call(this);
var groundGraphics = self.attachAsset('ground', {
anchorX: 0,
anchorY: 0
});
return self;
});
var Lava = Container.expand(function () {
var self = Container.call(this);
var lavaGraphics = self.attachAsset('lava', {
anchorX: 0,
anchorY: 0
});
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 1.0
});
self.velocityY = 0;
self.isGrounded = false;
self.jumpForce = -20;
self.gravity = 0.8;
self.groundY = 0;
self.isJumping = false;
self.jump = function () {
if (self.isGrounded) {
self.velocityY = self.jumpForce;
self.isGrounded = false;
self.isJumping = true;
LK.getSound('jump').play();
}
};
self.strongJump = function () {
if (self.isGrounded) {
self.velocityY = self.jumpForce * 1.5;
self.isGrounded = false;
self.isJumping = true;
LK.getSound('jump').play();
}
};
self.update = function () {
// Apply gravity
if (!self.isGrounded) {
self.velocityY += self.gravity;
}
// Update position
self.y += self.velocityY;
// Ground collision
if (self.y >= self.groundY) {
self.y = self.groundY;
self.velocityY = 0;
self.isGrounded = true;
self.isJumping = false;
}
};
return self;
});
var Spike = Container.expand(function () {
var self = Container.call(this);
var spikeGraphics = self.attachAsset('spike', {
anchorX: 0.5,
anchorY: 1.0
});
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb
});
/****
* Game Code
****/
// Game variables
var player;
var grounds = [];
var spikes = [];
var coins = [];
var finishLine;
var cameraOffsetX = 0;
var gameSpeed = 4;
var currentLevel = storage.currentLevel || 1;
var levelComplete = false;
var isJumpPressed = false;
var jumpHoldTime = 0;
var maxJumpHoldTime = 15;
// UI Elements
var scoreTxt = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0, 0);
scoreTxt.x = 50;
scoreTxt.y = 50;
LK.gui.topLeft.addChild(scoreTxt);
var levelTxt = new Text2('Level: ' + currentLevel, {
size: 60,
fill: 0xFFFFFF
});
levelTxt.anchor.set(1, 0);
levelTxt.x = -50;
levelTxt.y = 50;
LK.gui.topRight.addChild(levelTxt);
// Initialize player
player = game.addChild(new Player());
player.x = 300;
player.y = 2200;
player.groundY = 2200;
// Level generation function
function generateLevel() {
// Clear existing level elements
for (var i = grounds.length - 1; i >= 0; i--) {
grounds[i].destroy();
}
for (var i = spikes.length - 1; i >= 0; i--) {
spikes[i].destroy();
}
for (var i = coins.length - 1; i >= 0; i--) {
coins[i].destroy();
}
if (finishLine) {
finishLine.destroy();
}
grounds = [];
spikes = [];
coins = [];
// Generate ground platforms
var groundY = 2300;
var currentX = 0;
var levelLength = 3000 + currentLevel * 500;
while (currentX < levelLength) {
var ground = game.addChild(new Ground());
ground.x = currentX;
ground.y = groundY;
grounds.push(ground);
// Add spikes on some platforms
if (currentX > 500 && Math.random() < 0.3 + currentLevel * 0.1) {
var spike = game.addChild(new Spike());
spike.x = currentX + 100 + Math.random() * 100;
spike.y = groundY;
spikes.push(spike);
}
// Add coins
if (Math.random() < 0.4) {
var coin = game.addChild(new Coin());
coin.x = currentX + 50 + Math.random() * 100;
coin.y = groundY - 100 - Math.random() * 100;
coins.push(coin);
}
currentX += 150 + Math.random() * 100;
// Create gaps between platforms
if (currentX < levelLength - 500 && Math.random() < 0.4) {
currentX += 150 + Math.random() * 200;
}
}
// Add infinite lava background
var lavaY = 2500;
var lavaX = 0;
while (lavaX < levelLength + 2048) {
var lava = game.addChild(new Lava());
lava.x = lavaX;
lava.y = lavaY;
lavaX += 2048; // Move to next lava tile position
}
// Add finish line
finishLine = game.addChild(new FinishLine());
finishLine.x = levelLength - 100;
finishLine.y = groundY;
// Reset player position
player.x = 300;
player.y = 2200;
player.velocityY = 0;
player.isGrounded = true;
cameraOffsetX = 0;
levelComplete = false;
}
// Input handling
game.down = function (x, y, obj) {
isJumpPressed = true;
jumpHoldTime = 0;
};
game.up = function (x, y, obj) {
if (isJumpPressed) {
if (jumpHoldTime < 5) {
player.jump();
} else {
player.strongJump();
}
isJumpPressed = false;
jumpHoldTime = 0;
}
};
// Game update loop
game.update = function () {
if (levelComplete) return;
// Handle jump input
if (isJumpPressed) {
jumpHoldTime++;
if (jumpHoldTime >= maxJumpHoldTime) {
player.strongJump();
isJumpPressed = false;
jumpHoldTime = 0;
}
}
// Move player forward automatically
player.x += gameSpeed;
// Update camera
cameraOffsetX = player.x - 400;
game.x = -cameraOffsetX;
// Check ground collision
var onGround = false;
for (var i = 0; i < grounds.length; i++) {
var ground = grounds[i];
if (player.x + 60 > ground.x && player.x - 60 < ground.x + 300 && player.y >= ground.y - 10 && player.y <= ground.y + 75) {
player.groundY = ground.y;
onGround = true;
break;
}
}
if (!onGround) {
player.groundY = 2600; // Fall into lava
}
// Check spike collision
for (var i = 0; i < spikes.length; i++) {
var spike = spikes[i];
if (player.intersects(spike)) {
LK.getSound('death').play();
LK.effects.flashScreen(0xff0000, 500);
resetLevel();
return;
}
}
// Check coin collection
for (var i = 0; i < coins.length; i++) {
var coin = coins[i];
if (!coin.collected && player.intersects(coin)) {
coin.collected = true;
coin.alpha = 0;
LK.setScore(LK.getScore() + 10);
scoreTxt.setText('Score: ' + LK.getScore());
LK.getSound('coin').play();
}
}
// Check finish line
if (finishLine && player.intersects(finishLine)) {
levelComplete = true;
currentLevel++;
storage.currentLevel = currentLevel;
levelTxt.setText('Level: ' + currentLevel);
// Flash screen green and generate next level
LK.effects.flashScreen(0x00ff00, 1000);
LK.setTimeout(function () {
generateLevel();
}, 1000);
}
// Check if player fell into lava or fell below ground level
if (player.y > 2500 || player.y > player.groundY + 100) {
LK.getSound('death').play();
LK.effects.flashScreen(0xff0000, 500);
resetLevel();
}
};
function resetLevel() {
LK.setTimeout(function () {
generateLevel();
}, 1000);
}
// Initialize first level
generateLevel(); ===================================================================
--- original.js
+++ change.js
@@ -190,12 +190,17 @@
if (currentX < levelLength - 500 && Math.random() < 0.4) {
currentX += 150 + Math.random() * 200;
}
}
- // Add lava background
- var lava = game.addChild(new Lava());
- lava.x = 0;
- lava.y = 2500;
+ // Add infinite lava background
+ var lavaY = 2500;
+ var lavaX = 0;
+ while (lavaX < levelLength + 2048) {
+ var lava = game.addChild(new Lava());
+ lava.x = lavaX;
+ lava.y = lavaY;
+ lavaX += 2048; // Move to next lava tile position
+ }
// Add finish line
finishLine = game.addChild(new FinishLine());
finishLine.x = levelLength - 100;
finishLine.y = groundY;