User prompt
add a button in upgrades that player can choose when they want to reset all upgrades back to 0/10 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
save players highest score Distance that displays what players highest score is ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
add a blood particle effect when player die red particles come out of the player ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
add a coin sound effect
User prompt
make the ghost power up the one to go through obstacles more rare to find
User prompt
obstacles still moves all power ups and coins still moves when i go to shop
User prompt
every time i go into upgrades the backround still moves pause everything same as i click the pause button
User prompt
game does not play error obstacles does not spawn Distance Score says NaN also speed fix this
User prompt
another upgrade faster speed same as jump higher 10 fases to upgrade ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Make a shop named upgrades add upgrades player can buy with money jump higher is the first upgrade player can upgrade this 10 times every time jump higher ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Add a coin and if this coin is collected player get +2 money ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
add a backround asset so that i can add a backround
User prompt
make another power up and that is only for 5 seconds player can go through obstacles ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
add power ups to collect make it spawn random first power up super speed for 5 seconds ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
try again please
User prompt
add a Main Menu that when game starts the Main Menu screen shows then add a game over screen when player run into a object
Code edit (1 edits merged)
Please save this source code
User prompt
Jump Rush
Initial prompt
i want to create a endless runner game where player needs to jump over objects
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Ground = Container.expand(function () {
var self = Container.call(this);
var groundGraphics = self.attachAsset('ground', {
anchorX: 0,
anchorY: 0
});
return self;
});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 1.0
});
self.speed = gameSpeed;
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: 1.0
});
self.isJumping = false;
self.jumpSpeed = 0;
self.gravity = 0.8;
self.groundY = 2732 - 150;
self.jumpPower = -18;
self.jump = function () {
if (!self.isJumping) {
self.isJumping = true;
self.jumpSpeed = self.jumpPower;
LK.getSound('jump').play();
}
};
self.update = function () {
if (self.isJumping) {
self.jumpSpeed += self.gravity;
self.y += self.jumpSpeed;
if (self.y >= self.groundY) {
self.y = self.groundY;
self.isJumping = false;
self.jumpSpeed = 0;
}
}
};
return self;
});
var PowerUp = Container.expand(function (type) {
var self = Container.call(this);
self.type = type || 'speed';
var assetId = self.type === 'ghost' ? 'ghostpowerup' : 'powerup';
var powerupGraphics = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = gameSpeed;
self.update = function () {
self.x -= self.speed;
// Add floating animation
self.y += Math.sin(LK.ticks * 0.1) * 0.5;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var gameSpeed = 8;
var speedIncrement = 0.005;
var maxSpeed = 20;
var obstacleSpawnRate = 120;
var nextObstacleSpawn = obstacleSpawnRate;
var distance = 0;
var obstacles = [];
var powerups = [];
var gameRunning = true;
var powerupSpawnRate = 300;
var nextPowerupSpawn = powerupSpawnRate;
var speedBoostActive = false;
var speedBoostEndTime = 0;
var originalSpeed = gameSpeed;
var ghostModeActive = false;
var ghostModeEndTime = 0;
// Create ground
var ground = game.addChild(new Ground());
ground.x = 0;
ground.y = 2732 - 150;
// Create player
var player = game.addChild(new Player());
player.x = 300;
player.y = 2732 - 150;
// Create score display
var scoreText = new Text2('Distance: 0', {
size: 60,
fill: '#ffffff'
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
// Create speed display
var speedText = new Text2('Speed: 8', {
size: 40,
fill: '#ffffff'
});
speedText.anchor.set(1, 0);
speedText.x = -50;
speedText.y = 50;
LK.gui.topRight.addChild(speedText);
function spawnObstacle() {
var obstacle = new Obstacle();
obstacle.x = 2048 + 60;
obstacle.y = 2732 - 150;
obstacles.push(obstacle);
game.addChild(obstacle);
}
function spawnPowerUp() {
var powerupType = Math.random() < 0.5 ? 'speed' : 'ghost';
var powerup = new PowerUp(powerupType);
powerup.x = 2048 + 80;
powerup.y = 2732 - 150 - 100 - Math.random() * 200;
powerups.push(powerup);
game.addChild(powerup);
}
function updateObstacles() {
for (var i = obstacles.length - 1; i >= 0; i--) {
var obstacle = obstacles[i];
obstacle.speed = gameSpeed;
// Remove obstacles that are off screen
if (obstacle.x < -100) {
obstacle.destroy();
obstacles.splice(i, 1);
continue;
}
// Check collision with player
if (gameRunning && !ghostModeActive && obstacle.intersects(player)) {
gameRunning = false;
LK.getSound('collision').play();
LK.effects.flashScreen(0xFF0000, 1000);
LK.setScore(Math.floor(distance / 10));
LK.setTimeout(function () {
LK.showGameOver();
}, 500);
return; // Exit function early after collision
}
}
}
function updatePowerUps() {
for (var i = powerups.length - 1; i >= 0; i--) {
var powerup = powerups[i];
powerup.speed = gameSpeed;
// Remove power-ups that are off screen
if (powerup.x < -100) {
powerup.destroy();
powerups.splice(i, 1);
continue;
}
// Check collision with player
if (gameRunning && powerup.intersects(player)) {
if (powerup.type === 'speed') {
activateSpeedBoost();
} else if (powerup.type === 'ghost') {
activateGhostMode();
}
LK.getSound('powerup').play();
LK.effects.flashObject(player, 0xFFD700, 500);
powerup.destroy();
powerups.splice(i, 1);
}
}
}
function activateSpeedBoost() {
speedBoostActive = true;
speedBoostEndTime = LK.ticks + 300; // 5 seconds at 60 FPS
gameSpeed = Math.min(gameSpeed * 1.5, maxSpeed);
// Tween player color to indicate speed boost
tween(player, {
tint: 0x00FF00
}, {
duration: 200
});
}
function activateGhostMode() {
ghostModeActive = true;
ghostModeEndTime = LK.ticks + 300; // 5 seconds at 60 FPS
// Tween player to semi-transparent blue to indicate ghost mode
tween(player, {
tint: 0x0099FF,
alpha: 0.6
}, {
duration: 200
});
}
function updateSpeedBoost() {
if (speedBoostActive && LK.ticks >= speedBoostEndTime) {
speedBoostActive = false;
gameSpeed = originalSpeed;
// Tween player back to normal color
tween(player, {
tint: 0xFFFFFF
}, {
duration: 200
});
}
}
function updateGhostMode() {
if (ghostModeActive && LK.ticks >= ghostModeEndTime) {
ghostModeActive = false;
// Tween player back to normal appearance
tween(player, {
tint: 0xFFFFFF,
alpha: 1.0
}, {
duration: 200
});
}
}
function updateGameSpeed() {
if (!speedBoostActive && gameSpeed < maxSpeed) {
gameSpeed += speedIncrement;
originalSpeed = gameSpeed;
}
// Adjust obstacle spawn rate based on speed
obstacleSpawnRate = Math.max(60, 120 - (gameSpeed - 8) * 5);
}
function updateDistance() {
if (gameRunning) {
distance += gameSpeed * 0.1;
scoreText.setText('Distance: ' + Math.floor(distance));
speedText.setText('Speed: ' + Math.floor(gameSpeed));
}
}
// Game input handling
game.down = function (x, y, obj) {
if (gameRunning) {
player.jump();
}
};
// Main game loop
game.update = function () {
if (!gameRunning) return;
// Update distance and speed
updateDistance();
updateGameSpeed();
// Update speed boost
updateSpeedBoost();
// Update ghost mode
updateGhostMode();
// Spawn obstacles
nextObstacleSpawn--;
if (nextObstacleSpawn <= 0) {
spawnObstacle();
nextObstacleSpawn = obstacleSpawnRate + Math.random() * 30 - 15;
}
// Spawn power-ups
nextPowerupSpawn--;
if (nextPowerupSpawn <= 0) {
spawnPowerUp();
nextPowerupSpawn = powerupSpawnRate + Math.random() * 100 - 50;
}
// Update obstacles
updateObstacles();
// Update power-ups
updatePowerUps();
}; ===================================================================
--- original.js
+++ change.js
@@ -56,15 +56,16 @@
}
};
return self;
});
-var PowerUp = Container.expand(function () {
+var PowerUp = Container.expand(function (type) {
var self = Container.call(this);
- var powerupGraphics = self.attachAsset('powerup', {
+ self.type = type || 'speed';
+ var assetId = self.type === 'ghost' ? 'ghostpowerup' : 'powerup';
+ var powerupGraphics = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5
});
- self.type = 'speed';
self.speed = gameSpeed;
self.update = function () {
self.x -= self.speed;
// Add floating animation
@@ -96,8 +97,10 @@
var nextPowerupSpawn = powerupSpawnRate;
var speedBoostActive = false;
var speedBoostEndTime = 0;
var originalSpeed = gameSpeed;
+var ghostModeActive = false;
+var ghostModeEndTime = 0;
// Create ground
var ground = game.addChild(new Ground());
ground.x = 0;
ground.y = 2732 - 150;
@@ -128,9 +131,10 @@
obstacles.push(obstacle);
game.addChild(obstacle);
}
function spawnPowerUp() {
- var powerup = new PowerUp();
+ var powerupType = Math.random() < 0.5 ? 'speed' : 'ghost';
+ var powerup = new PowerUp(powerupType);
powerup.x = 2048 + 80;
powerup.y = 2732 - 150 - 100 - Math.random() * 200;
powerups.push(powerup);
game.addChild(powerup);
@@ -145,9 +149,9 @@
obstacles.splice(i, 1);
continue;
}
// Check collision with player
- if (gameRunning && obstacle.intersects(player)) {
+ if (gameRunning && !ghostModeActive && obstacle.intersects(player)) {
gameRunning = false;
LK.getSound('collision').play();
LK.effects.flashScreen(0xFF0000, 1000);
LK.setScore(Math.floor(distance / 10));
@@ -171,8 +175,10 @@
// Check collision with player
if (gameRunning && powerup.intersects(player)) {
if (powerup.type === 'speed') {
activateSpeedBoost();
+ } else if (powerup.type === 'ghost') {
+ activateGhostMode();
}
LK.getSound('powerup').play();
LK.effects.flashObject(player, 0xFFD700, 500);
powerup.destroy();
@@ -190,8 +196,19 @@
}, {
duration: 200
});
}
+function activateGhostMode() {
+ ghostModeActive = true;
+ ghostModeEndTime = LK.ticks + 300; // 5 seconds at 60 FPS
+ // Tween player to semi-transparent blue to indicate ghost mode
+ tween(player, {
+ tint: 0x0099FF,
+ alpha: 0.6
+ }, {
+ duration: 200
+ });
+}
function updateSpeedBoost() {
if (speedBoostActive && LK.ticks >= speedBoostEndTime) {
speedBoostActive = false;
gameSpeed = originalSpeed;
@@ -202,8 +219,20 @@
duration: 200
});
}
}
+function updateGhostMode() {
+ if (ghostModeActive && LK.ticks >= ghostModeEndTime) {
+ ghostModeActive = false;
+ // Tween player back to normal appearance
+ tween(player, {
+ tint: 0xFFFFFF,
+ alpha: 1.0
+ }, {
+ duration: 200
+ });
+ }
+}
function updateGameSpeed() {
if (!speedBoostActive && gameSpeed < maxSpeed) {
gameSpeed += speedIncrement;
originalSpeed = gameSpeed;
@@ -231,8 +260,10 @@
updateDistance();
updateGameSpeed();
// Update speed boost
updateSpeedBoost();
+ // Update ghost mode
+ updateGhostMode();
// Spawn obstacles
nextObstacleSpawn--;
if (nextObstacleSpawn <= 0) {
spawnObstacle();
a cactus plant. In-Game asset. 2d. High contrast. No shadows
a long desert sand platform. In-Game asset. 2d. High contrast. No shadows
an adventure character. In-Game asset. 2d. High contrast. No shadows
create a power up coin. In-Game asset. 2d. High contrast. No shadows
Money Bill. In-Game asset. 2d. High contrast. No shadows