User prompt
zıpladıktan sonra havada çeyrek saniye bekleyelim lütfen
User prompt
kaktüsleri daha sık gönderelim lütfen
User prompt
zıpladıktan sonra havada yarım saniye beklesin
User prompt
zıpladıktan sonra havada 2sn beklesin lütfen
User prompt
kediyi birazdaha yükseğe zıplatırmısın
User prompt
birazdaha yavaş lütfen
User prompt
birazdaha yavaş lütfen
User prompt
oyunu yaparmısın rica etsem
User prompt
Kaktüs Atlama Kedisi
Initial prompt
BİR KEDİ SAĞDAN DOĞRU GELEN KAKTÜSLERİN ÜSTÜNDEN ZIPLAYRAK KAÇMA
/**** * Classes ****/ // Cactus class: moves left, destroys itself off screen var Cactus = Container.expand(function () { var self = Container.call(this); // Attach cactus asset, anchor bottom left var cactusSprite = self.attachAsset('cactus', { anchorX: 0.5, anchorY: 1 }); self.speed = 12 + Math.random() * 4; // slower speed for easier gameplay self.update = function () { self.x -= self.speed; // Destroy if off screen if (self.lastX >= -200 && self.x < -200) { self.destroy(); } self.lastX = self.x; }; return self; }); // Cat class: handles jump, gravity, and collision var Cat = Container.expand(function () { var self = Container.call(this); // Attach cat asset, anchor bottom left for ground logic var catSprite = self.attachAsset('cat', { anchorX: 0.5, anchorY: 1 }); // Cat physics self.y = 0; self.x = 0; self.vy = 0; self.isJumping = false; self.groundY = 0; // will be set after creation // Jump parameters self.jumpVelocity = -55; self.gravity = 4; // Update method for physics self.update = function () { if (self.isJumping) { self.vy += self.gravity; self.y += self.vy; // Land on ground if (self.y >= self.groundY) { self.y = self.groundY; self.vy = 0; self.isJumping = false; } } }; // Jump method self.jump = function () { if (!self.isJumping) { self.isJumping = true; self.vy = self.jumpVelocity; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ ; // --- GAME CODE --- // Game constants var GROUND_Y = 2200; // y position of ground (bottom of screen minus margin) var CAT_START_X = 400; var CAT_START_Y = GROUND_Y; var CACTUS_SPAWN_MIN = 80; // min frames between cacti var CACTUS_SPAWN_MAX = 160; // max frames between cacti // Game state var cat; var cacti = []; var score = 0; var scoreTxt; var nextCactusTick = 0; var gameOver = false; // Add score text to GUI scoreTxt = new Text2('0', { size: 120, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Create cat cat = new Cat(); cat.x = CAT_START_X; cat.y = CAT_START_Y; cat.groundY = CAT_START_Y; game.addChild(cat); // Touch/click to jump game.down = function (x, y, obj) { if (!gameOver) { cat.jump(); } }; // Main update loop game.update = function () { if (gameOver) return; // Update cat cat.update(); // Spawn cactus if (nextCactusTick <= 0) { var cactus = new Cactus(); cactus.x = 2048 + 100; // spawn just off right edge cactus.y = GROUND_Y; cactus.lastX = cactus.x; game.addChild(cactus); cacti.push(cactus); // Next spawn in random interval nextCactusTick = CACTUS_SPAWN_MIN + Math.floor(Math.random() * (CACTUS_SPAWN_MAX - CACTUS_SPAWN_MIN)); } else { nextCactusTick--; } // Update cacti, check for collision and scoring for (var i = cacti.length - 1; i >= 0; i--) { var cactus = cacti[i]; cactus.update(); // Remove if off screen if (cactus.x < -200) { cactus.destroy(); cacti.splice(i, 1); continue; } // Collision detection (only trigger on first intersect) if (!cactus.lastWasIntersecting && cat.intersects(cactus)) { // Game over LK.effects.flashScreen(0xff0000, 800); LK.showGameOver(); gameOver = true; return; } // Scoring: passed cactus (cat.x > cactus.x + cactus.width/2) and not already scored if (!cactus.scored && cat.x > cactus.x + cactus.width / 2) { score++; scoreTxt.setText(score); cactus.scored = true; } cactus.lastWasIntersecting = cat.intersects(cactus); } };
===================================================================
--- original.js
+++ change.js
@@ -8,9 +8,9 @@
var cactusSprite = self.attachAsset('cactus', {
anchorX: 0.5,
anchorY: 1
});
- self.speed = 24 + Math.random() * 8; // randomize speed a bit
+ self.speed = 12 + Math.random() * 4; // slower speed for easier gameplay
self.update = function () {
self.x -= self.speed;
// Destroy if off screen
if (self.lastX >= -200 && self.x < -200) {