User prompt
Que la gallina cuando salte un cactus no tenga más valor de salto
User prompt
Que los cactus sean más pequeños
User prompt
Que enves que la gallina salte un 0.70 más alto se cambie a un 0.5
User prompt
Dependiendo de cuantos puntos tenga el jugador la gallina saltara un 0.70 más alto
User prompt
Añade un sistema de puntuación arriba en el medio (cada que la gallina salta un cactus incrementa)
User prompt
Que la gallina salte más alto que la altura promedio de un cactus
User prompt
Que la gallina salte más alto que la altura del cactus
Code edit (1 edits merged)
Please save this source code
User prompt
Desert Dash Chicken
Initial prompt
Una gallina que corre por el desierto esquivando cactus de diferentes tamaños
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
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.update = function () {
if (self.isJumping) {
self.y += self.jumpVelocity;
self.jumpVelocity += self.gravity;
if (self.y >= self.groundY) {
self.y = self.groundY;
self.isJumping = false;
self.jumpVelocity = 0;
}
}
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;
LK.getSound('jump').play();
}
};
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;
});
/****
* 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 cacti = [];
var clouds = [];
var ground;
var isGameRunning = true;
var isJumpPressed = false;
// 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;
// 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;
// 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;
// Game controls
game.down = function (x, y, obj) {
if (isGameRunning) {
isJumpPressed = true;
chicken.startJump();
}
};
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 checkCollisions() {
for (var i = 0; i < cacti.length; i++) {
var cactus = cacti[i];
if (chicken.intersects(cactus)) {
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();
}
}
}
function increaseDifficulty() {
// Gradually increase speed
if (gameSpeed < maxGameSpeed) {
gameSpeed += speedIncrement;
}
// Decrease spawn interval over time
if (cactusSpawnInterval > minSpawnInterval) {
cactusSpawnInterval -= 0.05;
}
}
game.update = function () {
if (!isGameRunning) return;
updateScore();
increaseDifficulty();
// Spawn cacti
cactusSpawnTimer++;
if (cactusSpawnTimer >= cactusSpawnInterval) {
spawnCactus();
cactusSpawnTimer = 0;
}
// Spawn clouds
cloudSpawnTimer++;
if (cloudSpawnTimer >= 180) {
spawnCloud();
cloudSpawnTimer = 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);
}
}
checkCollisions();
checkCactusJumps();
// Hide instructions after first jump
if (chicken.isJumping && instructionText.alpha > 0) {
tween(instructionText, {
alpha: 0
}, {
duration: 1000
});
}
}; ===================================================================
--- original.js
+++ change.js
@@ -57,10 +57,9 @@
};
self.executeJump = function () {
if (!self.isJumping && self.isCharging) {
var jumpPower = Math.min(self.jumpChargeTime / 30, 1);
- var scoreMultiplier = 1 + jumpScore * 0.5;
- self.jumpVelocity = self.maxJumpVelocity * (0.4 + jumpPower * 0.6) * scoreMultiplier;
+ self.jumpVelocity = self.maxJumpVelocity * (0.4 + jumpPower * 0.6);
self.isJumping = true;
self.isCharging = false;
self.jumpChargeTime = 0;
LK.getSound('jump').play();
Generame un cactus. In-Game asset. 2d. Estilo cartoon. Cartoon
Que el personaje tenga un casco de militar de la guerra con unos lentes de mira redonda
Un cañón verde estilo cartón plano y con un aura naranja resplandeciente como borde. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat