/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ // Kaktüs sınıfı var Cactus = Container.expand(function () { var self = Container.call(this); // Kaktüs görseli var cactusSprite = self.attachAsset('cactus', { anchorX: 0.5, anchorY: 1 }); self.isActive = false; // Oyuncuya çarpabilir mi? self.hasHitPlayer = false; // Oyuncuya çarptı mı? // Kaktüs yukarı fırlasın (animasyon) self.popUp = function (fromY, toY, duration) { self.y = fromY; self.visible = true; self.isActive = false; self.hasHitPlayer = false; // Tween ile yukarı çıkar tween(self, { y: toY }, { duration: duration, onFinish: function onFinish() { // Bir süre yukarıda kalıp sonra geri gitsin LK.setTimeout(function () { self.hide(); }, 400); } }); self.isActive = true; }; // Kaktüs geri gizlensin (animasyon) self.hide = function () { if (!self.visible) return; self.isActive = false; // Tween ile aşağı in tween(self, { y: self.y + 180 }, { duration: 220, onFinish: function onFinish() { self.visible = false; } }); }; return self; }); // Oyuncu karakteri sınıfı var Player = Container.expand(function () { var self = Container.call(this); // Oyuncu görseli var playerSprite = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); // Yanıp sönme efekti self.flash = function () { LK.effects.flashObject(self, 0xff0000, 400); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xf7eac6 // Açık bej arka plan }); /**** * Game Code ****/ // Arka plan resmi eklemek için (örnek id, kendi id'nizi kullanabilirsiniz) // Zemin: kahverengi kutu (süsleme) // Kaktüs: yeşil elips (dikey) // Oyuncu karakteri: kırmızı kutu // Oyun alanı boyutları var GAME_WIDTH = 2048; var GAME_HEIGHT = 2732; // Arka plan resmi ekle (değiştirilebilir) var backgroundImageId = 'background'; // Varsayılan arka plan id var backgroundImage = LK.getAsset(backgroundImageId, { anchorX: 0, anchorY: 0, x: 0, y: 0, width: GAME_WIDTH, height: GAME_HEIGHT }); game.addChild(backgroundImage); // Arka plan resmini değiştirmek için fonksiyon function setBackgroundImage(imageId) { if (backgroundImage && backgroundImage.parent) { backgroundImage.parent.removeChild(backgroundImage); } backgroundImageId = imageId; backgroundImage = LK.getAsset(backgroundImageId, { anchorX: 0, anchorY: 0, x: 0, y: 0, width: GAME_WIDTH, height: GAME_HEIGHT }); game.addChildAt(backgroundImage, 0); // En arkaya ekle } // Zemin çiz (tekrarlı şekilde tüm ekran boyunca) var groundTiles = []; var groundAsset = LK.getAsset('ground', { anchorX: 0, anchorY: 1 }); var groundWidth = groundAsset.width; var groundY = GAME_HEIGHT; for (var gx = 0; gx < GAME_WIDTH; gx += groundWidth) { var groundTile = LK.getAsset('ground', { anchorX: 0, anchorY: 1, x: gx, y: groundY }); game.addChild(groundTile); groundTiles.push(groundTile); } // Oyuncu karakterini oluştur ve başlat var player = new Player(); player.x = GAME_WIDTH / 2; player.y = GAME_HEIGHT - 200; game.addChild(player); // Oyuncu canı var maxLives = 3; var lives = maxLives; // Skor var score = 0; // GUI: Skor ve can göstergesi var scoreTxt = new Text2('0', { size: 120, fill: "#222", font: "'GillSans-Bold',Impact,'Arial Black',Tahoma" // Skora özel yazı tipi }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Kalp görselleri için dizi var heartIcons = []; for (var i = 0; i < maxLives; i++) { var heart = LK.getAsset('Kalp', { anchorX: 1, anchorY: 0, x: -i * 110, // Her kalbi sağdan sola aralıklı yerleştir y: 0, scaleX: 0.9, scaleY: 0.9 }); LK.gui.topRight.addChild(heart); heartIcons.push(heart); } // Kaktüsler dizisi var cacti = []; // Kaktüs çıkış noktaları (ekranın alt kısmında, rastgele aralıklarla) var cactusSpots = []; var spotCount = 7; for (var i = 0; i < spotCount; i++) { // Ekranın altına eşit aralıklı noktalar var margin = 180; var x = margin + i * ((GAME_WIDTH - 2 * margin) / (spotCount - 1)); cactusSpots.push(x); } // Kaktüs çıkış hızı ve zorluk var cactusInterval = 1200; // ms var cactusSpeed = 350; // ms var minCactusInterval = 400; var minCactusSpeed = 180; var cactusTimer = null; var gameTime = 0; // Sürükleme için var dragNode = null; var offsetX = 0, offsetY = 0; // Ok butonları için var leftArrowBtn = LK.getAsset('arrow_left', { anchorX: 0.5, anchorY: 0.5, x: GAME_WIDTH / 2 - 400, y: GAME_HEIGHT / 2 + 700 //{19} // YUKARI ALINDI }); var rightArrowBtn = LK.getAsset('arrow_right', { anchorX: 0.5, anchorY: 0.5, x: GAME_WIDTH / 2 + 400, y: GAME_HEIGHT / 2 + 700 //{1d} // YUKARI ALINDI }); game.addChild(leftArrowBtn); game.addChild(rightArrowBtn); // Ok butonlarının üstüne ok işareti çizmek için Text2 // Ok butonlarına basınca hareket için var arrowMoveStep = 180; // Her basışta kayacağı mesafe // Butonlara basıldığında kontrol // Sürekli hareket için zamanlayıcılar var moveDir = 0; // -1: sola, 1: sağa, 0: dur var moveTimer = null; var moveSpeed = 7; // px per frame function startMove(dir) { if (isGameOver) return; moveDir = dir; if (moveTimer) return; // Zaten hareket ediyorsa tekrar başlatma moveTimer = LK.setInterval(function () { if (isGameOver) { stopMove(); return; } // Sadece ok tuşuna basılıysa hareket et if (moveDir !== 0) { var nextX = player.x + moveDir * moveSpeed; player.x = Math.max(80, Math.min(GAME_WIDTH - 80, nextX)); } }, 16); // ~60fps } function stopMove() { moveDir = 0; if (moveTimer) { LK.clearInterval(moveTimer); moveTimer = null; } } // Ok butonlarına basınca sürekli hareket başlat leftArrowBtn.down = function (x, y, obj) { if (isGameOver) return; startMove(-1); }; rightArrowBtn.down = function (x, y, obj) { if (isGameOver) return; startMove(1); }; // Ok butonundan parmak kaldırınca hareketi durdur leftArrowBtn.up = function (x, y, obj) { stopMove(); }; rightArrowBtn.up = function (x, y, obj) { stopMove(); }; // Oyun bitti mi? var isGameOver = false; // Skor ve can güncelle function updateScoreAndLives() { scoreTxt.setText(score); // Kalp görsellerinin görünürlüğünü güncelle for (var i = 0; i < heartIcons.length; i++) { heartIcons[i].visible = i < lives; } } // Kaktüs oluştur ve fırlat (1 veya 2 tane, 1.5 saniye içinde) function spawnCactus() { // 1 veya 2 kaktüs çıkacak (rastgele) var cactusCount = 1 + Math.floor(Math.random() * 2); // 1 veya 2 // Çıkış noktalarını karıştır var availableSpots = []; for (var i = 0; i < cactusSpots.length; i++) availableSpots.push(i); // Fisher-Yates shuffle for (var i = availableSpots.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = availableSpots[i]; availableSpots[i] = availableSpots[j]; availableSpots[j] = temp; } var groundY = GAME_HEIGHT - 80; for (var c = 0; c < cactusCount; c++) { (function (delay, spotIdx) { LK.setTimeout(function () { var x = cactusSpots[spotIdx]; var cactus = new Cactus(); cactus.x = x; cactus.y = groundY + 120; // Zemin altından başlasın cactus.lastY = cactus.y; // lastY başlat game.addChild(cactus); cacti.push(cactus); cactus.popUp(groundY + 120, groundY - 10, cactusSpeed); }, delay); })(c * 3500 / cactusCount, availableSpots[c]); } } // Kaktüsleri temizle function clearCacti() { for (var i = cacti.length - 1; i >= 0; i--) { cacti[i].destroy(); cacti.splice(i, 1); } } // Kaktüs çıkışlarını başlat function startCactusSpawning() { if (cactusTimer) LK.clearInterval(cactusTimer); cactusTimer = LK.setInterval(function () { // Zaman ilerledikçe zorluk artsın gameTime += cactusInterval; // Her 10 saniyede bir hız ve sıklık artsın if (gameTime % 10000 === 0 && cactusInterval > minCactusInterval) { cactusInterval -= 100; if (cactusInterval < minCactusInterval) cactusInterval = minCactusInterval; cactusSpeed -= 20; if (cactusSpeed < minCactusSpeed) cactusSpeed = minCactusSpeed; // Timer'ı güncelle startCactusSpawning(); } // Aynı anda birden fazla kaktüs çıkabilir (zorluk için) var multi = 1; if (gameTime > 15000) multi = 2; if (gameTime > 30000) multi = 3; for (var m = 0; m < multi; m++) { spawnCactus(); } }, cactusInterval); } // Oyun başlat function startGame() { isGameOver = false; score = 0; lives = maxLives; updateScoreAndLives(); clearCacti(); cactusInterval = 1200; cactusSpeed = 350; gameTime = 0; startCactusSpawning(); player.x = GAME_WIDTH / 2; player.y = GAME_HEIGHT - 200; // BGMusic başlat (oyun boyunca çalsın) LK.playMusic('BGMusic'); } // Oyun bitişi function endGame() { isGameOver = true; if (cactusTimer) LK.clearInterval(cactusTimer); clearCacti(); // Play GameOver sound LK.getSound('GameOver').play(); // Play Bomba Patlama sound LK.getSound('Bomba Patlama').play(); // BGMusic durdur LK.stopMusic(); LK.effects.flashScreen(0xff0000, 800); LK.showGameOver(); } // Sürükleme işlemleri game.down = function (x, y, obj) { // Eğer ok butonlarından birine tıklandıysa sürükleme başlatma if (obj === leftArrowBtn || obj === rightArrowBtn) { // Ok butonları kendi hareketini zaten yapıyor, burada sürükleme başlatma return; } stopMove(); // Sürükleme başlarsa ok hareketini durdur // Oyuncuya tıklanırsa sürükleme başlasın var local = player.toLocal({ x: x, y: y }); // Oyuncunun alanı içinde mi? if (Math.abs(local.x) <= 80 && Math.abs(local.y) <= 80) { dragNode = player; offsetX = player.x - x; offsetY = player.y - y; } }; game.up = function (x, y, obj) { dragNode = null; stopMove(); }; function handleMove(x, y, obj) { if (dragNode && !isGameOver) { // Oyuncuyu yeni konuma taşı var nx = x + offsetX; var ny = y + offsetY; // Sınırları aşmasın var px = Math.max(80, Math.min(GAME_WIDTH - 80, nx)); var py = Math.max(120, Math.min(GAME_HEIGHT - 200, ny)); player.x = px; player.y = py; } } game.move = handleMove; // Oyun döngüsü game.update = function () { if (isGameOver) return; // Kaktüsler ile çarpışma kontrolü for (var i = cacti.length - 1; i >= 0; i--) { var cactus = cacti[i]; // Sadece aktif (yukarıda) olanlar tehlikeli if (cactus.isActive && !cactus.hasHitPlayer && player.intersects(cactus)) { cactus.hasHitPlayer = true; // Sadece bir kez çarpsın cactus.isActive = false; cactus.hide(); // Kaktüs geri gitsin lives -= 1; player.flash(); // Hasar sesi çal LK.getSound('Kill').play(); updateScoreAndLives(); if (lives <= 0) { endGame(); return; } } // Kaktüs tamamen gizlendiyse sil (tam olarak bu frame'de geçtiyse) if (!cactus.isActive) { if (cactus.lastY === undefined) cactus.lastY = cactus.y; var hideY = GAME_HEIGHT - 80 + 100; if (cactus.lastY < hideY && cactus.y >= hideY) { cactus.destroy(); cacti.splice(i, 1); // Skor artır (kaçılan kaktüs) score += 1; updateScoreAndLives(); } cactus.lastY = cactus.y; } } }; // Menü kodları kaldırıldı, oyun doğrudan başlar startGame();
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
// Kaktüs sınıfı
var Cactus = Container.expand(function () {
var self = Container.call(this);
// Kaktüs görseli
var cactusSprite = self.attachAsset('cactus', {
anchorX: 0.5,
anchorY: 1
});
self.isActive = false; // Oyuncuya çarpabilir mi?
self.hasHitPlayer = false; // Oyuncuya çarptı mı?
// Kaktüs yukarı fırlasın (animasyon)
self.popUp = function (fromY, toY, duration) {
self.y = fromY;
self.visible = true;
self.isActive = false;
self.hasHitPlayer = false;
// Tween ile yukarı çıkar
tween(self, {
y: toY
}, {
duration: duration,
onFinish: function onFinish() {
// Bir süre yukarıda kalıp sonra geri gitsin
LK.setTimeout(function () {
self.hide();
}, 400);
}
});
self.isActive = true;
};
// Kaktüs geri gizlensin (animasyon)
self.hide = function () {
if (!self.visible) return;
self.isActive = false;
// Tween ile aşağı in
tween(self, {
y: self.y + 180
}, {
duration: 220,
onFinish: function onFinish() {
self.visible = false;
}
});
};
return self;
});
// Oyuncu karakteri sınıfı
var Player = Container.expand(function () {
var self = Container.call(this);
// Oyuncu görseli
var playerSprite = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
// Yanıp sönme efekti
self.flash = function () {
LK.effects.flashObject(self, 0xff0000, 400);
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xf7eac6 // Açık bej arka plan
});
/****
* Game Code
****/
// Arka plan resmi eklemek için (örnek id, kendi id'nizi kullanabilirsiniz)
// Zemin: kahverengi kutu (süsleme)
// Kaktüs: yeşil elips (dikey)
// Oyuncu karakteri: kırmızı kutu
// Oyun alanı boyutları
var GAME_WIDTH = 2048;
var GAME_HEIGHT = 2732;
// Arka plan resmi ekle (değiştirilebilir)
var backgroundImageId = 'background'; // Varsayılan arka plan id
var backgroundImage = LK.getAsset(backgroundImageId, {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0,
width: GAME_WIDTH,
height: GAME_HEIGHT
});
game.addChild(backgroundImage);
// Arka plan resmini değiştirmek için fonksiyon
function setBackgroundImage(imageId) {
if (backgroundImage && backgroundImage.parent) {
backgroundImage.parent.removeChild(backgroundImage);
}
backgroundImageId = imageId;
backgroundImage = LK.getAsset(backgroundImageId, {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0,
width: GAME_WIDTH,
height: GAME_HEIGHT
});
game.addChildAt(backgroundImage, 0); // En arkaya ekle
}
// Zemin çiz (tekrarlı şekilde tüm ekran boyunca)
var groundTiles = [];
var groundAsset = LK.getAsset('ground', {
anchorX: 0,
anchorY: 1
});
var groundWidth = groundAsset.width;
var groundY = GAME_HEIGHT;
for (var gx = 0; gx < GAME_WIDTH; gx += groundWidth) {
var groundTile = LK.getAsset('ground', {
anchorX: 0,
anchorY: 1,
x: gx,
y: groundY
});
game.addChild(groundTile);
groundTiles.push(groundTile);
}
// Oyuncu karakterini oluştur ve başlat
var player = new Player();
player.x = GAME_WIDTH / 2;
player.y = GAME_HEIGHT - 200;
game.addChild(player);
// Oyuncu canı
var maxLives = 3;
var lives = maxLives;
// Skor
var score = 0;
// GUI: Skor ve can göstergesi
var scoreTxt = new Text2('0', {
size: 120,
fill: "#222",
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma" // Skora özel yazı tipi
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Kalp görselleri için dizi
var heartIcons = [];
for (var i = 0; i < maxLives; i++) {
var heart = LK.getAsset('Kalp', {
anchorX: 1,
anchorY: 0,
x: -i * 110,
// Her kalbi sağdan sola aralıklı yerleştir
y: 0,
scaleX: 0.9,
scaleY: 0.9
});
LK.gui.topRight.addChild(heart);
heartIcons.push(heart);
}
// Kaktüsler dizisi
var cacti = [];
// Kaktüs çıkış noktaları (ekranın alt kısmında, rastgele aralıklarla)
var cactusSpots = [];
var spotCount = 7;
for (var i = 0; i < spotCount; i++) {
// Ekranın altına eşit aralıklı noktalar
var margin = 180;
var x = margin + i * ((GAME_WIDTH - 2 * margin) / (spotCount - 1));
cactusSpots.push(x);
}
// Kaktüs çıkış hızı ve zorluk
var cactusInterval = 1200; // ms
var cactusSpeed = 350; // ms
var minCactusInterval = 400;
var minCactusSpeed = 180;
var cactusTimer = null;
var gameTime = 0;
// Sürükleme için
var dragNode = null;
var offsetX = 0,
offsetY = 0;
// Ok butonları için
var leftArrowBtn = LK.getAsset('arrow_left', {
anchorX: 0.5,
anchorY: 0.5,
x: GAME_WIDTH / 2 - 400,
y: GAME_HEIGHT / 2 + 700 //{19} // YUKARI ALINDI
});
var rightArrowBtn = LK.getAsset('arrow_right', {
anchorX: 0.5,
anchorY: 0.5,
x: GAME_WIDTH / 2 + 400,
y: GAME_HEIGHT / 2 + 700 //{1d} // YUKARI ALINDI
});
game.addChild(leftArrowBtn);
game.addChild(rightArrowBtn);
// Ok butonlarının üstüne ok işareti çizmek için Text2
// Ok butonlarına basınca hareket için
var arrowMoveStep = 180; // Her basışta kayacağı mesafe
// Butonlara basıldığında kontrol
// Sürekli hareket için zamanlayıcılar
var moveDir = 0; // -1: sola, 1: sağa, 0: dur
var moveTimer = null;
var moveSpeed = 7; // px per frame
function startMove(dir) {
if (isGameOver) return;
moveDir = dir;
if (moveTimer) return; // Zaten hareket ediyorsa tekrar başlatma
moveTimer = LK.setInterval(function () {
if (isGameOver) {
stopMove();
return;
}
// Sadece ok tuşuna basılıysa hareket et
if (moveDir !== 0) {
var nextX = player.x + moveDir * moveSpeed;
player.x = Math.max(80, Math.min(GAME_WIDTH - 80, nextX));
}
}, 16); // ~60fps
}
function stopMove() {
moveDir = 0;
if (moveTimer) {
LK.clearInterval(moveTimer);
moveTimer = null;
}
}
// Ok butonlarına basınca sürekli hareket başlat
leftArrowBtn.down = function (x, y, obj) {
if (isGameOver) return;
startMove(-1);
};
rightArrowBtn.down = function (x, y, obj) {
if (isGameOver) return;
startMove(1);
};
// Ok butonundan parmak kaldırınca hareketi durdur
leftArrowBtn.up = function (x, y, obj) {
stopMove();
};
rightArrowBtn.up = function (x, y, obj) {
stopMove();
};
// Oyun bitti mi?
var isGameOver = false;
// Skor ve can güncelle
function updateScoreAndLives() {
scoreTxt.setText(score);
// Kalp görsellerinin görünürlüğünü güncelle
for (var i = 0; i < heartIcons.length; i++) {
heartIcons[i].visible = i < lives;
}
}
// Kaktüs oluştur ve fırlat (1 veya 2 tane, 1.5 saniye içinde)
function spawnCactus() {
// 1 veya 2 kaktüs çıkacak (rastgele)
var cactusCount = 1 + Math.floor(Math.random() * 2); // 1 veya 2
// Çıkış noktalarını karıştır
var availableSpots = [];
for (var i = 0; i < cactusSpots.length; i++) availableSpots.push(i);
// Fisher-Yates shuffle
for (var i = availableSpots.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = availableSpots[i];
availableSpots[i] = availableSpots[j];
availableSpots[j] = temp;
}
var groundY = GAME_HEIGHT - 80;
for (var c = 0; c < cactusCount; c++) {
(function (delay, spotIdx) {
LK.setTimeout(function () {
var x = cactusSpots[spotIdx];
var cactus = new Cactus();
cactus.x = x;
cactus.y = groundY + 120; // Zemin altından başlasın
cactus.lastY = cactus.y; // lastY başlat
game.addChild(cactus);
cacti.push(cactus);
cactus.popUp(groundY + 120, groundY - 10, cactusSpeed);
}, delay);
})(c * 3500 / cactusCount, availableSpots[c]);
}
}
// Kaktüsleri temizle
function clearCacti() {
for (var i = cacti.length - 1; i >= 0; i--) {
cacti[i].destroy();
cacti.splice(i, 1);
}
}
// Kaktüs çıkışlarını başlat
function startCactusSpawning() {
if (cactusTimer) LK.clearInterval(cactusTimer);
cactusTimer = LK.setInterval(function () {
// Zaman ilerledikçe zorluk artsın
gameTime += cactusInterval;
// Her 10 saniyede bir hız ve sıklık artsın
if (gameTime % 10000 === 0 && cactusInterval > minCactusInterval) {
cactusInterval -= 100;
if (cactusInterval < minCactusInterval) cactusInterval = minCactusInterval;
cactusSpeed -= 20;
if (cactusSpeed < minCactusSpeed) cactusSpeed = minCactusSpeed;
// Timer'ı güncelle
startCactusSpawning();
}
// Aynı anda birden fazla kaktüs çıkabilir (zorluk için)
var multi = 1;
if (gameTime > 15000) multi = 2;
if (gameTime > 30000) multi = 3;
for (var m = 0; m < multi; m++) {
spawnCactus();
}
}, cactusInterval);
}
// Oyun başlat
function startGame() {
isGameOver = false;
score = 0;
lives = maxLives;
updateScoreAndLives();
clearCacti();
cactusInterval = 1200;
cactusSpeed = 350;
gameTime = 0;
startCactusSpawning();
player.x = GAME_WIDTH / 2;
player.y = GAME_HEIGHT - 200;
// BGMusic başlat (oyun boyunca çalsın)
LK.playMusic('BGMusic');
}
// Oyun bitişi
function endGame() {
isGameOver = true;
if (cactusTimer) LK.clearInterval(cactusTimer);
clearCacti();
// Play GameOver sound
LK.getSound('GameOver').play();
// Play Bomba Patlama sound
LK.getSound('Bomba Patlama').play();
// BGMusic durdur
LK.stopMusic();
LK.effects.flashScreen(0xff0000, 800);
LK.showGameOver();
}
// Sürükleme işlemleri
game.down = function (x, y, obj) {
// Eğer ok butonlarından birine tıklandıysa sürükleme başlatma
if (obj === leftArrowBtn || obj === rightArrowBtn) {
// Ok butonları kendi hareketini zaten yapıyor, burada sürükleme başlatma
return;
}
stopMove(); // Sürükleme başlarsa ok hareketini durdur
// Oyuncuya tıklanırsa sürükleme başlasın
var local = player.toLocal({
x: x,
y: y
});
// Oyuncunun alanı içinde mi?
if (Math.abs(local.x) <= 80 && Math.abs(local.y) <= 80) {
dragNode = player;
offsetX = player.x - x;
offsetY = player.y - y;
}
};
game.up = function (x, y, obj) {
dragNode = null;
stopMove();
};
function handleMove(x, y, obj) {
if (dragNode && !isGameOver) {
// Oyuncuyu yeni konuma taşı
var nx = x + offsetX;
var ny = y + offsetY;
// Sınırları aşmasın
var px = Math.max(80, Math.min(GAME_WIDTH - 80, nx));
var py = Math.max(120, Math.min(GAME_HEIGHT - 200, ny));
player.x = px;
player.y = py;
}
}
game.move = handleMove;
// Oyun döngüsü
game.update = function () {
if (isGameOver) return;
// Kaktüsler ile çarpışma kontrolü
for (var i = cacti.length - 1; i >= 0; i--) {
var cactus = cacti[i];
// Sadece aktif (yukarıda) olanlar tehlikeli
if (cactus.isActive && !cactus.hasHitPlayer && player.intersects(cactus)) {
cactus.hasHitPlayer = true; // Sadece bir kez çarpsın
cactus.isActive = false;
cactus.hide(); // Kaktüs geri gitsin
lives -= 1;
player.flash();
// Hasar sesi çal
LK.getSound('Kill').play();
updateScoreAndLives();
if (lives <= 0) {
endGame();
return;
}
}
// Kaktüs tamamen gizlendiyse sil (tam olarak bu frame'de geçtiyse)
if (!cactus.isActive) {
if (cactus.lastY === undefined) cactus.lastY = cactus.y;
var hideY = GAME_HEIGHT - 80 + 100;
if (cactus.lastY < hideY && cactus.y >= hideY) {
cactus.destroy();
cacti.splice(i, 1);
// Skor artır (kaçılan kaktüs)
score += 1;
updateScoreAndLives();
}
cactus.lastY = cactus.y;
}
}
};
// Menü kodları kaldırıldı, oyun doğrudan başlar
startGame();
Sağ ok. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Kaktüs. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Kalp. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Su damlası. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Çöl. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Kumlu Zemin. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat