User prompt
engellerin arasını biraz daha sıkı olsun
User prompt
boşlukları engellerle dolduralım
User prompt
karakter dönsün ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
kalplerin boyutu 2 kat büyüsün ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
her engeli geçtiğimizde puanımız atrtın
User prompt
eğer kalbi alamazsak 1 sonraki engelde 2 kalp olsun
User prompt
max can olmasın
User prompt
engelin içinde kalp olmasın 30 piksel ilerininde olsun
User prompt
kalpleri her engelden sonra 1 tane olsun
User prompt
kalpler olsun o kalpleri alınca canımız artsın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
arka planda geometrik şekiller olsun
User prompt
game ver ekranı oyunun ilk hali gibi olsun
User prompt
game over ekranını eski haline getir
User prompt
levels tuşu yok game over ekranında
User prompt
her elendiğimizde 1. levelden başlasın leveller arasın da bir kapı olsun ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
select level ekranını kaldır
User prompt
böyle değil tekrar oynanın yanına gelsin level tuşu
User prompt
oyun bitti ekranına level butonu olsun levelleri ordan görelim
User prompt
kuş yere değdiğinde oyun bitsin
User prompt
level 4 ün başında engel sıklığını azaltalım
User prompt
level 4 te karakterin güncel olarak ulunduğu yerde engel yok buraya engel koyalım
User prompt
level 4 te çok boş alan var orayı engelle dolduralım
User prompt
dişliyi kaldıralım
User prompt
game over ekranı gözükmüyor kontrol edebilirmisiniz
User prompt
platform eklenmemiş
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { currentLevel: 1, unlockedLevels: 1, totalScore: 0 }); /**** * Classes ****/ var Bird = Container.expand(function () { var self = Container.call(this); var birdGraphics = self.attachAsset('bird', { anchorX: 0.5, anchorY: 0.5 }); // Ensure bird is visible birdGraphics.alpha = 1.0; birdGraphics.visible = true; self.velocityY = 0; self.gravity = 0.8; self.flapPower = -12; self.rotation = 0; self.rotationVelocity = 0; self.isFlipping = false; self.completedFlips = 0; self.lastUpright = true; self.flap = function () { self.velocityY = self.flapPower; LK.getSound('flap').play(); }; self.update = function () { // Apply gravity self.velocityY += self.gravity; self.y += self.velocityY; // Keep bird graphics without rotation birdGraphics.rotation = 0; // Keep bird in bounds horizontally if (self.x < 40) self.x = 40; if (self.x > 2008) self.x = 2008; }; self.isUpright = function () { var normalizedRotation = self.rotation % (Math.PI * 2); return normalizedRotation < 0.3 || normalizedRotation > Math.PI * 2 - 0.3; }; return self; }); var Obstacle = Container.expand(function () { var self = Container.call(this); // Choose obstacle type from level-specific sequence var randomType = 'block'; // Default fallback if (levelObstacleTypes.length > 0) { var typeIndex = obstacleCounter % levelObstacleTypes.length; randomType = levelObstacleTypes[typeIndex]; } var obstacleGraphics = self.attachAsset(randomType, { anchorX: 0.5, anchorY: 0.5 }); self.speed = -3; self.passed = false; self.obstacleType = randomType; // Add visual effects for Geometry Dash style self.pulseScale = 1; self.pulseDirection = 1; self.rotationSpeed = 0; self.isStationary = false; // Set rotation speed for certain types if (randomType === 'spike' || randomType === 'block') { self.rotationSpeed = 0.02; } // Set gear-specific properties if (randomType === 'gear') { self.rotationSpeed = 0.05; // Faster rotation for gears self.speed = 0; // Gears don't move horizontally self.isStationary = true; } // Set rest platform specific properties if (randomType === 'restPlatform') { self.speed = 0; // Rest platforms don't move horizontally self.isStationary = true; self.isSafe = true; // Mark as safe platform } self.update = function () { // Only move if not stationary if (!self.isStationary) { self.x += self.speed; } // Add pulsing effect only for non-gear and non-rest platform obstacles if (self.obstacleType !== 'gear' && self.obstacleType !== 'restPlatform') { self.pulseScale += 0.005 * self.pulseDirection; if (self.pulseScale > 1.05) self.pulseDirection = -1; if (self.pulseScale < 0.98) self.pulseDirection = 1; obstacleGraphics.scaleX = self.pulseScale; obstacleGraphics.scaleY = self.pulseScale; } // Add rotation for certain obstacles if (self.rotationSpeed > 0) { obstacleGraphics.rotation += self.rotationSpeed; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ var bird; var obstacles = []; var ground; var gameStarted = false; var lastObstacle = 0; var obstacleSpacing = 400; var currentLevel = storage.currentLevel || 1; var unlockedLevels = storage.unlockedLevels || 1; var totalScore = storage.totalScore || 0; var levelScoreThreshold = 10; // Score needed to unlock next level var obstacleCounter = 0; // Counter for obstacle generation var levelObstacleTypes = []; // Array to store shuffled obstacle types for current level var playerHealth = 3; // Player starts with 3 lives var maxHealth = 3; // Maximum health // Create score display var scoreTxt = new Text2('0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); scoreTxt.y = 100; // Create level display var levelTxt = new Text2('Level ' + currentLevel, { size: 60, fill: 0xFFD700 }); levelTxt.anchor.set(0.5, 0); LK.gui.top.addChild(levelTxt); levelTxt.y = 200; // Create level progress display var progressTxt = new Text2('Progress: 0/' + levelScoreThreshold, { size: 40, fill: 0xFFFFFF }); progressTxt.anchor.set(0.5, 0); LK.gui.top.addChild(progressTxt); progressTxt.y = 280; // Create health display var healthTxt = new Text2('Lives: ' + playerHealth, { size: 50, fill: 0xff0000 }); healthTxt.anchor.set(0.5, 0); LK.gui.top.addChild(healthTxt); healthTxt.y = 340; // Create instructions var instructionTxt = new Text2('TAP TO FLIP AND FLY\nBOUNCE OFF OBSTACLES!', { size: 60, fill: 0xFFFFFF }); instructionTxt.anchor.set(0.5, 0.5); game.addChild(instructionTxt); instructionTxt.x = 1024; instructionTxt.y = 1000; // Create ground ground = game.addChild(LK.getAsset('ground', { anchorX: 0, anchorY: 0 })); ground.x = 0; ground.y = 2632; // Create bird bird = game.addChild(new Bird()); bird.x = 300; bird.y = 800; // Generate initial obstacle sequence for current level generateLevelObstacleSequence(); // Create initial obstacles at game start createObstacle(); function generateLevelObstacleSequence() { levelObstacleTypes = []; var baseTypes = ['spike', 'block', 'tallBlock', 'platform', 'gear', 'restPlatform', 'restPlatform', 'restPlatform']; // Added more rest platforms for higher frequency var sequenceLength = 50; // Generate enough types for a full level var seed = currentLevel * 12345; // Level-based seed for consistent sequences for (var i = 0; i < sequenceLength; i++) { seed = (seed * 9301 + 49297) % 233280; var randomIndex = Math.floor(seed / 233280 * baseTypes.length); levelObstacleTypes.push(baseTypes[randomIndex]); } } function updateLevelProgress() { var levelProgress = LK.getScore(); var progressNeeded = levelScoreThreshold * currentLevel; // Update progress display progressTxt.setText('Progress: ' + levelProgress + '/' + progressNeeded); // Check if level is completed if (levelProgress >= progressNeeded) { // Level completed totalScore += levelProgress; storage.totalScore = totalScore; // Unlock next level if not already unlocked if (currentLevel >= unlockedLevels) { unlockedLevels = currentLevel + 1; storage.unlockedLevels = unlockedLevels; LK.effects.flashScreen(0x00ff00, 1000); // Green flash for level completion } // Advance to next level currentLevel++; storage.currentLevel = currentLevel; levelTxt.setText('Level ' + currentLevel); // Reset score for new level LK.setScore(0); scoreTxt.setText(0); // Reset obstacle counter for consistent level maps obstacleCounter = 0; // Generate new obstacle sequence for the new level generateLevelObstacleSequence(); updateLevelProgress(); // Increase difficulty for new level updateDifficultyForLevel(); } } function updateDifficultyForLevel() { // Each level increases difficulty var difficultyMultiplier = 1 + (currentLevel - 1) * 0.3; // Adjust obstacle spacing based on level obstacleSpacing = Math.max(200, 400 - (currentLevel - 1) * 20); // Adjust bird physics slightly for higher levels if (currentLevel > 3) { bird.gravity = 0.8 + (currentLevel - 3) * 0.1; } } function resetToLevelStart() { // Reset score to level start LK.setScore(0); scoreTxt.setText(0); // Reset health playerHealth = maxHealth; healthTxt.setText('Lives: ' + playerHealth); // Clear all obstacles for (var i = obstacles.length - 1; i >= 0; i--) { obstacles[i].destroy(); obstacles.splice(i, 1); } // Reset obstacle counter obstacleCounter = 0; // Reset bird position bird.x = 300; bird.y = 800; bird.velocityY = 0; bird.completedFlips = 0; // Regenerate obstacle sequence for current level generateLevelObstacleSequence(); // Update displays updateLevelProgress(); // Create initial obstacle createObstacle(); } function takeDamage() { playerHealth--; healthTxt.setText('Lives: ' + playerHealth); // Flash screen red when taking damage tween(game, { tint: 0xff4444 }, { duration: 200, onFinish: function onFinish() { tween(game, { tint: 0xffffff }, { duration: 200 }); } }); // Check if game over if (playerHealth <= 0) { resetToLevelStart(); } } function resetHealth() { playerHealth = maxHealth; healthTxt.setText('Lives: ' + playerHealth); } function startGame() { if (!gameStarted) { gameStarted = true; game.removeChild(instructionTxt); // Reset obstacle counter for consistent level maps obstacleCounter = 0; // Generate obstacle sequence for current level generateLevelObstacleSequence(); resetHealth(); // Reset health when starting game updateDifficultyForLevel(); updateLevelProgress(); } } function createObstacle() { // Create walls that cover full screen with a gap for the bird var baseX = 2148; var gapSize = 400; // Size of the gap for bird to pass through (increased for larger bird) // Use seeded random based on current level and obstacle counter for consistent maps var seed = (currentLevel * 1000 + obstacleCounter) % 9973; // Use prime number for better distribution var seededRandom = (seed * 9301 + 49297) % 233280 / 233280; // Linear congruential generator var gapPosition = seededRandom * (2200 - gapSize) + 300; // Seeded gap position between 300-2200 var obstacleHeight = 400; // Height of each obstacle segment var numSegments = Math.ceil(2732 / obstacleHeight); // Number of segments to cover full height for (var i = 0; i < numSegments; i++) { var segmentY = i * obstacleHeight + obstacleHeight / 2; // Skip creating obstacles in the gap area if (segmentY + obstacleHeight / 2 > gapPosition && segmentY - obstacleHeight / 2 < gapPosition + gapSize) { continue; } var obstacle = new Obstacle(); obstacle.x = baseX; obstacle.y = segmentY; obstacles.push(obstacle); game.addChild(obstacle); } obstacleCounter++; lastObstacle = LK.ticks; } function checkCollisions() { // Check ground collision if (bird.y + 60 >= ground.y) { if (!bird.isUpright()) { takeDamage(); if (playerHealth > 0) { // Push bird back up if still alive bird.velocityY = -12; bird.y = ground.y - 60; } return; } else { // Successful landing - award points if (bird.completedFlips > 0) { LK.setScore(LK.getScore() + bird.completedFlips); scoreTxt.setText(LK.getScore()); LK.getSound('score').play(); updateLevelProgress(); bird.completedFlips = 0; // Bounce back up bird.velocityY = -8; bird.y = ground.y - 60; } } } // Check obstacle collisions - bounce off obstacles for (var i = obstacles.length - 1; i >= 0; i--) { var obstacle = obstacles[i]; // Skip if obstacle is undefined if (!obstacle) { obstacles.splice(i, 1); continue; } if (bird.intersects(obstacle)) { // Check if it's a gear - immediate elimination if (obstacle.obstacleType === 'gear') { // Flash screen red and reset to level start LK.effects.flashScreen(0xff0000, 500); resetToLevelStart(); return; } // Check if it's a rest platform - safe area if (obstacle.obstacleType === 'restPlatform') { // Safe collision - just bounce without damage var distanceX = bird.x - obstacle.x; var distanceY = bird.y - obstacle.y; var totalDistance = Math.sqrt(distanceX * distanceX + distanceY * distanceY); if (totalDistance > 0) { var normalX = distanceX / totalDistance; var normalY = distanceY / totalDistance; // Gentle push away from platform var pushForce = 3; bird.x += normalX * pushForce; bird.y += normalY * pushForce; // Apply gentle bounce velocity bird.velocityY = normalY * 3; // Visual feedback for landing on safe platform LK.effects.flashObject(obstacle, 0x00ff88, 300); } continue; // Skip damage dealing } // Only take damage if not already damaged from this obstacle if (!obstacle.damagedBird) { takeDamage(); obstacle.damagedBird = true; // Mark this obstacle as having caused damage } // Calculate collision direction var distanceX = bird.x - obstacle.x; var distanceY = bird.y - obstacle.y; var totalDistance = Math.sqrt(distanceX * distanceX + distanceY * distanceY); // Normalize collision direction if (totalDistance > 0) { var normalX = distanceX / totalDistance; var normalY = distanceY / totalDistance; // Push bird away from obstacle var pushForce = 8; bird.x += normalX * pushForce; bird.y += normalY * pushForce; // Apply bounce velocity var bounceForce = 5; bird.velocityY = normalY * bounceForce; // Play flap sound for bounce feedback LK.getSound('flap').play(); } } // Check if bird passed obstacle if (!obstacle.passed && obstacle.x + 100 < bird.x) { obstacle.passed = true; if (bird.isUpright() && bird.completedFlips > 0) { LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); LK.getSound('score').play(); updateLevelProgress(); } } // Remove off-screen obstacles (but keep stationary gears and rest platforms) if (obstacle.x < -100 && !obstacle.isStationary) { // Add flash effect when obstacle disappears LK.effects.flashObject(obstacle, 0xffffff, 200); obstacle.destroy(); obstacles.splice(i, 1); } } // Check ceiling collision if (bird.y < 50) { bird.y = 50; bird.velocityY = 0; } } game.down = function (x, y, obj) { if (!gameStarted) { startGame(); } bird.flap(); }; game.update = function () { if (!gameStarted) return; // Create obstacles if (LK.ticks - lastObstacle > obstacleSpacing) { createObstacle(); } // Update bird physics bird.update(); // Update obstacles for (var i = 0; i < obstacles.length; i++) { obstacles[i].update(); } // Check collisions checkCollisions(); // Level-based difficulty progression var baseSpacing = 400 - (currentLevel - 1) * 20; var minSpacing = Math.max(200, 300 - (currentLevel - 1) * 10); var reductionRate = 1 + currentLevel; // Increase reduction rate with level var currentSpacing = baseSpacing - LK.getScore() * reductionRate; obstacleSpacing = Math.max(minSpacing, currentSpacing); };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
currentLevel: 1,
unlockedLevels: 1,
totalScore: 0
});
/****
* Classes
****/
var Bird = Container.expand(function () {
var self = Container.call(this);
var birdGraphics = self.attachAsset('bird', {
anchorX: 0.5,
anchorY: 0.5
});
// Ensure bird is visible
birdGraphics.alpha = 1.0;
birdGraphics.visible = true;
self.velocityY = 0;
self.gravity = 0.8;
self.flapPower = -12;
self.rotation = 0;
self.rotationVelocity = 0;
self.isFlipping = false;
self.completedFlips = 0;
self.lastUpright = true;
self.flap = function () {
self.velocityY = self.flapPower;
LK.getSound('flap').play();
};
self.update = function () {
// Apply gravity
self.velocityY += self.gravity;
self.y += self.velocityY;
// Keep bird graphics without rotation
birdGraphics.rotation = 0;
// Keep bird in bounds horizontally
if (self.x < 40) self.x = 40;
if (self.x > 2008) self.x = 2008;
};
self.isUpright = function () {
var normalizedRotation = self.rotation % (Math.PI * 2);
return normalizedRotation < 0.3 || normalizedRotation > Math.PI * 2 - 0.3;
};
return self;
});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
// Choose obstacle type from level-specific sequence
var randomType = 'block'; // Default fallback
if (levelObstacleTypes.length > 0) {
var typeIndex = obstacleCounter % levelObstacleTypes.length;
randomType = levelObstacleTypes[typeIndex];
}
var obstacleGraphics = self.attachAsset(randomType, {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -3;
self.passed = false;
self.obstacleType = randomType;
// Add visual effects for Geometry Dash style
self.pulseScale = 1;
self.pulseDirection = 1;
self.rotationSpeed = 0;
self.isStationary = false;
// Set rotation speed for certain types
if (randomType === 'spike' || randomType === 'block') {
self.rotationSpeed = 0.02;
}
// Set gear-specific properties
if (randomType === 'gear') {
self.rotationSpeed = 0.05; // Faster rotation for gears
self.speed = 0; // Gears don't move horizontally
self.isStationary = true;
}
// Set rest platform specific properties
if (randomType === 'restPlatform') {
self.speed = 0; // Rest platforms don't move horizontally
self.isStationary = true;
self.isSafe = true; // Mark as safe platform
}
self.update = function () {
// Only move if not stationary
if (!self.isStationary) {
self.x += self.speed;
}
// Add pulsing effect only for non-gear and non-rest platform obstacles
if (self.obstacleType !== 'gear' && self.obstacleType !== 'restPlatform') {
self.pulseScale += 0.005 * self.pulseDirection;
if (self.pulseScale > 1.05) self.pulseDirection = -1;
if (self.pulseScale < 0.98) self.pulseDirection = 1;
obstacleGraphics.scaleX = self.pulseScale;
obstacleGraphics.scaleY = self.pulseScale;
}
// Add rotation for certain obstacles
if (self.rotationSpeed > 0) {
obstacleGraphics.rotation += self.rotationSpeed;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var bird;
var obstacles = [];
var ground;
var gameStarted = false;
var lastObstacle = 0;
var obstacleSpacing = 400;
var currentLevel = storage.currentLevel || 1;
var unlockedLevels = storage.unlockedLevels || 1;
var totalScore = storage.totalScore || 0;
var levelScoreThreshold = 10; // Score needed to unlock next level
var obstacleCounter = 0; // Counter for obstacle generation
var levelObstacleTypes = []; // Array to store shuffled obstacle types for current level
var playerHealth = 3; // Player starts with 3 lives
var maxHealth = 3; // Maximum health
// Create score display
var scoreTxt = new Text2('0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
scoreTxt.y = 100;
// Create level display
var levelTxt = new Text2('Level ' + currentLevel, {
size: 60,
fill: 0xFFD700
});
levelTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(levelTxt);
levelTxt.y = 200;
// Create level progress display
var progressTxt = new Text2('Progress: 0/' + levelScoreThreshold, {
size: 40,
fill: 0xFFFFFF
});
progressTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(progressTxt);
progressTxt.y = 280;
// Create health display
var healthTxt = new Text2('Lives: ' + playerHealth, {
size: 50,
fill: 0xff0000
});
healthTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(healthTxt);
healthTxt.y = 340;
// Create instructions
var instructionTxt = new Text2('TAP TO FLIP AND FLY\nBOUNCE OFF OBSTACLES!', {
size: 60,
fill: 0xFFFFFF
});
instructionTxt.anchor.set(0.5, 0.5);
game.addChild(instructionTxt);
instructionTxt.x = 1024;
instructionTxt.y = 1000;
// Create ground
ground = game.addChild(LK.getAsset('ground', {
anchorX: 0,
anchorY: 0
}));
ground.x = 0;
ground.y = 2632;
// Create bird
bird = game.addChild(new Bird());
bird.x = 300;
bird.y = 800;
// Generate initial obstacle sequence for current level
generateLevelObstacleSequence();
// Create initial obstacles at game start
createObstacle();
function generateLevelObstacleSequence() {
levelObstacleTypes = [];
var baseTypes = ['spike', 'block', 'tallBlock', 'platform', 'gear', 'restPlatform', 'restPlatform', 'restPlatform']; // Added more rest platforms for higher frequency
var sequenceLength = 50; // Generate enough types for a full level
var seed = currentLevel * 12345; // Level-based seed for consistent sequences
for (var i = 0; i < sequenceLength; i++) {
seed = (seed * 9301 + 49297) % 233280;
var randomIndex = Math.floor(seed / 233280 * baseTypes.length);
levelObstacleTypes.push(baseTypes[randomIndex]);
}
}
function updateLevelProgress() {
var levelProgress = LK.getScore();
var progressNeeded = levelScoreThreshold * currentLevel;
// Update progress display
progressTxt.setText('Progress: ' + levelProgress + '/' + progressNeeded);
// Check if level is completed
if (levelProgress >= progressNeeded) {
// Level completed
totalScore += levelProgress;
storage.totalScore = totalScore;
// Unlock next level if not already unlocked
if (currentLevel >= unlockedLevels) {
unlockedLevels = currentLevel + 1;
storage.unlockedLevels = unlockedLevels;
LK.effects.flashScreen(0x00ff00, 1000); // Green flash for level completion
}
// Advance to next level
currentLevel++;
storage.currentLevel = currentLevel;
levelTxt.setText('Level ' + currentLevel);
// Reset score for new level
LK.setScore(0);
scoreTxt.setText(0);
// Reset obstacle counter for consistent level maps
obstacleCounter = 0;
// Generate new obstacle sequence for the new level
generateLevelObstacleSequence();
updateLevelProgress();
// Increase difficulty for new level
updateDifficultyForLevel();
}
}
function updateDifficultyForLevel() {
// Each level increases difficulty
var difficultyMultiplier = 1 + (currentLevel - 1) * 0.3;
// Adjust obstacle spacing based on level
obstacleSpacing = Math.max(200, 400 - (currentLevel - 1) * 20);
// Adjust bird physics slightly for higher levels
if (currentLevel > 3) {
bird.gravity = 0.8 + (currentLevel - 3) * 0.1;
}
}
function resetToLevelStart() {
// Reset score to level start
LK.setScore(0);
scoreTxt.setText(0);
// Reset health
playerHealth = maxHealth;
healthTxt.setText('Lives: ' + playerHealth);
// Clear all obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
obstacles[i].destroy();
obstacles.splice(i, 1);
}
// Reset obstacle counter
obstacleCounter = 0;
// Reset bird position
bird.x = 300;
bird.y = 800;
bird.velocityY = 0;
bird.completedFlips = 0;
// Regenerate obstacle sequence for current level
generateLevelObstacleSequence();
// Update displays
updateLevelProgress();
// Create initial obstacle
createObstacle();
}
function takeDamage() {
playerHealth--;
healthTxt.setText('Lives: ' + playerHealth);
// Flash screen red when taking damage
tween(game, {
tint: 0xff4444
}, {
duration: 200,
onFinish: function onFinish() {
tween(game, {
tint: 0xffffff
}, {
duration: 200
});
}
});
// Check if game over
if (playerHealth <= 0) {
resetToLevelStart();
}
}
function resetHealth() {
playerHealth = maxHealth;
healthTxt.setText('Lives: ' + playerHealth);
}
function startGame() {
if (!gameStarted) {
gameStarted = true;
game.removeChild(instructionTxt);
// Reset obstacle counter for consistent level maps
obstacleCounter = 0;
// Generate obstacle sequence for current level
generateLevelObstacleSequence();
resetHealth(); // Reset health when starting game
updateDifficultyForLevel();
updateLevelProgress();
}
}
function createObstacle() {
// Create walls that cover full screen with a gap for the bird
var baseX = 2148;
var gapSize = 400; // Size of the gap for bird to pass through (increased for larger bird)
// Use seeded random based on current level and obstacle counter for consistent maps
var seed = (currentLevel * 1000 + obstacleCounter) % 9973; // Use prime number for better distribution
var seededRandom = (seed * 9301 + 49297) % 233280 / 233280; // Linear congruential generator
var gapPosition = seededRandom * (2200 - gapSize) + 300; // Seeded gap position between 300-2200
var obstacleHeight = 400; // Height of each obstacle segment
var numSegments = Math.ceil(2732 / obstacleHeight); // Number of segments to cover full height
for (var i = 0; i < numSegments; i++) {
var segmentY = i * obstacleHeight + obstacleHeight / 2;
// Skip creating obstacles in the gap area
if (segmentY + obstacleHeight / 2 > gapPosition && segmentY - obstacleHeight / 2 < gapPosition + gapSize) {
continue;
}
var obstacle = new Obstacle();
obstacle.x = baseX;
obstacle.y = segmentY;
obstacles.push(obstacle);
game.addChild(obstacle);
}
obstacleCounter++;
lastObstacle = LK.ticks;
}
function checkCollisions() {
// Check ground collision
if (bird.y + 60 >= ground.y) {
if (!bird.isUpright()) {
takeDamage();
if (playerHealth > 0) {
// Push bird back up if still alive
bird.velocityY = -12;
bird.y = ground.y - 60;
}
return;
} else {
// Successful landing - award points
if (bird.completedFlips > 0) {
LK.setScore(LK.getScore() + bird.completedFlips);
scoreTxt.setText(LK.getScore());
LK.getSound('score').play();
updateLevelProgress();
bird.completedFlips = 0;
// Bounce back up
bird.velocityY = -8;
bird.y = ground.y - 60;
}
}
}
// Check obstacle collisions - bounce off obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
var obstacle = obstacles[i];
// Skip if obstacle is undefined
if (!obstacle) {
obstacles.splice(i, 1);
continue;
}
if (bird.intersects(obstacle)) {
// Check if it's a gear - immediate elimination
if (obstacle.obstacleType === 'gear') {
// Flash screen red and reset to level start
LK.effects.flashScreen(0xff0000, 500);
resetToLevelStart();
return;
}
// Check if it's a rest platform - safe area
if (obstacle.obstacleType === 'restPlatform') {
// Safe collision - just bounce without damage
var distanceX = bird.x - obstacle.x;
var distanceY = bird.y - obstacle.y;
var totalDistance = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
if (totalDistance > 0) {
var normalX = distanceX / totalDistance;
var normalY = distanceY / totalDistance;
// Gentle push away from platform
var pushForce = 3;
bird.x += normalX * pushForce;
bird.y += normalY * pushForce;
// Apply gentle bounce velocity
bird.velocityY = normalY * 3;
// Visual feedback for landing on safe platform
LK.effects.flashObject(obstacle, 0x00ff88, 300);
}
continue; // Skip damage dealing
}
// Only take damage if not already damaged from this obstacle
if (!obstacle.damagedBird) {
takeDamage();
obstacle.damagedBird = true; // Mark this obstacle as having caused damage
}
// Calculate collision direction
var distanceX = bird.x - obstacle.x;
var distanceY = bird.y - obstacle.y;
var totalDistance = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
// Normalize collision direction
if (totalDistance > 0) {
var normalX = distanceX / totalDistance;
var normalY = distanceY / totalDistance;
// Push bird away from obstacle
var pushForce = 8;
bird.x += normalX * pushForce;
bird.y += normalY * pushForce;
// Apply bounce velocity
var bounceForce = 5;
bird.velocityY = normalY * bounceForce;
// Play flap sound for bounce feedback
LK.getSound('flap').play();
}
}
// Check if bird passed obstacle
if (!obstacle.passed && obstacle.x + 100 < bird.x) {
obstacle.passed = true;
if (bird.isUpright() && bird.completedFlips > 0) {
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
LK.getSound('score').play();
updateLevelProgress();
}
}
// Remove off-screen obstacles (but keep stationary gears and rest platforms)
if (obstacle.x < -100 && !obstacle.isStationary) {
// Add flash effect when obstacle disappears
LK.effects.flashObject(obstacle, 0xffffff, 200);
obstacle.destroy();
obstacles.splice(i, 1);
}
}
// Check ceiling collision
if (bird.y < 50) {
bird.y = 50;
bird.velocityY = 0;
}
}
game.down = function (x, y, obj) {
if (!gameStarted) {
startGame();
}
bird.flap();
};
game.update = function () {
if (!gameStarted) return;
// Create obstacles
if (LK.ticks - lastObstacle > obstacleSpacing) {
createObstacle();
}
// Update bird physics
bird.update();
// Update obstacles
for (var i = 0; i < obstacles.length; i++) {
obstacles[i].update();
}
// Check collisions
checkCollisions();
// Level-based difficulty progression
var baseSpacing = 400 - (currentLevel - 1) * 20;
var minSpacing = Math.max(200, 300 - (currentLevel - 1) * 10);
var reductionRate = 1 + currentLevel; // Increase reduction rate with level
var currentSpacing = baseSpacing - LK.getScore() * reductionRate;
obstacleSpacing = Math.max(minSpacing, currentSpacing);
};
kırmızı bir kalp . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
portal. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
bomba. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
minecraft papağan. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
bayrak . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat