User prompt
replace background2's code to match exactly background
User prompt
replace backgrounds2 code so it matches background
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'parallax.bgGraphics2.x = parallax.bgGraphics.x + parallax.bgGraphics.width - 5; // Increase overlap to 5 pixels to prevent visible seams' Line Number: 390
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'bgGraphics2')' in or related to this line: 'if (self.bgGraphics2.x <= -self.bgGraphics2.width / 2) {' Line Number: 461
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'bgGraphics2')' in or related to this line: 'if (self.bgGraphics2.x <= -self.bgGraphics2.width / 2) {' Line Number: 461
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'bgGraphics2')' in or related to this line: 'if (self.bgGraphics2.x <= -self.bgGraphics2.width / 2) {' Line Number: 460
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'bgGraphics2')' in or related to this line: 'if (self.bgGraphics2.x <= -self.bgGraphics2.width / 2) {' Line Number: 462
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'bgGraphics2')' in or related to this line: 'if (self.bgGraphics2.x <= -self.bgGraphics2.width / 2) {' Line Number: 458
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'bgGraphics2')' in or related to this line: 'if (!self.bgGraphics2) {' Line Number: 451
User prompt
there shouldn't be any logic difference between background and background2, delete all of background2's code and try again
User prompt
background2 doesn't tile fast enough
User prompt
the logic ofbackground2's seamless tiling does not work, restart it
User prompt
fix background2 so it loops seamlessly
User prompt
background2 doesn't loop at all, fix it
User prompt
make sure background and background2's logic are exactly the same
User prompt
background2's looping logic should be similar to background
User prompt
fix it
User prompt
background2 does not loop correctly,
User prompt
background should appear above background2
User prompt
background2 should always appear behind background
Code edit (1 edits merged)
Please save this source code
User prompt
move bootext a bit to the left
User prompt
instantiate background2 before boottext
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'if (self.y >= targetY && self.x >= targetX && parallax.bgGraphics3.x > 0) {' Line Number: 110
User prompt
do not start the game unless background2 is visible on screen
/****
* Classes
****/
var BootText = Container.expand(function (text) {
var self = Container.call(this);
var bootText = self.addChild(new Text2(text, {
size: 100,
fill: "#FFFFFF",
fontWeight: 'bolder',
stroke: "#000000",
// Black outline
strokeThickness: 5 // Thickness of the outline
}));
bootText.anchor.set(0.5, 0);
self.alpha = 0;
self.fadeIn = function () {
if (self.alpha < 1) {
self.alpha += 0.05;
}
};
self.fadeOut = function () {
if (self.alpha > 0) {
self.alpha -= 0.05;
} else {
self.destroy();
}
};
});
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -3;
self._move_migrated = function () {};
});
var Hero = Container.expand(function () {
var self = Container.call(this);
self.createDashTrail = function () {
var trailCount = 10;
var flashDuration = 50; // Duration for each flash
for (var i = 0; i < trailCount; i++) {
LK.setTimeout(function () {
var trailParticle = new Particle();
trailParticle.x = self.x;
trailParticle.y = self.y;
game.addChild(trailParticle);
var neonColors = [0x39ff14, 0xff073a, 0x00ffff, 0xffff00, 0xff00ff];
var randomColor = neonColors[Math.floor(Math.random() * neonColors.length)];
LK.effects.flashObject(trailParticle, randomColor, flashDuration);
}, i * 50);
}
};
var heroGraphics = self.attachAsset('hero', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 30;
// Initialize jetfuel in the center of hero
var jetfuel = self.attachAsset('jetfuel', {
anchorX: 0.5,
anchorY: 0.5
});
jetfuel.x = -50;
jetfuel.y = 50;
self.addChildAt(jetfuel, 0);
// Set interval to flip jetfuel's visual on the x alignment every 0.5 seconds
LK.setInterval(function () {
jetfuel.scale.x *= -1;
}, 250);
self.dashSpeed = game.width / 2 / 30; // 1/2 of the screen over 0.5 seconds at 60FPS
self.dashBackSpeed = self.dashSpeed / 2; // Accelerated return at half of the dash speed
self.dashStartTime = 0; // Time when the dash started
self.gravity = 1;
self.isDashing = false;
self.initialX = 200;
self.animateToPosition = function () {
var targetY = Math.max(2732 / 2, 300);
var targetX = self.initialX;
var animationSpeed = 10;
if (!self.animationStarted) {
self.animationDelay = LK.setTimeout(function () {
self.animationStarted = true;
}, 3000);
self.animationStarted = false;
}
if (self.animationStarted) {
if (self.y < targetY) {
self.y += animationSpeed;
}
if (self.x < targetX) {
self.x += animationSpeed;
}
if (self.y >= targetY && self.x >= targetX && parallax.bgGraphics3.x > 0) {
gameStarted = true; // Start the game once the hero reaches the initial position and background2 is visible
initializeScoreDisplay();
startObstacleGeneration();
}
}
};
self.dash = function () {
if (!self.isDashing && LK.ticks - self.holdStartTime >= 60 && self.x === self.initialX && !self.isDashing) {
self.isDashing = true;
self.dashStartTime = LK.ticks; // Save the start time of the dash
self.savedX = self.x; // Save the current x position
self.dashTargetX = self.x + game.width / 3 * 2; // Set the target X position for the dash, now twice as long
// Apply dash effect
self.createDashTrail();
self.stopFlashing();
}
};
self.isGravityFlipped = false;
self.flipGravity = function () {
if (!self.isDashing) {
self.isGravityFlipped = !self.isGravityFlipped;
self.gravity *= -1;
}
};
self._move_migrated = function () {
if (self.isHolding && LK.ticks - self.holdStartTime >= 60 && LK.ticks - self.dashStartTime > 6) {
self.dash();
}
if (self.isDashing) {
if (self.x < self.dashTargetX) {
self.x += self.dashSpeed;
// Check for collision with obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
if (self.intersects(obstacles[i])) {
obstacles[i].destroy();
obstacles.splice(i, 1);
}
}
} else {
self.isDashing = false;
self.dashTargetX = null; // Clear the dash target position
// Remove dash effect
self.tint = 0xffffff;
}
}
// Gradually move back to the initial position after dashing
// Resume normal movement after reaching saved x position
if (!self.isDashing && self.dashTargetX === null && self.x !== self.savedX) {
var moveBack = self.savedX < self.x ? -self.dashBackSpeed : self.dashBackSpeed;
self.x += moveBack;
// Clamp the hero's x position to the savedX to prevent overshooting
if (Math.abs(self.x - self.savedX) < Math.abs(moveBack)) {
self.x = self.savedX;
}
}
// Stop vertical movement while holding down
if (!self.isHolding && !self.isDashing) {
self.y += self.speed * self.gravity;
var boundaryPadding = 300; // Adjust this value to set the top boundary padding
if (self.y < boundaryPadding) {
self.y = boundaryPadding;
}
if (self.y > game.height / 2 + 400) {
self.y = game.height / 2 + 400;
}
}
// Trigger game over if hero leaves the screen horizontally
if (self.x < 0 || self.x > game.width) {
isGameOver = true;
}
// Generate particle trail
if (LK.ticks % 5 == 0 && !self.isHolding) {
var particle = new Particle();
particle.x = self.x;
particle.y = self.y;
game.addChildAt(particle, 0);
}
};
self.isHolding = false;
self.holdStartTime = 0;
self.startFlashing = function () {
if (!self.flashInterval && !self.isDashing) {
self.flashInterval = LK.setInterval(function () {
self.scale.set(self.scale.x === 1 ? 1.5 : 1);
self.tint = self.tint === 0x0000ff ? 0x00ffff : 0x0000ff; // Transition between blue and cyan
}, 100); // Pulse every 100ms
}
};
self.stopFlashing = function () {
if (self.flashInterval) {
LK.clearInterval(self.flashInterval);
self.flashInterval = null;
self.visible = true; // Ensure hero is visible after stopping flash
self.tint = 0x9a3986; // Reset color to default
self.scale.set(1); // Reset scale to default
}
};
self.onHold = function () {
if (!self.isHolding && !self.isDashing && !self.isDashing) {
self.isHolding = true;
self.holdStartTime = LK.ticks;
self.startFlashing();
}
};
self.onRelease = function () {
if (self.isHolding && !self.isDashing) {
self.dash();
}
self.isHolding = false;
self.holdStartTime = 0;
self.stopFlashing();
};
});
var Hero_Ground = Container.expand(function () {
var self = Container.call(this);
var heroGroundGraphics = self.attachAsset('heroGround', {
anchorX: 0.5,
anchorY: 0.5
});
var heroGroundGraphicsB = self.attachAsset('heroGroundB', {
anchorX: 0.5,
anchorY: 0.5
});
heroGroundGraphicsB.visible = false;
self.addChild(heroGroundGraphicsB);
// Set interval to switch between heroGround and heroGroundB every 0.5 seconds
LK.setInterval(function () {
heroGroundGraphics.visible = !heroGroundGraphics.visible;
heroGroundGraphicsB.visible = !heroGroundGraphicsB.visible;
}, 250);
self.speed = 20;
self.gravity = 1;
self.isJumping = false;
self.jumpSpeed = -20;
self.initialY = 200;
self.jump = function () {
if (!self.isJumping) {
self.isJumping = true;
self.y += self.jumpSpeed;
}
};
self._move_migrated = function () {
if (self.isJumping) {
self.y += self.gravity;
if (self.y >= self.initialY) {
self.y = self.initialY;
self.isJumping = false;
}
}
};
});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -5;
self._move_migrated = function () {
self.x += self.speed;
if (self.x < -self.width) {
self.destroy();
}
};
});
var Parallax = Container.expand(function () {
var self = Container.call(this);
var bgGraphics = self.attachAsset('background', {
anchorX: 0.5,
anchorY: 0.5
});
bgGraphics.x = game.width / 2;
bgGraphics.y = game.height - bgGraphics.height / 2;
self.speed = -3;
self._move_migrated = function () {
bgGraphics.x += self.speed;
if (bgGraphics.x <= -bgGraphics.width / 2) {
bgGraphics.x = self.bgGraphics2.x + bgGraphics.width - 5; // Increase overlap to 5 pixels to prevent visible seams
}
if (!self.bgGraphics2) {
self.bgGraphics2 = self.attachAsset('background', {
anchorX: 0.5,
anchorY: 0.5
});
self.bgGraphics2.x = bgGraphics.x + bgGraphics.width - 5; // Increase overlap to 5 pixels to prevent visible seams
self.bgGraphics2.y = game.height - self.bgGraphics2.height / 2;
self.addChildAt(self.bgGraphics2, 0); // Ensure bgGraphics2 is behind bgGraphics
} else if (self.bgGraphics2.x <= -self.bgGraphics2.width / 2) {
self.bgGraphics2.x = bgGraphics.x + bgGraphics.width - 5; // Increase overlap to 5 pixels to prevent visible seams
}
self.bgGraphics2.x += self.speed;
// Instantiate and position background2
if (!self.bgGraphics3) {
self.bgGraphics3 = self.attachAsset('background2', {
anchorX: 0.5,
anchorY: 0.5
});
self.bgGraphics3.x = game.width; // Ensure background2 is initially positioned to be visible on screen
self.bgGraphics3.y = game.height / 2; // Center background2 vertically
self.addChildAt(self.bgGraphics3, 0); // Ensure bgGraphics3 is behind bgGraphics
} else if (self.bgGraphics3.x <= -self.bgGraphics3.width / 2) {
self.bgGraphics3.x = game.width / 2; // Ensure seamless looping
if (self.bgGraphics3.x <= -self.bgGraphics3.width / 2) {
self.bgGraphics3.x = self.bgGraphics2.x + self.bgGraphics2.width - 5; // Ensure seamless looping
}
}
self.bgGraphics3.x += self.speed;
};
});
var Particle = Container.expand(function () {
var self = Container.call(this);
var particleGraphics = self.attachAsset('particle', {
anchorX: 0.5,
anchorY: 0.5
});
var neonColors = [0x39ff14, 0xff073a, 0x00ffff, 0xffff00, 0xff00ff];
particleGraphics.tint = neonColors[Math.floor(Math.random() * neonColors.length)];
self.alpha = 1.0;
self.fadeOut = function () {
self.alpha -= 0.05;
if (self.alpha <= 0) {
self.destroy();
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
function startBootSequence() {
var bootTexts = ['Calibrating Cybernetic Enhancements...', 'Booting Cybernetic Core Systems...', 'All systems ready...'];
var currentBootTextIndex = 0;
var bootTextY = game.height / 2 - 100;
var displayBootText = function displayBootText() {
var bootText = new BootText(bootTexts[currentBootTextIndex]);
bootText.x = game.width / 2 + 175;
bootText.y = bootTextY + currentBootTextIndex * 120;
game.addChild(bootText);
LK.setInterval(function () {
bootText.fadeIn();
if (bootText.alpha === 1) {
LK.setTimeout(function () {
bootText.fadeOut();
}, 300);
}
}, 60);
currentBootTextIndex++;
if (currentBootTextIndex < bootTexts.length) {
LK.setTimeout(displayBootText, 1000);
}
};
displayBootText();
}
var hero,
enemies = [],
obstacles = [],
parallax,
score = 0,
distanceTraveled = 0,
isGameOver = false,
gameStarted = false;
var generateObstacle = function generateObstacle() {
var obstacle = new Obstacle();
obstacle.x = game.width;
var heroYMin = Math.max(hero.y - 200, 300); // Adjust this value to set the minimum Y reach of the hero
var heroYMax = hero.y + 200; // Adjust this value to set the maximum Y reach of the hero
obstacle.y = heroYMin + Math.random() * (heroYMax - heroYMin);
obstacles.push(obstacle);
game.addChild(obstacle);
};
var obstacleGenerationInterval;
function startObstacleGeneration() {
obstacleGenerationInterval = LK.setInterval(generateObstacle, 2000);
}
parallax = game.addChild(new Parallax());
var distanceTxt;
function initializeScoreDisplay() {
// Remove BootText from the screen
var bootTexts = game.children.filter(function (child) {
return child instanceof BootText;
});
for (var i = 0; i < bootTexts.length; i++) {
bootTexts[i].destroy();
}
// Initialize score display
distanceTxt = new Text2('Distance: 0', {
size: 75,
// Reduced size
fill: "#ffffff",
stroke: "#000000",
// Black outline
strokeThickness: 5 // Thickness of the outline
});
distanceTxt.anchor.set(.5, 0);
LK.gui.top.addChild(distanceTxt);
}
hero = game.addChild(new Hero());
var heroGround = game.addChild(new Hero_Ground());
heroGround.x = hero.x + 175;
heroGround.y = game.height - heroGround.height / 2 - 100;
hero.x = -100;
hero.y = -100;
startBootSequence();
LK.on('tick', function () {
if (!gameStarted) {
hero.animateToPosition();
return; // Skip the rest of the game logic until the animation is complete
}
parallax._move_migrated();
if (hero.visible) {
hero._move_migrated();
} else if (heroGround.visible) {
heroGround._move_migrated();
}
for (var i = 0; i < enemies.length; i++) {
enemies[i]._move_migrated();
}
for (var i = obstacles.length - 1; i >= 0; i--) {
obstacles[i]._move_migrated();
if (!obstacles[i].parent) {
obstacles.splice(i, 1);
}
}
var particles = game.children.filter(function (child) {
return child instanceof Particle;
});
for (var i = 0; i < particles.length; i++) {
particles[i].fadeOut();
}
if (!isGameOver) {
distanceTraveled += 1 / 60;
distanceTxt.setText('Distance: ' + Math.floor(distanceTraveled).toString());
}
if (isGameOver) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
});
game.on('down', function (x, y, obj) {
if (hero.visible) {
hero.flipGravity();
hero.onHold();
} else if (heroGround.visible) {
heroGround.jump();
}
});
game.on('up', function (x, y, obj) {
hero.onRelease();
});
2d cyberpunk particle of a dash ability. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
blue jetfuel. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art speech bubble that says "?" neon color. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art speech bubble that says "Go" neon color. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art speech bubble that says "Ok" neon color.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a bubble a wing inside in neon color.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art bubble with 2 fast foward arrows neon color. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Gray Cyber neon lit logo of the word Rush. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
side profile of a flying car in the art style of a 16 bit neon cyberpunk game. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
retro cyberpunk datadisk in neon colors. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
retro cyberpunk pole flag in neon colors with the words 'events' on it.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
retro sign that says "Hold to Dash" in neon colors. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
retro sign that says "Tap to Move" in neon colors.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
retro sign that says "catch" with an flying drone symbol in neon colors.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
retro flying drone in neon colors.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
retro sign that says "Survive" with an face symbol in neon colors... Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
neon colored cyberpunk round electricity. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
SynthwaveMusic
Music
snd_letsgo
Sound effect
snd_announcer
Sound effect
snd_powerup
Sound effect
snd_dataacquire
Sound effect
snd_walkie
Sound effect
snd_nice
Sound effect
snd_carhonk
Sound effect
snd_enemy
Sound effect
snd_sphere
Sound effect
snd_windup
Sound effect
snd_spikey
Sound effect
snd_drone
Sound effect