User prompt
**Bottom Boundary**: 400 pixels below the vertical center of the game screen. to 800
User prompt
make sure none of them spawn near the bottom of the playspace and or near hero_ground
User prompt
nsures it does not spawn too close to other objects (at least 600 pixels apart) as long as it Spawns within the hero's vertical game boundaries:
User prompt
apply that to the spawning rules of objaccelerate,objgo,objrally and objfly
User prompt
ensure they stay within the heros vertical game boundaries but dont spawn them relative to the heros position
User prompt
Ensures it does not spawn too close to objaccelerate, objgo, objrally and objjump
User prompt
Limited to 1 instances at a time.
User prompt
remove the minimum delay of 60 ticks
User prompt
when objaccelerate,objgo,objrally and objfly leaves the playspace destroy them
User prompt
objrush should fade in and fade out
User prompt
ObjAccelerate should spawn every 8 seconds ObjGO every 1.5 Seconds ObjRally every 2 seconds objfly every 2.5 seconds
User prompt
change objrush instantation frmo 3 to 4
User prompt
fade in and out objrush
User prompt
do it
User prompt
do it
User prompt
fix it
User prompt
fix it
User prompt
change the 3 second instantiation of objrush to 4 seconds
User prompt
the parralax speed should return to normal after 5 seconds
User prompt
change the 3 second instantiation of objrush to 5 seconds
User prompt
if hero destroys objaccelerate while distance travel is temporarily increased, reset the 5 seconds timer
User prompt
is it possible to add that for 5 seconds, there will not be a new objaccelerate that will spawn? if so do it
User prompt
when objaccelerate is destroyed, instantiate for three seconds in the center of the playspace objrush
User prompt
also temporarily accelerate the parallax speed by 5 fold
User prompt
also shake and flash the screen to simulate speed effect for 5 seconds
/****
* 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 EnemyBottomRight = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = game.width + 200;
self.y = game.height - 400;
self.alpha = 0;
self.fadeInInterval = LK.setInterval(function () {
self.alpha += 0.05;
if (self.alpha >= 1) {
LK.clearInterval(self.fadeInInterval);
}
}, 16); // Approximately 60 FPS
self.animate = function () {
var targetX = game.width - 100;
// animationSpeed is now defined in the global scope
self.animationInterval = LK.setInterval(function () {
if (self.x > targetX) {
self.x -= animationSpeed;
} else {
LK.clearInterval(self.animationInterval);
LK.setTimeout(function () {
self.reverseAnimation();
}, 10000); // Reverse after 10 seconds
}
}, 16); // Approximately 60 FPS
};
self.reverseAnimation = function () {
var startX = game.width + 200;
self.animationInterval = LK.setInterval(function () {
if (self.x < startX) {
self.x += animationSpeed;
} else {
LK.clearInterval(self.animationInterval);
self.fadeOutInterval = LK.setInterval(function () {
self.alpha -= 0.05;
if (self.alpha <= 0) {
LK.clearInterval(self.fadeOutInterval);
self.visible = false;
}
}, 16); // Approximately 60 FPS
}
}, 16); // Approximately 60 FPS
};
});
var EnemyMiddleRight = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = game.width + 200;
self.y = game.height / 2;
self.alpha = 0;
self.fadeInInterval = LK.setInterval(function () {
self.alpha += 0.05;
if (self.alpha >= 1) {
LK.clearInterval(self.fadeInInterval);
}
}, 16); // Approximately 60 FPS
self.animate = function () {
var targetX = game.width - 100;
// animationSpeed is now defined in the global scope
self.animationInterval = LK.setInterval(function () {
if (self.x > targetX) {
self.x -= animationSpeed;
} else {
LK.clearInterval(self.animationInterval);
LK.setTimeout(function () {
self.reverseAnimation();
}, 10000); // Reverse after 10 seconds
}
}, 16); // Approximately 60 FPS
};
self.reverseAnimation = function () {
var startX = game.width + 200;
self.animationInterval = LK.setInterval(function () {
if (self.x < startX) {
self.x += animationSpeed;
} else {
LK.clearInterval(self.animationInterval);
self.fadeOutInterval = LK.setInterval(function () {
self.alpha -= 0.05;
if (self.alpha <= 0) {
LK.clearInterval(self.fadeOutInterval);
self.visible = false;
}
}, 16); // Approximately 60 FPS
}
}, 16); // Approximately 60 FPS
};
});
var EnemyTopRight = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = game.width + 200;
self.y = 400;
self.alpha = 0;
self.fadeInInterval = LK.setInterval(function () {
self.alpha += 0.05;
if (self.alpha >= 1) {
LK.clearInterval(self.fadeInInterval);
}
}, 16); // Approximately 60 FPS
self.animate = function () {
var targetX = game.width - 100;
// animationSpeed is now defined in the global scope
self.animationInterval = LK.setInterval(function () {
if (self.x > targetX) {
self.x -= animationSpeed;
} else {
LK.clearInterval(self.animationInterval);
LK.setTimeout(function () {
self.reverseAnimation();
}, 10000); // Reverse after 10 seconds
}
}, 16); // Approximately 60 FPS
};
self.reverseAnimation = function () {
var startX = game.width + 200;
self.animationInterval = LK.setInterval(function () {
if (self.x < startX) {
self.x += animationSpeed;
} else {
LK.clearInterval(self.animationInterval);
self.fadeOutInterval = LK.setInterval(function () {
self.alpha -= 0.05;
if (self.alpha <= 0) {
LK.clearInterval(self.fadeOutInterval);
self.visible = false;
}
}, 16); // Approximately 60 FPS
}
}, 16); // Approximately 60 FPS
};
});
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
self.jetfuelInterval = LK.setInterval(function () {
jetfuel.scale.x *= -1;
}, 250);
self.on('destroy', function () {
LK.clearInterval(self.jetfuelInterval);
});
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) {
gameStarted = true; // Start the game once the hero reaches the initial position
initializeScoreDisplay();
startObstacleGeneration();
}
}
};
self.dash = function () {
if (!self.isDashing && LK.ticks - self.holdStartTime >= 60 && self.x === self.initialX) {
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])) {
var explosion = new ParticleExplosion(obstacles[i].x, obstacles[i].y);
game.addChild(explosion);
if (obstacles[i] instanceof ObjGO) {
heroGround.moveToCenterX();
var explosion = new ParticleExplosion(obstacles[i].x, obstacles[i].y);
game.addChild(explosion);
var explosion = new ParticleExplosion(obstacles[i].x, obstacles[i].y);
game.addChild(explosion);
handleCollisionWithObj(); // Call handleCollisionWithObj when colliding with ObjGO
} else if (obstacles[i] instanceof ObjRALLY) {
heroGround.moveToInitialPosition();
var initialHeroGroundX = heroGround.x;
var initialHeroGroundY = heroGround.y;
handleCollisionWithObj(); // Call handleCollisionWithObj when colliding with ObjRALLY
} else if (obstacles[i] instanceof ObjJUMP) {
brother();
handleCollisionWithObj(); // Call handleCollisionWithObj when colliding with ObjJUMP
if (heroGround.idleSpeechBubble) {
heroGround.idleSpeechBubble.visible = false;
LK.setTimeout(function () {
heroGround.idleSpeechBubble.visible = true;
}, 3000);
}
} else if (obstacles[i] instanceof ObjACCELERATE) {
var explosion = new ParticleExplosion(obstacles[i].x, obstacles[i].y);
game.addChild(explosion);
destroyAllObjs(); // Destroy all instances of ObjGO, ObjRALLY, and ObjJUMP
// Temporarily increase distanceTraveled increment
var originalIncrement = 1 / 60;
var acceleratedIncrement = 1 / 15;
distanceTraveledIncrement = acceleratedIncrement;
// Add screen shake and flash effect
var shakeAmplitude = 10;
var shakeDuration = 100;
var originalX = game.x;
var originalY = game.y;
var shakeInterval = LK.setInterval(function () {
game.x = originalX + (Math.random() - 0.5) * shakeAmplitude;
game.y = originalY + (Math.random() - 0.5) * shakeAmplitude;
}, shakeDuration);
LK.effects.flashScreen(0xffffff, 5000); // Flash screen for 5 seconds
LK.setTimeout(function () {
distanceTraveledIncrement = originalIncrement;
LK.clearInterval(shakeInterval);
game.x = originalX;
game.y = originalY;
}, 5000); // Reset to normal after 5 seconds
}
if (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;
}
}
// Removed game over condition when hero leaves the screen horizontally
// 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
self.heroGroundInterval = LK.setInterval(function () {
heroGroundGraphics.visible = !heroGroundGraphics.visible;
heroGroundGraphicsB.visible = !heroGroundGraphicsB.visible;
}, 250);
self.on('destroy', function () {
LK.clearInterval(self.heroGroundInterval);
if (self.interpolationInterval) {
LK.clearInterval(self.interpolationInterval);
}
});
self.speed = 20;
self.gravity = 1;
self.isJumping = false;
self.jumpSpeed = -20;
self.jumpVelocity = 0;
self.initialY = 200;
self._update_migrated = function () {
if (self.isJumping) {
self.y += self.jumpSpeed;
self.jumpSpeed += self.gravity;
}
if (self.y > game.floorLevel) {
self.y = game.floorLevel;
self.isJumping = false;
}
};
self.moveToCenterX = function () {
if (self.isMovingToCenter || self.isMovingToInitial) {
return;
} // Prevent multiple calls
self.isMovingToCenter = true; // Set flag to indicate movement in progress
isHeroGroundMoving = true;
var targetX = game.width / 2;
var interpolationSpeed = 10; // Adjust this value to control the speed of interpolation
self.interpolationInterval = LK.setInterval(function () {
if (Math.abs(self.x - targetX) < interpolationSpeed) {
self.x = targetX;
LK.clearInterval(self.interpolationInterval);
self.isMovingToCenter = false; // Reset flag when movement is complete
isHeroGroundMoving = false;
// Replace movingSpeechBubble with idleSpeechBubble
if (self.movingSpeechBubble) {
self.movingSpeechBubble.destroy();
self.movingSpeechBubble = null;
}
self.idleSpeechBubble = LK.getAsset('idleSpeechBubble', {
anchorX: 0.5,
anchorY: 0.5
});
self.addChild(self.idleSpeechBubble);
self.idleSpeechBubble.x = self.width / 2 - 20;
self.idleSpeechBubble.y = -self.idleSpeechBubble.height / 2 - 125;
} else {
self.x += self.x < targetX ? interpolationSpeed : -interpolationSpeed;
}
}, 16); // Approximately 60 FPS
// Replace idleSpeechBubble with movingSpeechBubble
if (self.idleSpeechBubble) {
self.idleSpeechBubble.destroy();
self.idleSpeechBubble = null;
}
// Ensure only one moving speech bubble is active at a time
if (game.activeMovingSpeechBubble) {
game.activeMovingSpeechBubble.destroy();
}
self.movingSpeechBubble = LK.getAsset('movingSpeechBubble', {
anchorX: 0.5,
anchorY: 0.5
});
self.addChild(self.movingSpeechBubble);
self.movingSpeechBubble.x = self.width / 2 + 10;
self.movingSpeechBubble.y = -self.movingSpeechBubble.height / 2 - 125;
game.activeMovingSpeechBubble = self.movingSpeechBubble;
};
self._move_migrated = function () {
if (self.isJumping) {
self.y += self.jumpVelocity;
self.jumpVelocity += self.gravity;
if (self.y >= self.initialY) {
self.y = self.initialY;
self.isJumping = false;
}
} else {
self.y += self.gravity;
if (self.y > game.height - self.height / 2) {
self.y = game.height - self.height / 2;
}
}
};
self.moveToInitialPosition = function () {
if (self.isMovingToInitial || self.isMovingToCenter) {
return;
} // Prevent multiple calls
var targetX = heroGround.initialX;
if (Math.abs(self.x - targetX) < interpolationSpeed) {
return; // Already at the initial position, do nothing
}
self.isMovingToInitial = true; // Set flag to indicate movement in progress
isHeroGroundMoving = true;
var interpolationSpeed = 10; // Adjust this value to control the speed of interpolation
self.interpolationInterval = LK.setInterval(function () {
if (Math.abs(self.x - targetX) < interpolationSpeed) {
self.x = targetX;
LK.clearInterval(self.interpolationInterval);
self.isMovingToInitial = false; // Reset flag when movement is complete
isHeroGroundMoving = false;
// Replace movingSpeechBubble with idleSpeechBubble
if (self.movingSpeechBubble) {
self.movingSpeechBubble.destroy();
self.movingSpeechBubble = null;
}
self.idleSpeechBubble = LK.getAsset('idleSpeechBubble', {
anchorX: 0.5,
anchorY: 0.5
});
self.addChild(self.idleSpeechBubble);
self.idleSpeechBubble.x = self.width / 2 - 20;
self.idleSpeechBubble.y = -self.idleSpeechBubble.height / 2 - 125;
} else {
self.x += self.x < targetX ? interpolationSpeed : -interpolationSpeed;
}
}, 16); // Approximately 60 FPS
// Replace idleSpeechBubble with movingSpeechBubble
if (self.idleSpeechBubble) {
self.idleSpeechBubble.destroy();
self.idleSpeechBubble = null;
}
// Ensure only one moving speech bubble is active at a time
if (game.activeMovingSpeechBubble) {
game.activeMovingSpeechBubble.destroy();
}
self.movingSpeechBubble = LK.getAsset('movingSpeechBubble', {
anchorX: 0.5,
anchorY: 0.5
});
self.addChild(self.movingSpeechBubble);
self.movingSpeechBubble.x = self.width / 2 + 10;
self.movingSpeechBubble.y = -self.movingSpeechBubble.height / 2 - 125;
game.activeMovingSpeechBubble = self.movingSpeechBubble;
};
});
var ObjACCELERATE = Container.expand(function () {
var self = Container.call(this);
var objACCELERATEGraphics = self.attachAsset('objAccelerate', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -5;
self._move_migrated = function () {
self.x += self.speed;
if (self.x < -self.width) {
self.x = game.width;
var heroYMin = Math.max(hero.y - hero.height / 2, 0);
var heroYMax = Math.min(hero.y + hero.height / 2, game.height);
self.y = heroYMin + Math.random() * (heroYMax - heroYMin);
}
self.y += Math.sin(LK.ticks / 10) * 2;
};
});
var ObjGO = Container.expand(function () {
var self = Container.call(this);
var objGOGraphics = self.attachAsset('objGO', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -5;
self.spawnTime = LK.ticks;
self.spawnTime = LK.ticks;
self.spawnTime = LK.ticks;
self.spawnTime = LK.ticks;
self._move_migrated = function () {
self.x += self.speed;
if (self.x < -self.width) {
self.x = game.width;
var heroYMin = Math.max(hero.y - hero.height / 2, 0);
var heroYMax = Math.min(hero.y + hero.height / 2, game.height);
self.y = heroYMin + Math.random() * (heroYMax - heroYMin);
return;
return;
return;
}
// Add hover effect
self.y += Math.sin(LK.ticks / 10) * 2;
};
});
var ObjJUMP = Container.expand(function () {
var self = Container.call(this);
var objJUMPGraphics = self.attachAsset('objJUMP', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -5;
self._move_migrated = function () {
self.x += self.speed;
if (self.x < -self.width) {
self.x = game.width;
var heroYMin = Math.max(hero.y - hero.height / 2, 0);
var heroYMax = Math.min(hero.y + hero.height / 2, game.height);
self.y = heroYMin + Math.random() * (heroYMax - heroYMin);
}
// Add hover effect
self.y += Math.sin(LK.ticks / 10) * 2;
};
});
var ObjRALLY = Container.expand(function () {
var self = Container.call(this);
var objRALLYGraphics = self.attachAsset('objRALLY', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -5;
self._move_migrated = function () {
self.x += self.speed;
if (self.x < -self.width) {
self.x = game.width;
var heroYMin = Math.max(hero.y - hero.height / 2, 0);
var heroYMax = Math.min(hero.y + hero.height / 2, game.height);
self.y = heroYMin + Math.random() * (heroYMax - heroYMin);
}
// Add hover effect
self.y += Math.sin(LK.ticks / 10) * 2;
};
});
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.x = game.width;
var heroYMin = Math.max(hero.y - hero.height / 2, 0);
var heroYMax = Math.min(hero.y + hero.height / 2, game.height);
self.y = heroYMin + Math.random() * (heroYMax - heroYMin);
}
};
});
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 (!self.bgGraphics2) {
self.bgGraphics2 = self.attachAsset('background', {
anchorX: 0.5,
anchorY: 0.5
});
self.bgGraphics2.x = bgGraphics.x + bgGraphics.width;
self.bgGraphics2.y = game.height - self.bgGraphics2.height / 2;
self.addChildAt(self.bgGraphics2, 1); // Ensure bgGraphics2 is behind bgGraphics
}
self.bgGraphics2.x += self.speed;
if (bgGraphics.x <= -bgGraphics.width / 2) {
bgGraphics.x = self.bgGraphics2.x + bgGraphics.width;
}
if (self.bgGraphics2.x <= -self.bgGraphics2.width / 2) {
self.bgGraphics2.x = bgGraphics.x + bgGraphics.width;
}
};
});
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) {
if (self) {
self.destroy();
}
}
};
});
var Particle2 = Container.expand(function () {
var self = Container.call(this);
var particleGraphics = self.attachAsset('particle2', {
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) {
if (self) {
self.destroy();
}
}
};
});
var ParticleExplosion = Container.expand(function (x, y) {
var self = Container.call(this);
var particles = [];
var particleCount = 20;
var speedRange = 20; // Further increased speed range for more exaggerated movement
var neonColors = [0x39ff14, 0xff073a, 0x00ffff, 0xffff00, 0xff00ff];
for (var i = 0; i < particleCount; i++) {
var particle = new Particle2();
particle.x = x;
particle.y = y;
particle.vx = (Math.random() - 0.5) * speedRange;
particle.vy = (Math.random() - 0.5) * speedRange;
particle.rotationSpeed = (Math.random() - 0.5) * 0.2; // Further increased rotation speed for more exaggerated movement
particle.tint = neonColors[Math.floor(Math.random() * neonColors.length)];
particles.push(particle);
self.addChild(particle);
}
self.update = function () {
for (var i = particles.length - 1; i >= 0; i--) {
particles[i].x += particles[i].vx;
particles[i].y += particles[i].vy;
particles[i].rotation += particles[i].rotationSpeed; // Apply rotation
particles[i].alpha -= 0.02;
if (particles[i].alpha <= 0) {
if (particles[i]) {
particles[i].destroy();
particles.splice(i, 1);
}
}
}
if (particles.length === 0) {
self.destroy();
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
var generateObjACCELERATE = function generateObjACCELERATE() {
if (obstacles.filter(function (obstacle) {
return obstacle instanceof ObjACCELERATE;
}).length >= 2) {
return;
}
if (obstacles.length > 0) {
var lastObstacle = obstacles[obstacles.length - 1];
if (LK.ticks - lastObstacle.spawnTime < 60) {
return;
}
}
LK.setTimeout(function () {
var objACCELERATE = new ObjACCELERATE();
objACCELERATE.x = game.width;
var minY = 400;
var maxY = game.height / 2 + 200;
if (hero.x >= 0 && hero.x <= game.width) {
var heroYMin = Math.max(hero.y - hero.height / 2, minY);
var heroYMax = Math.min(hero.y + hero.height / 2, maxY);
var randomOffset = (Math.random() - 0.5) * hero.height * 2;
objACCELERATE.y = hero.y + randomOffset;
var objACCELERATEHalfHeight = objACCELERATE.height / 2;
objACCELERATE.y = Math.max(objACCELERATEHalfHeight, Math.min(game.height - objACCELERATEHalfHeight, objACCELERATE.y));
} else {
objACCELERATE.y = minY + Math.random() * (maxY - minY);
}
obstacles.push(objACCELERATE);
game.addChild(objACCELERATE);
}, 500 + Math.random() * 2000);
};
var isHeroGroundAttached = false;
var isHeroGroundMoving = false;
var collisionCounter = 0; // Initialize the collision counter
var brother = function brother() {
if (isHeroGroundAttached || isHeroGroundMoving) {
return;
}
isHeroGroundAttached = true;
heroGround.x = hero.x;
heroGround.y = hero.y + hero.height / 2 + heroGround.height / 2;
var originalX = heroGround.x;
var originalY = heroGround.y;
var attachInterval = LK.setInterval(function () {
heroGround.x = hero.x;
heroGround.y = hero.y + hero.height / 2 + heroGround.height / 2 - 200;
}, 16); // Update position every frame (approximately 60 FPS)
LK.setTimeout(function () {
LK.clearInterval(attachInterval);
heroGround.x = hero.x;
heroGround.y = game.height - heroGround.height / 2 - 100;
isHeroGroundAttached = false;
}, 3000); // Detach after 3 seconds
// Lower hero_ground a little bit after 3 seconds have elapsed
LK.setTimeout(function () {
heroGround.y += 50;
}, 3000);
};
// Function to handle collision and update the counter
function handleCollisionWithObj() {
collisionCounter += 1;
if (collisionCounter >= 1) {
destroyAllObjs();
}
}
// Function to destroy all instances of ObjGO, ObjRALLY, and ObjJUMP
function destroyAllObjs() {
for (var i = obstacles.length - 1; i >= 0; i--) {
if (obstacles[i] instanceof ObjGO || obstacles[i] instanceof ObjRALLY || obstacles[i] instanceof ObjJUMP || obstacles[i] instanceof ObjACCELERATE) {
if (obstacles[i]) {
var explosion = new ParticleExplosion(obstacles[i].x, obstacles[i].y);
game.addChild(explosion);
obstacles[i].destroy();
obstacles.splice(i, 1);
}
}
}
}
var generateObjJUMP = function generateObjJUMP() {
if (obstacles.filter(function (obstacle) {
return obstacle instanceof ObjJUMP;
}).length >= 1) {
return;
}
// Add delay to avoid two ObjJUMP spawning on top of each other
if (obstacles.length > 0) {
var lastObstacle = obstacles[obstacles.length - 1];
if (LK.ticks - lastObstacle.spawnTime < 60) {
return;
}
}
LK.setTimeout(function () {
var objJUMP = new ObjJUMP();
objJUMP.x = game.width;
var minY = 400; // Minimum Y position
var maxY = game.height / 2 + 200; // Maximum Y position
objJUMP.y = minY + Math.random() * (maxY - minY);
obstacles.push(objJUMP);
game.addChild(objJUMP);
}, 500 + Math.random() * 2000);
};
function startBootSequence() {
var bootTexts = ['Booting Core Systems...', 'Calibrating Enhancements...', 'All systems ready...', 'Begin Dash..!'];
var currentBootTextIndex = 0;
var bootTextY = game.height / 2 - 100;
var displayBootText = function displayBootText() {
var bootText = new BootText(bootTexts[currentBootTextIndex]);
bootText.x = game.width / 2 + 50;
bootText.y = bootTextY + currentBootTextIndex * 120;
game.addChild(bootText);
var fadeInInterval = LK.setInterval(function () {
bootText.fadeIn();
if (bootText.alpha === 1) {
LK.setTimeout(function () {
bootText.fadeOut();
}, 300);
}
}, 60);
bootText.on('destroy', function () {
LK.clearInterval(fadeInInterval);
});
currentBootTextIndex++;
if (currentBootTextIndex < bootTexts.length) {
LK.setTimeout(displayBootText, 1000);
}
};
displayBootText();
}
var activeMovingSpeechBubble = null,
enemies = [],
obstacles = [],
parallax,
score = 0,
distanceTraveled = 0,
distanceTraveledIncrement = 1 / 60,
isGameOver = false,
gameStarted = false;
var generateObstacle = function generateObstacle() {
if (obstacles.filter(function (obstacle) {
return obstacle instanceof Obstacle;
}).length >= 1) {
return;
}
// Add delay to avoid two Obstacle spawning on top of each other
if (obstacles.length > 0) {
var lastObstacle = obstacles[obstacles.length - 1];
if (LK.ticks - lastObstacle.spawnTime < 60) {
return;
}
}
LK.setTimeout(function () {
var obstacle = new Obstacle();
obstacle.x = game.width;
var minY = 400; // Minimum Y position
var maxY = game.height / 2 + 200; // Maximum Y position
if (hero.x >= 0 && hero.x <= game.width) {
var heroYMin = Math.max(hero.y - hero.height / 2, minY); // Ensure obstacle spawns within the top boundary of the hero
var heroYMax = Math.min(hero.y + hero.height / 2, maxY); // Ensure obstacle spawns within the bottom boundary of the hero
var randomOffset = (Math.random() - 0.5) * hero.height * 2; // Augmented random offset within 2 times the hero's height
obstacle.y = hero.y + randomOffset;
// Ensure obstacle stays within the game boundaries
var obstacleHalfHeight = obstacle.height / 2;
obstacle.y = Math.max(obstacleHalfHeight, Math.min(game.height - obstacleHalfHeight, obstacle.y));
} else {
obstacle.y = minY + Math.random() * (maxY - minY); // Spawn obstacle anywhere within the boundaries if hero is off screen
}
obstacles.push(obstacle);
game.addChild(obstacle);
}, 500 + Math.random() * 2000);
};
var generateObjGO = function generateObjGO() {
if (obstacles.filter(function (obstacle) {
return obstacle instanceof ObjGO;
}).length >= 2) {
return;
}
// Add delay to avoid two ObjGO spawning on top of each other
if (obstacles.length > 0) {
var lastObstacle = obstacles[obstacles.length - 1];
if (LK.ticks - lastObstacle.spawnTime < 60) {
return;
}
}
LK.setTimeout(function () {
var objGO = new ObjGO();
objGO.x = game.width;
var minY = 400; // Minimum Y position
var maxY = game.height / 2 + 200; // Maximum Y position
if (hero.x >= 0 && hero.x <= game.width) {
var heroYMin = Math.max(hero.y - hero.height / 2, minY); // Ensure objGO spawns within the top boundary of the hero
var heroYMax = Math.min(hero.y + hero.height / 2, maxY); // Ensure objGO spawns within the bottom boundary of the hero
var randomOffset = (Math.random() - 0.5) * hero.height * 2; // Augmented random offset within 2 times the hero's height
objGO.y = hero.y + randomOffset;
// Ensure objGO stays within the game boundaries
var objGOHalfHeight = objGO.height / 2;
objGO.y = Math.max(objGOHalfHeight, Math.min(game.height - objGOHalfHeight, objGO.y));
} else {
objGO.y = minY + Math.random() * (maxY - minY); // Spawn objGO anywhere within the boundaries if hero is off screen
}
// Ensure objGO does not spawn too close to objRALLY
if (obstacles.length > 0) {
var lastObstacle = obstacles[obstacles.length - 1];
if (lastObstacle instanceof ObjRALLY && Math.abs(lastObstacle.x - objGO.x) < 600) {
objGO.x = lastObstacle.x + 600;
}
}
obstacles.push(objGO);
game.addChild(objGO);
}, 500 + Math.random() * 2000);
};
var generateObjJUMP = function generateObjJUMP() {
if (obstacles.filter(function (obstacle) {
return obstacle instanceof ObjJUMP;
}).length >= 1) {
return;
}
var objJUMP = new ObjJUMP();
objJUMP.x = game.width;
objJUMP.y = Math.random() * game.height;
obstacles.push(objJUMP);
game.addChild(objJUMP);
};
var generateObjRALLY = function generateObjRALLY() {
if (obstacles.filter(function (obstacle) {
return obstacle instanceof ObjRALLY;
}).length >= 2) {
return;
}
// Add delay to avoid two ObjRALLY spawning on top of each other
if (obstacles.length > 0) {
var lastObstacle = obstacles[obstacles.length - 1];
if (LK.ticks - lastObstacle.spawnTime < 60) {
return;
}
}
LK.setTimeout(function () {
var objRALLY = new ObjRALLY();
objRALLY.x = game.width;
var minY = 400; // Minimum Y position
var maxY = game.height / 2 + 200; // Maximum Y position
if (hero.x >= 0 && hero.x <= game.width) {
var heroYMin = Math.max(hero.y - hero.height / 2, minY); // Ensure objRALLY spawns within the top boundary of the hero
var heroYMax = Math.min(hero.y + hero.height / 2, maxY); // Ensure objRALLY spawns within the bottom boundary of the hero
var randomOffset = (Math.random() - 0.5) * hero.height * 2; // Augmented random offset within 2 times the hero's height
objRALLY.y = hero.y + randomOffset;
// Ensure objRALLY stays within the game boundaries
var objRALLYHalfHeight = objRALLY.height / 2;
objRALLY.y = Math.max(objRALLYHalfHeight, Math.min(game.height - objRALLYHalfHeight, objRALLY.y));
} else {
objRALLY.y = minY + Math.random() * (maxY - minY); // Spawn objRALLY anywhere within the boundaries if hero is off screen
}
// Ensure objRALLY does not spawn too close to objGO
if (obstacles.length > 0) {
var lastObstacle = obstacles[obstacles.length - 1];
if (lastObstacle instanceof ObjGO && Math.abs(lastObstacle.x - objRALLY.x) < 600) {
objRALLY.x = lastObstacle.x + 600;
}
}
obstacles.push(objRALLY);
game.addChild(objRALLY);
}, 500 + Math.random() * 2000);
};
var obstacleGenerationInterval;
function startObstacleGeneration() {
obstacleGenerationInterval = LK.setInterval(generateObstacle, 2000);
var objGOGenerationInterval = LK.setInterval(generateObjGO, 2000);
var objRALLYGenerationInterval = LK.setInterval(generateObjRALLY, 2000);
var objJUMPGenerationInterval = LK.setInterval(generateObjJUMP, 2000);
var objACCELERATEGenerationInterval = LK.setInterval(generateObjACCELERATE, 2000);
var objJUMPGenerationInterval = LK.setInterval(generateObjJUMP, 2000);
LK.on('gameOver', function () {
LK.clearInterval(objJUMPGenerationInterval);
LK.clearInterval(obstacleGenerationInterval);
LK.clearInterval(objGOGenerationInterval);
LK.clearInterval(objRALLYGenerationInterval);
LK.clearInterval(objJUMPGenerationInterval);
LK.clearInterval(objACCELERATEGenerationInterval);
});
}
parallax = game.addChild(new Parallax());
var parallaxSpeedIncrement = 0.05; // Speed increment per second
var parallaxSpeedUpdateInterval = 500; // Update interval in milliseconds
LK.setInterval(function () {
parallax.speed -= parallaxSpeedIncrement;
}, parallaxSpeedUpdateInterval);
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());
var objGroundTrail = LK.getAsset('objGroundTrail', {
anchorX: 0.5,
anchorY: 0.5
});
heroGround.addChildAt(objGroundTrail, 0);
objGroundTrail.rotation = -Math.PI / 4; // Rotate 45 degrees to the left
objGroundTrail.x = heroGround.width / 2 - 200;
objGroundTrail.y = heroGround.height / 2 - 125;
// Add shake effect to objGroundTrail
var shakeAmplitude = 5; // Amplitude of the shake
var shakeDuration = 100; // Duration of each shake in milliseconds
var originalX = objGroundTrail.x;
var originalY = objGroundTrail.y;
var shakeInterval = LK.setInterval(function () {
objGroundTrail.x = originalX + (Math.random() - 0.5) * shakeAmplitude;
objGroundTrail.y = originalY + (Math.random() - 0.5) * shakeAmplitude;
}, shakeDuration);
heroGround.idleSpeechBubble = LK.getAsset('idleSpeechBubble', {
anchorX: 0.5,
anchorY: 0.5
});
heroGround.addChild(heroGround.idleSpeechBubble);
heroGround.idleSpeechBubble.x = heroGround.width / 2 + 20;
heroGround.idleSpeechBubble.y = -heroGround.idleSpeechBubble.height / 2 - 125;
heroGround.initialX = hero.x + 175;
heroGround.x = -heroGround.width;
heroGround.y = game.height - heroGround.height / 2 - 50;
hero.x = -100;
hero.y = -100;
startBootSequence();
LK.playMusic('SynthwaveMusic', {
loop: true
});
LK.setTimeout(function () {
heroGround.moveToInitialPosition();
}, 3000); // Start animation after 3 seconds
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();
// Removed collision detection between hero_ground and obstacles
}
var particles = game.children.filter(function (child) {
return child instanceof Particle;
});
for (var i = 0; i < particles.length; i++) {
if (particles[i] instanceof ParticleExplosion) {
particles[i].update();
} else {
particles[i].fadeOut();
}
}
if (!isGameOver) {
distanceTraveled += distanceTraveledIncrement;
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();
}
});
game.on('up', function (x, y, obj) {
hero.onRelease();
});
Hero_Ground.prototype.moveToInitialPosition = function () {
if (this.isMovingToInitial) {
return;
} // Prevent multiple calls
this.isMovingToInitial = true; // Set flag to indicate movement in progress
// Set initial position outside the play space
this.x = -this.width;
this.y = game.height - this.height / 2 - 100;
var targetX = hero.x + 175;
var interpolationSpeed = hero.speed; // Match hero's speed
this.interpolationInterval = LK.setInterval(function () {
if (Math.abs(this.x - targetX) < interpolationSpeed) {
this.x = targetX;
LK.clearInterval(this.interpolationInterval);
this.isMovingToInitial = false; // Reset flag when movement is complete
// Replace movingSpeechBubble with idleSpeechBubble
if (this.movingSpeechBubble) {
this.movingSpeechBubble.destroy();
this.movingSpeechBubble = null;
}
this.idleSpeechBubble = LK.getAsset('idleSpeechBubble', {
anchorX: 0.5,
anchorY: 0.5
});
this.addChild(this.idleSpeechBubble);
this.idleSpeechBubble.x = this.width / 2 - 20;
this.idleSpeechBubble.y = -this.idleSpeechBubble.height / 2 - 125;
} else {
this.x += this.x < targetX ? interpolationSpeed : -interpolationSpeed;
}
}.bind(this), 16); // Approximately 60 FPS
// Replace idleSpeechBubble with movingSpeechBubble
if (this.idleSpeechBubble) {
this.idleSpeechBubble.destroy();
this.idleSpeechBubble = null;
}
// Ensure only one moving speech bubble is active at a time
if (game.activeMovingSpeechBubble) {
game.activeMovingSpeechBubble.destroy();
}
this.movingSpeechBubble = LK.getAsset('movingSpeechBubble', {
anchorX: 0.5,
anchorY: 0.5
});
this.addChild(this.movingSpeechBubble);
this.movingSpeechBubble.x = this.width / 2 + 10;
this.movingSpeechBubble.y = -this.movingSpeechBubble.height / 2 - 125;
game.activeMovingSpeechBubble = this.movingSpeechBubble;
};
var animationSpeed = 2; // Define animationSpeed in the global scope
var enemyTopRight, enemyMiddleRight, enemyBottomRight;
var enemySpawnedCount = 0;
function selectAndAnimateEnemy() {
if (enemySpawnedCount === 0) {
enemyTopRight = new EnemyTopRight();
enemyMiddleRight = new EnemyMiddleRight();
enemyBottomRight = new EnemyBottomRight();
}
var enemies = [enemyTopRight, enemyMiddleRight, enemyBottomRight];
var selectedEnemies = [];
var randomChance = Math.random();
if (randomChance < 0.05) {
// 5% chance to spawn all three enemies
selectedEnemies = enemies;
} else if (randomChance < 0.25) {
// 20% chance to spawn two enemies
selectedEnemies = [enemies[enemySpawnedCount % enemies.length], enemies[(enemySpawnedCount + 1) % enemies.length]];
} else {
// Default to spawning one enemy
selectedEnemies = [enemies[enemySpawnedCount % enemies.length]];
}
selectedEnemies.forEach(function (enemy) {
game.addChild(enemy);
enemy.animate();
});
enemySpawnedCount += selectedEnemies.length;
LK.setTimeout(function () {
selectedEnemies.forEach(function (enemy) {
enemy.destroy();
});
if (enemySpawnedCount >= enemies.length) {
enemySpawnedCount = 0; // Reset the count to restart the sequence
}
}, 15000); // Destroy the enemies after 15 seconds
}
LK.setInterval(selectAndAnimateEnemy, 15000); // Call the function every 15 seconds;
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