User prompt
pon un atardecer
User prompt
pon en el fondo unos edificios
User prompt
un fondo de una ciudad
User prompt
al saltar que la imagen se de la vuelta
User prompt
que no salte automaticamente
Code edit (1 edits merged)
Please save this source code
User prompt
Wall Jumping Cat
Initial prompt
Crea un juego de un gato que va saltando de pared en pared infinitamente mientras objetos caen
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Cat = Container.expand(function () {
var self = Container.call(this);
var catGraphics = self.attachAsset('cat', {
anchorX: 0.5,
anchorY: 0.5
});
self.jumpSpeed = 8;
self.targetX = 0;
self.isJumping = false;
// Auto jump functionality removed - cat only jumps on player input
self.jumpToWall = function (wallX) {
if (self.isJumping) return;
self.isJumping = true;
self.targetX = wallX;
LK.getSound('jump').play();
// Flip cat image based on jump direction
if (wallX > self.x) {
// Jumping right - face right (normal)
catGraphics.scaleX = 1;
} else {
// Jumping left - face left (flipped)
catGraphics.scaleX = -1;
}
tween(self, {
x: wallX
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
self.isJumping = false;
}
});
};
self.update = function () {
// Cat no longer auto-jumps, only responds to player input
};
return self;
});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 3;
self.update = function () {
self.y += self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb
});
/****
* Game Code
****/
// Game variables
var cat;
var obstacles = [];
var leftWall, rightWall;
var leftWallX = 20;
var rightWallX = 2028;
var spawnTimer = 0;
var spawnInterval = 120; // frames between obstacle spawns
var gameSpeed = 1;
var survivalTime = 0;
// Create walls
leftWall = game.addChild(LK.getAsset('wall', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
rightWall = game.addChild(LK.getAsset('wall', {
anchorX: 0,
anchorY: 0,
x: 2008,
y: 0
}));
// Create cat
cat = game.addChild(new Cat());
cat.x = leftWallX + 60;
cat.y = 2200;
// Create score display
var scoreTxt = new Text2('0', {
size: 100,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Create time display
var timeTxt = new Text2('Time: 0', {
size: 60,
fill: 0xFFFFFF
});
timeTxt.anchor.set(0, 0);
timeTxt.x = 150;
timeTxt.y = 20;
LK.gui.topLeft.addChild(timeTxt);
// Touch controls
game.down = function (x, y, obj) {
if (!cat.isJumping) {
// Jump to opposite wall
var newTargetX = cat.x < 1024 ? rightWallX - 60 : leftWallX + 60;
cat.jumpToWall(newTargetX);
}
};
// Spawn obstacles
function spawnObstacle() {
var obstacle = new Obstacle();
obstacle.x = Math.random() * (rightWallX - leftWallX - 100) + leftWallX + 50;
obstacle.y = -50;
obstacle.speed = 2 + Math.random() * 2 + gameSpeed * 0.5;
obstacles.push(obstacle);
game.addChild(obstacle);
}
// Game update loop
game.update = function () {
survivalTime++;
// Update time display
var seconds = Math.floor(survivalTime / 60);
timeTxt.setText('Time: ' + seconds);
// Update score
var score = Math.floor(survivalTime / 10);
scoreTxt.setText(score.toString());
LK.setScore(score);
// Increase game speed over time
gameSpeed = 1 + survivalTime / 3600;
// Spawn obstacles
spawnTimer++;
var currentSpawnInterval = Math.max(60, spawnInterval - survivalTime / 100);
if (spawnTimer >= currentSpawnInterval) {
spawnObstacle();
spawnTimer = 0;
}
// Update obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
var obstacle = obstacles[i];
// Check if obstacle went off screen
if (obstacle.y > 2800) {
obstacle.destroy();
obstacles.splice(i, 1);
continue;
}
// Check collision with cat
if (obstacle.intersects(cat)) {
LK.getSound('hit').play();
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -20,8 +20,16 @@
if (self.isJumping) return;
self.isJumping = true;
self.targetX = wallX;
LK.getSound('jump').play();
+ // Flip cat image based on jump direction
+ if (wallX > self.x) {
+ // Jumping right - face right (normal)
+ catGraphics.scaleX = 1;
+ } else {
+ // Jumping left - face left (flipped)
+ catGraphics.scaleX = -1;
+ }
tween(self, {
x: wallX
}, {
duration: 300,