User prompt
Cuando un ladrillo le cae al pollo y este tiene el power up le dará un vida extra al pollo (max-10) ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Cuando un cactus se rompe suelta partículas verdes como si fuera un explosión leve ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Que enves de que tengas triple salto por tiempo ilimitado lo trendas por 69 segundos(aparecerá cuando tiempo te queda en color verde abajo del botón de pausa) ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Agrega un cactus mas alto que los otro que solo aparece aleatoriamente una vez en la partida y inmediatamente que aparece en la pantalla el pollo puede hacer 3 saltos enves de 2 por tiempo ilimitado ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Que los ladrillos lo vaya tirando un avion(haz que el avión solo sea visual y no tenga una función como tal) ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Que la cámara vuelva a ser normal
User prompt
Que caiga un ladrillo del cielo cada 10 segundos ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Que la cámara este mucho más cerca del pollo
User prompt
Agregar un fondo de día, cuando el jugador llega a 100 puntos se hace de noche por 50 segundos ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Cuando la gallina salta cambia de imagen a "chicken jump"
Remix started
Copy Desert Dash Chicken
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Brick = Container.expand(function () {
var self = Container.call(this);
var brickGraphics = self.attachAsset('pauseButton', {
anchorX: 0.5,
anchorY: 0.5,
width: 80,
height: 40,
color: 0x8B4513
});
self.velocityY = 0;
self.gravity = 0.8;
self.hit = false;
self.update = function () {
self.velocityY += self.gravity;
self.y += self.velocityY;
};
return self;
});
var Cactus = Container.expand(function (type) {
var self = Container.call(this);
var assetName = type === 'tall' ? 'tallCactus' : 'smallCactus';
var cactusGraphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 1.0
});
self.type = type;
self.speed = gameSpeed;
self.passed = false;
self.update = function () {
self.x -= self.speed;
};
return self;
});
var Chicken = Container.expand(function () {
var self = Container.call(this);
var chickenGraphics = self.attachAsset('chicken', {
anchorX: 0.5,
anchorY: 1.0
});
self.groundY = 2732 - 200;
self.jumpStartY = self.groundY;
self.isJumping = false;
self.jumpVelocity = 0;
self.gravity = 1.2;
self.maxJumpVelocity = -45;
self.jumpChargeTime = 0;
self.isCharging = false;
self.canDoubleJump = false;
self.hasDoubleJumped = false;
self.isDashing = false;
self.dashSpeed = 25;
self.dashDuration = 300; // milliseconds
self.update = function () {
if (self.isJumping && !self.isDashing) {
self.y += self.jumpVelocity;
self.jumpVelocity += self.gravity;
if (self.y >= self.groundY) {
self.y = self.groundY;
self.isJumping = false;
self.jumpVelocity = 0;
self.canDoubleJump = false;
self.hasDoubleJumped = false;
}
}
if (self.isCharging && self.jumpChargeTime < 30) {
self.jumpChargeTime++;
}
};
self.startJump = function () {
if (!self.isJumping) {
self.isCharging = true;
self.jumpChargeTime = 0;
}
};
self.executeJump = function () {
if (!self.isJumping && self.isCharging) {
var jumpPower = Math.min(self.jumpChargeTime / 30, 1);
self.jumpVelocity = self.maxJumpVelocity * (0.4 + jumpPower * 0.6);
self.isJumping = true;
self.isCharging = false;
self.jumpChargeTime = 0;
self.canDoubleJump = true;
LK.getSound('jump').play();
} else if (self.isJumping && self.canDoubleJump && !self.hasDoubleJumped) {
// Double jump
self.jumpVelocity = self.maxJumpVelocity * 0.8;
self.hasDoubleJumped = true;
self.canDoubleJump = false;
LK.getSound('jump').play();
// Create particles below chicken's feet
for (var i = 0; i < 8; i++) {
var particle = new Particle();
particle.x = self.x + (Math.random() - 0.5) * 40;
particle.y = self.y + 30; // Below chicken's feet
particles.push(particle);
game.addChild(particle);
}
}
};
self.startDash = function () {
// Dash functionality disabled
};
return self;
});
var Cloud = Container.expand(function () {
var self = Container.call(this);
var cloudGraphics = self.attachAsset('cloud', {
anchorX: 0.5,
anchorY: 0.5
});
cloudGraphics.alpha = 0.7;
self.speed = 1;
self.update = function () {
self.x -= self.speed;
};
return self;
});
var Particle = Container.expand(function () {
var self = Container.call(this);
var particleGraphics = self.attachAsset('particle', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = (Math.random() - 0.5) * 8;
self.velocityY = Math.random() * -4 - 2;
self.life = 30;
self.maxLife = 30;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityY += 0.2; // gravity
self.life--;
// Fade out over time
var alpha = self.life / self.maxLife;
particleGraphics.alpha = alpha;
if (self.life <= 0) {
self.markForDestroy = true;
}
};
return self;
});
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerUpGraphics = self.attachAsset('powerUp', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = gameSpeed;
self.floatOffset = 0;
self.collected = false;
self.update = function () {
self.x -= self.speed;
// Floating animation
self.floatOffset += 0.2;
self.y += Math.sin(self.floatOffset) * 2;
};
return self;
});
var TrailParticle = Container.expand(function () {
var self = Container.call(this);
var particleGraphics = self.attachAsset('trailParticle', {
anchorX: 0.5,
anchorY: 0.5
});
// Random color for trail particles
var colors = [0xff4500, 0xff6347, 0xffd700, 0xff1493, 0x00ff00, 0x00bfff];
particleGraphics.tint = colors[Math.floor(Math.random() * colors.length)];
self.velocityX = (Math.random() - 0.5) * 6;
self.velocityY = Math.random() * -3 - 1;
self.life = 40;
self.maxLife = 40;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityY += 0.15; // gravity
self.life--;
// Fade out over time
var alpha = self.life / self.maxLife;
particleGraphics.alpha = alpha;
if (self.life <= 0) {
self.markForDestroy = true;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var gameSpeed = 8;
var maxGameSpeed = 20;
var speedIncrement = 0.02;
var cactusSpawnTimer = 0;
var cactusSpawnInterval = 90;
var minSpawnInterval = 45;
var cloudSpawnTimer = 0;
var distanceTraveled = 0;
var lastScoreSound = 0;
var jumpScore = 0;
var chicken;
var chickenLives = 3;
var lifeDisplays = [];
var cacti = [];
var clouds = [];
var powerUps = [];
var particles = [];
var trailParticles = [];
var bricks = [];
var brickSpawnTimer = 0;
var brickSpawnInterval = 3000; // 50 seconds at 60fps
var ground;
var isGameRunning = true;
var isJumpPressed = false;
var tapCount = 0;
var lastTapTime = 0;
var doubleTapThreshold = 300; // milliseconds for double tap detection
var dashCooldown = 0; // Timer for dash cooldown
var dashCooldownDuration = 600; // 10 seconds at 60fps (10 * 60 = 600 frames)
// Power-up system
var powerUpSpawnTimer = 0;
var powerUpSpawnInterval = 1200 + Math.random() * 1200; // Random 20-40 seconds at 60fps
var isInvincible = false;
var invincibilityTimer = 0;
var invincibilityDuration = 1500; // 25 seconds at 60fps
var baseGameSpeed = 8;
// Pause system
var isPaused = false;
var pauseButton;
// Create ground
ground = game.addChild(LK.getAsset('ground', {
anchorX: 0,
anchorY: 1.0
}));
ground.x = 0;
ground.y = 2732 - 140;
// Create chicken
chicken = game.addChild(new Chicken());
chicken.x = 300;
chicken.y = chicken.groundY;
// Create life display hearts beside pause button
for (var i = 0; i < chickenLives; i++) {
var heart = LK.getAsset('heart', {
anchorX: 0.5,
anchorY: 0.5
});
heart.x = 250 + i * 50; // Position next to pause button
heart.y = 70; // Align with pause button
lifeDisplays.push(heart);
LK.gui.topLeft.addChild(heart);
}
// Score display for cactus jumps
var jumpScoreText = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
jumpScoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(jumpScoreText);
jumpScoreText.y = 20;
// Tap counter display
var tapCountText = new Text2('CP: 0', {
size: 60,
fill: 0xFFFFFF
});
tapCountText.anchor.set(0.5, 0);
LK.gui.top.addChild(tapCountText);
tapCountText.y = 90;
// Distance display
var scoreText = new Text2('Distance: 0m', {
size: 60,
fill: 0xFFFFFF
});
scoreText.anchor.set(0, 0);
LK.gui.topRight.addChild(scoreText);
scoreText.x = -20;
scoreText.y = 20;
// Instructions
var instructionText = new Text2('TAP & HOLD TO JUMP HIGHER', {
size: 45,
fill: 0xFFFFFF
});
instructionText.anchor.set(0.5, 0);
LK.gui.top.addChild(instructionText);
instructionText.y = 100;
// Power-up timer display
var powerUpTimerText = new Text2('', {
size: 80,
fill: 0xFFFF00 // Yellow color
});
powerUpTimerText.anchor.set(0.5, 0.5);
LK.gui.center.addChild(powerUpTimerText);
powerUpTimerText.visible = false;
// Create pause button in top left (avoiding the 100x100 platform menu area)
pauseButton = LK.getAsset('pauseButton', {
anchorX: 0,
anchorY: 0
});
LK.gui.topLeft.addChild(pauseButton);
pauseButton.x = 120; // Offset from very top left to avoid platform menu
pauseButton.y = 20;
// Add pause symbol (two vertical lines)
var pauseLine1 = LK.getAsset('pauseButton', {
anchorX: 0.5,
anchorY: 0.5,
width: 8,
height: 40,
color: 0xffffff
});
var pauseLine2 = LK.getAsset('pauseButton', {
anchorX: 0.5,
anchorY: 0.5,
width: 8,
height: 40,
color: 0xffffff
});
pauseButton.addChild(pauseLine1);
pauseButton.addChild(pauseLine2);
pauseLine1.x = 25;
pauseLine1.y = 40;
pauseLine2.x = 55;
pauseLine2.y = 40;
// Variable to store play triangle reference
var playTriangle = null;
// Pause button functionality
pauseButton.down = function (x, y, obj) {
isPaused = !isPaused;
if (isPaused) {
// Show paused state - make lines into play triangle
pauseLine1.visible = false;
pauseLine2.visible = false;
// Create play triangle
playTriangle = LK.getAsset('pauseButton', {
anchorX: 0.5,
anchorY: 0.5,
width: 0,
height: 0,
color: 0xffffff
});
pauseButton.addChild(playTriangle);
playTriangle.x = 45;
playTriangle.y = 40;
// Create triangle using three lines (simple approach)
var tri1 = LK.getAsset('pauseButton', {
width: 30,
height: 4,
color: 0xffffff,
anchorX: 0,
anchorY: 0.5
});
var tri2 = LK.getAsset('pauseButton', {
width: 30,
height: 4,
color: 0xffffff,
anchorX: 0,
anchorY: 0.5
});
var tri3 = LK.getAsset('pauseButton', {
width: 30,
height: 4,
color: 0xffffff,
anchorX: 0,
anchorY: 0.5
});
playTriangle.addChild(tri1);
playTriangle.addChild(tri2);
playTriangle.addChild(tri3);
tri1.x = -15;
tri1.y = -15;
tri1.rotation = 0.5;
tri2.x = -15;
tri2.y = 15;
tri2.rotation = -0.5;
tri3.x = -15;
tri3.y = 0;
tri3.rotation = 0;
} else {
// Show pause state - remove play triangle and show pause lines
if (playTriangle) {
pauseButton.removeChild(playTriangle);
playTriangle = null;
}
pauseLine1.visible = true;
pauseLine2.visible = true;
}
};
// Game controls
game.down = function (x, y, obj) {
if (isGameRunning) {
// Single tap - start jump
isJumpPressed = true;
chicken.startJump();
tapCount++;
tapCountText.setText('CP: ' + tapCount);
}
};
game.up = function (x, y, obj) {
if (isGameRunning && isJumpPressed) {
isJumpPressed = false;
chicken.executeJump();
}
};
function spawnCactus() {
var cactusType = Math.random() < 0.6 ? 'small' : 'tall';
var newCactus = new Cactus(cactusType);
newCactus.x = 2048 + 100;
newCactus.y = 2732 - 200;
newCactus.speed = gameSpeed;
cacti.push(newCactus);
game.addChild(newCactus);
}
function spawnCloud() {
var newCloud = new Cloud();
newCloud.x = 2048 + 200;
newCloud.y = 200 + Math.random() * 400;
clouds.push(newCloud);
game.addChild(newCloud);
}
function spawnPowerUp() {
var newPowerUp = new PowerUp();
newPowerUp.x = 2048 + 100;
newPowerUp.y = 2732 - 400 - Math.random() * 200; // Spawn in air
newPowerUp.speed = gameSpeed;
powerUps.push(newPowerUp);
game.addChild(newPowerUp);
}
function spawnBrick() {
var newBrick = new Brick();
newBrick.x = 200 + Math.random() * 1648; // Random x position across screen
newBrick.y = -100; // Start above screen
bricks.push(newBrick);
game.addChild(newBrick);
}
function checkCollisions() {
for (var i = cacti.length - 1; i >= 0; i--) {
var cactus = cacti[i];
if (chicken.intersects(cactus)) {
if (isInvincible) {
// Destroy cactus with visual effect
tween(cactus, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 200,
onFinish: function onFinish() {
cactus.destroy();
}
});
cacti.splice(i, 1);
} else {
// Lose a life
chickenLives--;
// Hide one heart
if (lifeDisplays.length > 0) {
var heartToRemove = lifeDisplays.pop();
tween(heartToRemove, {
alpha: 0,
scaleX: 0,
scaleY: 0
}, {
duration: 300,
onFinish: function onFinish() {
heartToRemove.destroy();
}
});
}
// Push chicken backwards
tween(chicken, {
x: chicken.x - 150
}, {
duration: 500,
easing: tween.easeOut
});
// Flash chicken red briefly
tween(chicken, {
tint: 0xff0000
}, {
duration: 200,
onFinish: function onFinish() {
tween(chicken, {
tint: 0xffffff
}, {
duration: 200
});
}
});
// Destroy the cactus that hit the chicken with animation
tween(cactus, {
alpha: 0,
scaleX: 2,
scaleY: 2,
rotation: Math.PI
}, {
duration: 400,
easing: tween.easeOut,
onFinish: function onFinish() {
cactus.destroy();
}
});
cacti.splice(i, 1);
// Check if all lives are lost
if (chickenLives <= 0) {
isGameRunning = false;
LK.effects.flashScreen(0xFF0000, 800);
LK.setTimeout(function () {
LK.showGameOver();
}, 400);
return;
}
}
}
}
}
function updateScore() {
distanceTraveled = Math.floor(LK.ticks / 6);
scoreText.setText('Distance: ' + distanceTraveled + 'm');
// Play score sound every 100 meters
if (distanceTraveled > 0 && distanceTraveled % 100 === 0 && distanceTraveled !== lastScoreSound) {
LK.getSound('score').play();
lastScoreSound = distanceTraveled;
}
}
function checkCactusJumps() {
for (var i = 0; i < cacti.length; i++) {
var cactus = cacti[i];
// Check if chicken has passed the cactus (chicken is to the right of cactus)
if (!cactus.passed && chicken.x > cactus.x + 30) {
cactus.passed = true;
jumpScore++;
LK.setScore(jumpScore);
jumpScoreText.setText('Score: ' + jumpScore);
LK.getSound('score').play();
increaseDifficulty();
}
}
}
function checkPowerUpCollisions() {
for (var i = powerUps.length - 1; i >= 0; i--) {
var powerUp = powerUps[i];
if (chicken.intersects(powerUp) && !powerUp.collected) {
powerUp.collected = true;
// Activate invincibility
isInvincible = true;
invincibilityTimer = 0;
// Increase chicken speed by 70%
chicken.speed = baseGameSpeed * 1.7;
LK.getSound('powerup').play();
// Create colorful trail particles behind chicken
for (var j = 0; j < 12; j++) {
var trailParticle = new TrailParticle();
trailParticle.x = chicken.x - 50 - Math.random() * 30; // Behind chicken
trailParticle.y = chicken.y - Math.random() * 40;
trailParticles.push(trailParticle);
game.addChild(trailParticle);
}
// Visual feedback - make chicken glow
tween(chicken, {
tint: 0xffff00
}, {
duration: 300
});
// Remove power-up with effect
tween(powerUp, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 300,
onFinish: function onFinish() {
powerUp.destroy();
}
});
powerUps.splice(i, 1);
}
}
}
function checkBrickCollisions() {
for (var i = bricks.length - 1; i >= 0; i--) {
var brick = bricks[i];
if (chicken.intersects(brick) && !brick.hit) {
brick.hit = true;
if (!isInvincible) {
// Lose 2 lives
chickenLives -= 2;
// Hide two hearts
for (var h = 0; h < 2 && lifeDisplays.length > 0; h++) {
var heartToRemove = lifeDisplays.pop();
tween(heartToRemove, {
alpha: 0,
scaleX: 0,
scaleY: 0
}, {
duration: 300,
onFinish: function onFinish() {
heartToRemove.destroy();
}
});
}
// Push chicken backwards
tween(chicken, {
x: chicken.x - 150
}, {
duration: 500,
easing: tween.easeOut
});
// Flash chicken red briefly
tween(chicken, {
tint: 0xff0000
}, {
duration: 200,
onFinish: function onFinish() {
tween(chicken, {
tint: 0xffffff
}, {
duration: 200
});
}
});
// Check if all lives are lost
if (chickenLives <= 0) {
isGameRunning = false;
LK.effects.flashScreen(0xFF0000, 800);
LK.setTimeout(function () {
LK.showGameOver();
}, 400);
return;
}
}
// Destroy the brick with animation
tween(brick, {
alpha: 0,
scaleX: 2,
scaleY: 2,
rotation: Math.PI
}, {
duration: 400,
easing: tween.easeOut,
onFinish: function onFinish() {
brick.destroy();
}
});
bricks.splice(i, 1);
}
}
}
function increaseDifficulty() {
// Increase speed every 50 points
var targetSpeed = 8 + Math.floor(jumpScore / 50) * 2;
if (targetSpeed > maxGameSpeed) {
targetSpeed = maxGameSpeed;
}
gameSpeed = targetSpeed;
// Decrease spawn interval based on score
var targetInterval = 90 - Math.floor(jumpScore / 50) * 10;
if (targetInterval < minSpawnInterval) {
targetInterval = minSpawnInterval;
}
cactusSpawnInterval = targetInterval;
}
function updateInvincibility() {
if (isInvincible) {
invincibilityTimer++;
// Update power-up timer display
var remainingSeconds = Math.ceil((invincibilityDuration - invincibilityTimer) / 60);
powerUpTimerText.setText(remainingSeconds + 's');
powerUpTimerText.visible = true;
// Make chicken flash during invincibility
if (invincibilityTimer % 10 === 0) {
var currentTint = chicken.tint === 0xffff00 ? 0xffffff : 0xffff00;
chicken.tint = currentTint;
}
// End invincibility after duration
if (invincibilityTimer >= invincibilityDuration) {
isInvincible = false;
invincibilityTimer = 0;
powerUpTimerText.visible = false;
// Reset chicken speed
chicken.speed = baseGameSpeed;
// Reset chicken appearance
tween(chicken, {
tint: 0xffffff
}, {
duration: 500
});
}
} else {
powerUpTimerText.visible = false;
}
}
game.update = function () {
if (!isGameRunning || isPaused) return;
updateScore();
// Spawn cacti
cactusSpawnTimer++;
if (cactusSpawnTimer >= cactusSpawnInterval) {
spawnCactus();
cactusSpawnTimer = 0;
}
// Spawn clouds
cloudSpawnTimer++;
if (cloudSpawnTimer >= 180) {
spawnCloud();
cloudSpawnTimer = 0;
}
// Spawn power-ups
powerUpSpawnTimer++;
if (powerUpSpawnTimer >= powerUpSpawnInterval) {
spawnPowerUp();
powerUpSpawnTimer = 0;
// Set new random interval for next power-up (20-40 seconds)
powerUpSpawnInterval = 1200 + Math.random() * 1200;
}
// Spawn bricks every 50 seconds
brickSpawnTimer++;
if (brickSpawnTimer >= brickSpawnInterval) {
spawnBrick();
brickSpawnTimer = 0;
}
// Update and clean up cacti
for (var i = cacti.length - 1; i >= 0; i--) {
var cactus = cacti[i];
cactus.speed = gameSpeed;
if (cactus.x < -100) {
cactus.destroy();
cacti.splice(i, 1);
}
}
// Update and clean up clouds
for (var i = clouds.length - 1; i >= 0; i--) {
var cloud = clouds[i];
if (cloud.x < -200) {
cloud.destroy();
clouds.splice(i, 1);
}
}
// Update and clean up power-ups
for (var i = powerUps.length - 1; i >= 0; i--) {
var powerUp = powerUps[i];
powerUp.speed = gameSpeed;
if (powerUp.x < -100) {
powerUp.destroy();
powerUps.splice(i, 1);
}
}
// Update and clean up particles
for (var i = particles.length - 1; i >= 0; i--) {
var particle = particles[i];
if (particle.markForDestroy) {
particle.destroy();
particles.splice(i, 1);
}
}
// Update and clean up trail particles
for (var i = trailParticles.length - 1; i >= 0; i--) {
var trailParticle = trailParticles[i];
if (trailParticle.markForDestroy) {
trailParticle.destroy();
trailParticles.splice(i, 1);
}
}
// Update and clean up bricks
for (var i = bricks.length - 1; i >= 0; i--) {
var brick = bricks[i];
if (brick.y > 2732 + 100) {
// Off-screen cleanup
brick.destroy();
bricks.splice(i, 1);
}
}
updateInvincibility();
// Update dash cooldown
if (dashCooldown > 0) {
dashCooldown--;
}
checkCollisions();
checkCactusJumps();
checkPowerUpCollisions();
checkBrickCollisions();
// Hide instructions after first jump
if (chicken.isJumping && instructionText.alpha > 0) {
tween(instructionText, {
alpha: 0
}, {
duration: 1000
});
}
}; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Brick = Container.expand(function () {
var self = Container.call(this);
var brickGraphics = self.attachAsset('pauseButton', {
anchorX: 0.5,
anchorY: 0.5,
width: 80,
height: 40,
color: 0x8B4513
});
self.velocityY = 0;
self.gravity = 0.8;
self.hit = false;
self.update = function () {
self.velocityY += self.gravity;
self.y += self.velocityY;
};
return self;
});
var Cactus = Container.expand(function (type) {
var self = Container.call(this);
var assetName = type === 'tall' ? 'tallCactus' : 'smallCactus';
var cactusGraphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 1.0
});
self.type = type;
self.speed = gameSpeed;
self.passed = false;
self.update = function () {
self.x -= self.speed;
};
return self;
});
var Chicken = Container.expand(function () {
var self = Container.call(this);
var chickenGraphics = self.attachAsset('chicken', {
anchorX: 0.5,
anchorY: 1.0
});
self.groundY = 2732 - 200;
self.jumpStartY = self.groundY;
self.isJumping = false;
self.jumpVelocity = 0;
self.gravity = 1.2;
self.maxJumpVelocity = -45;
self.jumpChargeTime = 0;
self.isCharging = false;
self.canDoubleJump = false;
self.hasDoubleJumped = false;
self.isDashing = false;
self.dashSpeed = 25;
self.dashDuration = 300; // milliseconds
self.update = function () {
if (self.isJumping && !self.isDashing) {
self.y += self.jumpVelocity;
self.jumpVelocity += self.gravity;
if (self.y >= self.groundY) {
self.y = self.groundY;
self.isJumping = false;
self.jumpVelocity = 0;
self.canDoubleJump = false;
self.hasDoubleJumped = false;
}
}
if (self.isCharging && self.jumpChargeTime < 30) {
self.jumpChargeTime++;
}
};
self.startJump = function () {
if (!self.isJumping) {
self.isCharging = true;
self.jumpChargeTime = 0;
}
};
self.executeJump = function () {
if (!self.isJumping && self.isCharging) {
var jumpPower = Math.min(self.jumpChargeTime / 30, 1);
self.jumpVelocity = self.maxJumpVelocity * (0.4 + jumpPower * 0.6);
self.isJumping = true;
self.isCharging = false;
self.jumpChargeTime = 0;
self.canDoubleJump = true;
LK.getSound('jump').play();
} else if (self.isJumping && self.canDoubleJump && !self.hasDoubleJumped) {
// Double jump
self.jumpVelocity = self.maxJumpVelocity * 0.8;
self.hasDoubleJumped = true;
self.canDoubleJump = false;
LK.getSound('jump').play();
// Create particles below chicken's feet
for (var i = 0; i < 8; i++) {
var particle = new Particle();
particle.x = self.x + (Math.random() - 0.5) * 40;
particle.y = self.y + 30; // Below chicken's feet
particles.push(particle);
game.addChild(particle);
}
}
};
self.startDash = function () {
// Dash functionality disabled
};
return self;
});
var Cloud = Container.expand(function () {
var self = Container.call(this);
var cloudGraphics = self.attachAsset('cloud', {
anchorX: 0.5,
anchorY: 0.5
});
cloudGraphics.alpha = 0.7;
self.speed = 1;
self.update = function () {
self.x -= self.speed;
};
return self;
});
var Particle = Container.expand(function () {
var self = Container.call(this);
var particleGraphics = self.attachAsset('particle', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = (Math.random() - 0.5) * 8;
self.velocityY = Math.random() * -4 - 2;
self.life = 30;
self.maxLife = 30;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityY += 0.2; // gravity
self.life--;
// Fade out over time
var alpha = self.life / self.maxLife;
particleGraphics.alpha = alpha;
if (self.life <= 0) {
self.markForDestroy = true;
}
};
return self;
});
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerUpGraphics = self.attachAsset('powerUp', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = gameSpeed;
self.floatOffset = 0;
self.collected = false;
self.update = function () {
self.x -= self.speed;
// Floating animation
self.floatOffset += 0.2;
self.y += Math.sin(self.floatOffset) * 2;
};
return self;
});
var TrailParticle = Container.expand(function () {
var self = Container.call(this);
var particleGraphics = self.attachAsset('trailParticle', {
anchorX: 0.5,
anchorY: 0.5
});
// Random color for trail particles
var colors = [0xff4500, 0xff6347, 0xffd700, 0xff1493, 0x00ff00, 0x00bfff];
particleGraphics.tint = colors[Math.floor(Math.random() * colors.length)];
self.velocityX = (Math.random() - 0.5) * 6;
self.velocityY = Math.random() * -3 - 1;
self.life = 40;
self.maxLife = 40;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityY += 0.15; // gravity
self.life--;
// Fade out over time
var alpha = self.life / self.maxLife;
particleGraphics.alpha = alpha;
if (self.life <= 0) {
self.markForDestroy = true;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var gameSpeed = 8;
var maxGameSpeed = 20;
var speedIncrement = 0.02;
var cactusSpawnTimer = 0;
var cactusSpawnInterval = 90;
var minSpawnInterval = 45;
var cloudSpawnTimer = 0;
var distanceTraveled = 0;
var lastScoreSound = 0;
var jumpScore = 0;
var chicken;
var chickenLives = 3;
var lifeDisplays = [];
var cacti = [];
var clouds = [];
var powerUps = [];
var particles = [];
var trailParticles = [];
var bricks = [];
var brickSpawnTimer = 0;
var brickSpawnInterval = 3000; // 50 seconds at 60fps
var ground;
var isGameRunning = true;
var isJumpPressed = false;
var tapCount = 0;
var lastTapTime = 0;
var doubleTapThreshold = 300; // milliseconds for double tap detection
var dashCooldown = 0; // Timer for dash cooldown
var dashCooldownDuration = 600; // 10 seconds at 60fps (10 * 60 = 600 frames)
// Power-up system
var powerUpSpawnTimer = 0;
var powerUpSpawnInterval = 1200 + Math.random() * 1200; // Random 20-40 seconds at 60fps
var isInvincible = false;
var invincibilityTimer = 0;
var invincibilityDuration = 1500; // 25 seconds at 60fps
var baseGameSpeed = 8;
// Pause system
var isPaused = false;
var pauseButton;
// Create ground
ground = game.addChild(LK.getAsset('ground', {
anchorX: 0,
anchorY: 1.0
}));
ground.x = 0;
ground.y = 2732 - 140;
// Create chicken
chicken = game.addChild(new Chicken());
chicken.x = 300;
chicken.y = chicken.groundY;
// Create life display hearts beside pause button
for (var i = 0; i < chickenLives; i++) {
var heart = LK.getAsset('heart', {
anchorX: 0.5,
anchorY: 0.5
});
heart.x = 250 + i * 50; // Position next to pause button
heart.y = 70; // Align with pause button
lifeDisplays.push(heart);
LK.gui.topLeft.addChild(heart);
}
// Score display for cactus jumps
var jumpScoreText = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
jumpScoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(jumpScoreText);
jumpScoreText.y = 20;
// Tap counter display
var tapCountText = new Text2('CP: 0', {
size: 60,
fill: 0xFFFFFF
});
tapCountText.anchor.set(0.5, 0);
LK.gui.top.addChild(tapCountText);
tapCountText.y = 90;
// Distance display
var scoreText = new Text2('Distance: 0m', {
size: 60,
fill: 0xFFFFFF
});
scoreText.anchor.set(0, 0);
LK.gui.topRight.addChild(scoreText);
scoreText.x = -20;
scoreText.y = 20;
// Instructions
var instructionText = new Text2('TAP & HOLD TO JUMP HIGHER', {
size: 45,
fill: 0xFFFFFF
});
instructionText.anchor.set(0.5, 0);
LK.gui.top.addChild(instructionText);
instructionText.y = 100;
// Power-up timer display
var powerUpTimerText = new Text2('', {
size: 80,
fill: 0xFFFF00 // Yellow color
});
powerUpTimerText.anchor.set(0.5, 0.5);
LK.gui.center.addChild(powerUpTimerText);
powerUpTimerText.visible = false;
// Create pause button in top left (avoiding the 100x100 platform menu area)
pauseButton = LK.getAsset('pauseButton', {
anchorX: 0,
anchorY: 0
});
LK.gui.topLeft.addChild(pauseButton);
pauseButton.x = 120; // Offset from very top left to avoid platform menu
pauseButton.y = 20;
// Add pause symbol (two vertical lines)
var pauseLine1 = LK.getAsset('pauseButton', {
anchorX: 0.5,
anchorY: 0.5,
width: 8,
height: 40,
color: 0xffffff
});
var pauseLine2 = LK.getAsset('pauseButton', {
anchorX: 0.5,
anchorY: 0.5,
width: 8,
height: 40,
color: 0xffffff
});
pauseButton.addChild(pauseLine1);
pauseButton.addChild(pauseLine2);
pauseLine1.x = 25;
pauseLine1.y = 40;
pauseLine2.x = 55;
pauseLine2.y = 40;
// Variable to store play triangle reference
var playTriangle = null;
// Pause button functionality
pauseButton.down = function (x, y, obj) {
isPaused = !isPaused;
if (isPaused) {
// Show paused state - make lines into play triangle
pauseLine1.visible = false;
pauseLine2.visible = false;
// Create play triangle
playTriangle = LK.getAsset('pauseButton', {
anchorX: 0.5,
anchorY: 0.5,
width: 0,
height: 0,
color: 0xffffff
});
pauseButton.addChild(playTriangle);
playTriangle.x = 45;
playTriangle.y = 40;
// Create triangle using three lines (simple approach)
var tri1 = LK.getAsset('pauseButton', {
width: 30,
height: 4,
color: 0xffffff,
anchorX: 0,
anchorY: 0.5
});
var tri2 = LK.getAsset('pauseButton', {
width: 30,
height: 4,
color: 0xffffff,
anchorX: 0,
anchorY: 0.5
});
var tri3 = LK.getAsset('pauseButton', {
width: 30,
height: 4,
color: 0xffffff,
anchorX: 0,
anchorY: 0.5
});
playTriangle.addChild(tri1);
playTriangle.addChild(tri2);
playTriangle.addChild(tri3);
tri1.x = -15;
tri1.y = -15;
tri1.rotation = 0.5;
tri2.x = -15;
tri2.y = 15;
tri2.rotation = -0.5;
tri3.x = -15;
tri3.y = 0;
tri3.rotation = 0;
} else {
// Show pause state - remove play triangle and show pause lines
if (playTriangle) {
pauseButton.removeChild(playTriangle);
playTriangle = null;
}
pauseLine1.visible = true;
pauseLine2.visible = true;
}
};
// Game controls
game.down = function (x, y, obj) {
if (isGameRunning) {
// Single tap - start jump
isJumpPressed = true;
chicken.startJump();
tapCount++;
tapCountText.setText('CP: ' + tapCount);
}
};
game.up = function (x, y, obj) {
if (isGameRunning && isJumpPressed) {
isJumpPressed = false;
chicken.executeJump();
}
};
function spawnCactus() {
var cactusType = Math.random() < 0.6 ? 'small' : 'tall';
var newCactus = new Cactus(cactusType);
newCactus.x = 2048 + 100;
newCactus.y = 2732 - 200;
newCactus.speed = gameSpeed;
cacti.push(newCactus);
game.addChild(newCactus);
}
function spawnCloud() {
var newCloud = new Cloud();
newCloud.x = 2048 + 200;
newCloud.y = 200 + Math.random() * 400;
clouds.push(newCloud);
game.addChild(newCloud);
}
function spawnPowerUp() {
var newPowerUp = new PowerUp();
newPowerUp.x = 2048 + 100;
newPowerUp.y = 2732 - 400 - Math.random() * 200; // Spawn in air
newPowerUp.speed = gameSpeed;
powerUps.push(newPowerUp);
game.addChild(newPowerUp);
}
function spawnBrick() {
var newBrick = new Brick();
newBrick.x = 200 + Math.random() * 1648; // Random x position across screen
newBrick.y = -100; // Start above screen
bricks.push(newBrick);
game.addChild(newBrick);
}
function checkCollisions() {
for (var i = cacti.length - 1; i >= 0; i--) {
var cactus = cacti[i];
if (chicken.intersects(cactus)) {
if (isInvincible) {
// Destroy cactus with visual effect
tween(cactus, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 200,
onFinish: function onFinish() {
cactus.destroy();
}
});
cacti.splice(i, 1);
} else {
// Lose a life
chickenLives--;
// Hide one heart
if (lifeDisplays.length > 0) {
var heartToRemove = lifeDisplays.pop();
tween(heartToRemove, {
alpha: 0,
scaleX: 0,
scaleY: 0
}, {
duration: 300,
onFinish: function onFinish() {
heartToRemove.destroy();
}
});
}
// Push chicken backwards
tween(chicken, {
x: chicken.x - 150
}, {
duration: 500,
easing: tween.easeOut
});
// Flash chicken red briefly
tween(chicken, {
tint: 0xff0000
}, {
duration: 200,
onFinish: function onFinish() {
tween(chicken, {
tint: 0xffffff
}, {
duration: 200
});
}
});
// Destroy the cactus that hit the chicken with animation
tween(cactus, {
alpha: 0,
scaleX: 2,
scaleY: 2,
rotation: Math.PI
}, {
duration: 400,
easing: tween.easeOut,
onFinish: function onFinish() {
cactus.destroy();
}
});
cacti.splice(i, 1);
// Check if all lives are lost
if (chickenLives <= 0) {
isGameRunning = false;
LK.effects.flashScreen(0xFF0000, 800);
LK.setTimeout(function () {
LK.showGameOver();
}, 400);
return;
}
}
}
}
}
function updateScore() {
distanceTraveled = Math.floor(LK.ticks / 6);
scoreText.setText('Distance: ' + distanceTraveled + 'm');
// Play score sound every 100 meters
if (distanceTraveled > 0 && distanceTraveled % 100 === 0 && distanceTraveled !== lastScoreSound) {
LK.getSound('score').play();
lastScoreSound = distanceTraveled;
}
}
function checkCactusJumps() {
for (var i = 0; i < cacti.length; i++) {
var cactus = cacti[i];
// Check if chicken has passed the cactus (chicken is to the right of cactus)
if (!cactus.passed && chicken.x > cactus.x + 30) {
cactus.passed = true;
jumpScore++;
LK.setScore(jumpScore);
jumpScoreText.setText('Score: ' + jumpScore);
LK.getSound('score').play();
increaseDifficulty();
}
}
}
function checkPowerUpCollisions() {
for (var i = powerUps.length - 1; i >= 0; i--) {
var powerUp = powerUps[i];
if (chicken.intersects(powerUp) && !powerUp.collected) {
powerUp.collected = true;
// Activate invincibility
isInvincible = true;
invincibilityTimer = 0;
// Increase chicken speed by 70%
chicken.speed = baseGameSpeed * 1.7;
LK.getSound('powerup').play();
// Create colorful trail particles behind chicken
for (var j = 0; j < 12; j++) {
var trailParticle = new TrailParticle();
trailParticle.x = chicken.x - 50 - Math.random() * 30; // Behind chicken
trailParticle.y = chicken.y - Math.random() * 40;
trailParticles.push(trailParticle);
game.addChild(trailParticle);
}
// Visual feedback - make chicken glow
tween(chicken, {
tint: 0xffff00
}, {
duration: 300
});
// Remove power-up with effect
tween(powerUp, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 300,
onFinish: function onFinish() {
powerUp.destroy();
}
});
powerUps.splice(i, 1);
}
}
}
function checkBrickCollisions() {
for (var i = bricks.length - 1; i >= 0; i--) {
var brick = bricks[i];
if (chicken.intersects(brick) && !brick.hit) {
brick.hit = true;
if (!isInvincible) {
// Lose 2 lives
chickenLives -= 2;
// Hide two hearts
for (var h = 0; h < 2 && lifeDisplays.length > 0; h++) {
var heartToRemove = lifeDisplays.pop();
tween(heartToRemove, {
alpha: 0,
scaleX: 0,
scaleY: 0
}, {
duration: 300,
onFinish: function onFinish() {
heartToRemove.destroy();
}
});
}
// Push chicken backwards
tween(chicken, {
x: chicken.x - 150
}, {
duration: 500,
easing: tween.easeOut
});
// Flash chicken red briefly
tween(chicken, {
tint: 0xff0000
}, {
duration: 200,
onFinish: function onFinish() {
tween(chicken, {
tint: 0xffffff
}, {
duration: 200
});
}
});
// Check if all lives are lost
if (chickenLives <= 0) {
isGameRunning = false;
LK.effects.flashScreen(0xFF0000, 800);
LK.setTimeout(function () {
LK.showGameOver();
}, 400);
return;
}
}
// Destroy the brick with animation
tween(brick, {
alpha: 0,
scaleX: 2,
scaleY: 2,
rotation: Math.PI
}, {
duration: 400,
easing: tween.easeOut,
onFinish: function onFinish() {
brick.destroy();
}
});
bricks.splice(i, 1);
}
}
}
function increaseDifficulty() {
// Increase speed every 50 points
var targetSpeed = 8 + Math.floor(jumpScore / 50) * 2;
if (targetSpeed > maxGameSpeed) {
targetSpeed = maxGameSpeed;
}
gameSpeed = targetSpeed;
// Decrease spawn interval based on score
var targetInterval = 90 - Math.floor(jumpScore / 50) * 10;
if (targetInterval < minSpawnInterval) {
targetInterval = minSpawnInterval;
}
cactusSpawnInterval = targetInterval;
}
function updateInvincibility() {
if (isInvincible) {
invincibilityTimer++;
// Update power-up timer display
var remainingSeconds = Math.ceil((invincibilityDuration - invincibilityTimer) / 60);
powerUpTimerText.setText(remainingSeconds + 's');
powerUpTimerText.visible = true;
// Make chicken flash during invincibility
if (invincibilityTimer % 10 === 0) {
var currentTint = chicken.tint === 0xffff00 ? 0xffffff : 0xffff00;
chicken.tint = currentTint;
}
// End invincibility after duration
if (invincibilityTimer >= invincibilityDuration) {
isInvincible = false;
invincibilityTimer = 0;
powerUpTimerText.visible = false;
// Reset chicken speed
chicken.speed = baseGameSpeed;
// Reset chicken appearance
tween(chicken, {
tint: 0xffffff
}, {
duration: 500
});
}
} else {
powerUpTimerText.visible = false;
}
}
game.update = function () {
if (!isGameRunning || isPaused) return;
updateScore();
// Spawn cacti
cactusSpawnTimer++;
if (cactusSpawnTimer >= cactusSpawnInterval) {
spawnCactus();
cactusSpawnTimer = 0;
}
// Spawn clouds
cloudSpawnTimer++;
if (cloudSpawnTimer >= 180) {
spawnCloud();
cloudSpawnTimer = 0;
}
// Spawn power-ups
powerUpSpawnTimer++;
if (powerUpSpawnTimer >= powerUpSpawnInterval) {
spawnPowerUp();
powerUpSpawnTimer = 0;
// Set new random interval for next power-up (20-40 seconds)
powerUpSpawnInterval = 1200 + Math.random() * 1200;
}
// Spawn bricks every 50 seconds
brickSpawnTimer++;
if (brickSpawnTimer >= brickSpawnInterval) {
spawnBrick();
brickSpawnTimer = 0;
}
// Update and clean up cacti
for (var i = cacti.length - 1; i >= 0; i--) {
var cactus = cacti[i];
cactus.speed = gameSpeed;
if (cactus.x < -100) {
cactus.destroy();
cacti.splice(i, 1);
}
}
// Update and clean up clouds
for (var i = clouds.length - 1; i >= 0; i--) {
var cloud = clouds[i];
if (cloud.x < -200) {
cloud.destroy();
clouds.splice(i, 1);
}
}
// Update and clean up power-ups
for (var i = powerUps.length - 1; i >= 0; i--) {
var powerUp = powerUps[i];
powerUp.speed = gameSpeed;
if (powerUp.x < -100) {
powerUp.destroy();
powerUps.splice(i, 1);
}
}
// Update and clean up particles
for (var i = particles.length - 1; i >= 0; i--) {
var particle = particles[i];
if (particle.markForDestroy) {
particle.destroy();
particles.splice(i, 1);
}
}
// Update and clean up trail particles
for (var i = trailParticles.length - 1; i >= 0; i--) {
var trailParticle = trailParticles[i];
if (trailParticle.markForDestroy) {
trailParticle.destroy();
trailParticles.splice(i, 1);
}
}
// Update and clean up bricks
for (var i = bricks.length - 1; i >= 0; i--) {
var brick = bricks[i];
if (brick.y > 2732 + 100) {
// Off-screen cleanup
brick.destroy();
bricks.splice(i, 1);
}
}
updateInvincibility();
// Update dash cooldown
if (dashCooldown > 0) {
dashCooldown--;
}
checkCollisions();
checkCactusJumps();
checkPowerUpCollisions();
checkBrickCollisions();
// Hide instructions after first jump
if (chicken.isJumping && instructionText.alpha > 0) {
tween(instructionText, {
alpha: 0
}, {
duration: 1000
});
}
};
Cactus 2d style pixel 1980. 2d. High contrast. No shadows. 2d
White chicken military hat style 2d pixel 1980. In-Game asset. 2d. High contrast. No shadows
Chicken jump
Brick style pixel 1980. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Day sky and clouds style pixel 1980. In-Game asset. 2d. High contrast. No shadows. Pixel
Airplane 2d style pixel 1980. 2d. High contrast. No shadows
Night sky
Tubería gris radioactiva estilo pixel de 1983. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Boton verde ovalado qué dice "compra" estilo 2d pixel 1989. In-Game asset. 2d. High contrast. No shadows
Que el botón sea rojo y que diga salir
Pocion azul clara estilo pixel art . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Golden con style pixel art. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Red heart style pixel art. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Fondo verde
One Cloud style pixel art. 2d. High contrast. No shadows
Alas de ángel blancas estilo pixel art. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Un barrir marrón con 2 líneas negras en el medio estilo pixel art. 2d. High contrast. No shadows
Gray rock (stone) style pixel art. 2d. High contrast. No shadows
Yellow star with Black eyes style pixel art. 2d. High contrast. No shadows
Silla amarilla de un avion estilo pixel art. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Has el cuadro un poco más recto y sin líneas blancas
Caja de Interrogación alcoiris de líneas blancas estilo pixel art. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Una bola de acero negro con unas cadenas grises estilo pixel art. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Hitbox green. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Tiburón azul robótico volando con una elize abajo y una cara graciosa . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat