/**** 
* Plugins
****/ 
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/**** 
* Classes
****/ 
var Cloud = Container.expand(function () {
	var self = Container.call(this);
	var cloudGraphics = self.attachAsset('cloud', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.speed = 2;
	// Add floating animation to clouds
	tween(cloudGraphics, {
		y: -10
	}, {
		duration: 2000,
		easing: tween.easeInOut,
		onFinish: function onFinish() {
			tween(cloudGraphics, {
				y: 10
			}, {
				duration: 2000,
				easing: tween.easeInOut,
				onFinish: function onFinish() {
					tween(cloudGraphics, {
						y: 0
					}, {
						duration: 2000,
						easing: tween.easeInOut
					});
				}
			});
		}
	});
	self.update = function () {
		self.x -= self.speed;
	};
	return self;
});
var Dinosaur = Container.expand(function () {
	var self = Container.call(this);
	var dinoGraphics = self.attachAsset('dino', {
		anchorX: 0.5,
		anchorY: 1.0
	});
	self.isJumping = false;
	self.isDucking = false;
	self.groundY = 0;
	self.jumpSpeed = 0;
	self.gravity = 0.8;
	self.normalHeight = 80;
	self.duckHeight = 40;
	self.jump = function () {
		if (!self.isJumping && !self.isDucking) {
			self.isJumping = true;
			self.jumpSpeed = self.jumpPower;
			LK.getSound('jump').play();
			// Add bounce animation to dinosaur graphics
			tween(dinoGraphics, {
				scaleX: 1.2,
				scaleY: 0.8
			}, {
				duration: 100,
				easing: tween.easeOut,
				onFinish: function onFinish() {
					tween(dinoGraphics, {
						scaleX: 1.0,
						scaleY: 1.0
					}, {
						duration: 100,
						easing: tween.easeIn
					});
				}
			});
		}
	};
	self.startDuck = function () {
		if (!self.isJumping && !self.isDucking) {
			self.isDucking = true;
			dinoGraphics.height = self.duckHeight;
			// Add squash animation when ducking
			tween(dinoGraphics, {
				scaleX: 1.3,
				scaleY: 0.6
			}, {
				duration: 150,
				easing: tween.easeOut
			});
		}
	};
	self.stopDuck = function () {
		if (self.isDucking) {
			self.isDucking = false;
			dinoGraphics.height = self.normalHeight;
			// Return to normal scale when stopping duck
			tween(dinoGraphics, {
				scaleX: 1.0,
				scaleY: 1.0
			}, {
				duration: 150,
				easing: tween.easeIn
			});
		}
	};
	self.update = function () {
		if (self.isJumping) {
			self.jumpSpeed += self.gravity;
			self.y += self.jumpSpeed;
			if (self.y >= self.groundY) {
				self.y = self.groundY;
				self.isJumping = false;
				self.jumpSpeed = 0;
			}
		}
	};
	return self;
});
var Obstacle = Container.expand(function (type) {
	var self = Container.call(this);
	self.type = type;
	self.speed = 8;
	if (type === 'cactus') {
		var obstacleGraphics = self.attachAsset('cactus', {
			anchorX: 0.5,
			anchorY: 1.0
		});
		self.y = groundLevel;
	} else if (type === 'pterodactyl') {
		var obstacleGraphics = self.attachAsset('pterodactyl', {
			anchorX: 0.5,
			anchorY: 0.5
		});
		self.y = groundLevel - 120;
	}
	self.update = function () {
		self.x -= self.speed;
	};
	return self;
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x87CEEB
});
/**** 
* Game Code
****/ 
var groundLevel = 2732 - 200;
var gameSpeed = 8;
var speedIncrease = 0.005;
var distance = 0;
var isGameRunning = true;
var isDucking = false;
var lastMilestoneScore = 0;
// Create ground
var ground = game.addChild(LK.getAsset('ground', {
	anchorX: 0,
	anchorY: 0,
	x: 0,
	y: groundLevel
}));
// Create dinosaur
var dinosaur = game.addChild(new Dinosaur());
dinosaur.x = 2048 / 2; // Center horizontally on screen
dinosaur.y = groundLevel;
dinosaur.groundY = groundLevel;
dinosaur.jumpPower = -19; // Set jump power for higher jumps
// Create score display
var scoreText = new Text2('0', {
	size: 60,
	fill: 0x000000
});
scoreText.anchor.set(1, 0);
LK.gui.topRight.addChild(scoreText);
// Create high score display
var highScore = storage.highScore || 0;
var highScoreText = new Text2('highest score: ' + highScore, {
	size: 40,
	fill: 0x666666
});
highScoreText.anchor.set(1, 0);
highScoreText.y = 70;
LK.gui.topRight.addChild(highScoreText);
// Create sun in top left area
var sun = game.addChild(LK.getAsset('sun', {
	anchorX: 0.5,
	anchorY: 0.5,
	x: 430,
	y: 400
}));
// Arrays for game objects
var obstacles = [];
var clouds = [];
// Obstacle spawning variables
var obstacleSpawnTimer = 0;
var obstacleSpawnDelay = 120;
var cloudSpawnTimer = 0;
var cloudSpawnDelay = 200;
// Input handling
game.down = function (x, y, obj) {
	if (isGameRunning) {
		dinosaur.jump();
		isDucking = true;
		dinosaur.startDuck();
	}
};
game.up = function (x, y, obj) {
	if (isGameRunning) {
		isDucking = false;
		dinosaur.stopDuck();
	}
};
// Spawn obstacle function
function spawnObstacle() {
	var obstacleType = Math.random() < 0.85 ? 'cactus' : 'pterodactyl';
	if (obstacleType === 'cactus') {
		// Spawn 1, 2, or 3 cacti randomly
		var cactusCount = Math.floor(Math.random() * 3) + 1; // 1, 2, or 3
		var baseX = 2048 + 50;
		for (var k = 0; k < cactusCount; k++) {
			var obstacle = new Obstacle(obstacleType);
			obstacle.x = baseX + k * 80; // Space cacti 80 pixels apart
			obstacle.speed = gameSpeed;
			// Add random scale variation to make some cacti smaller
			var randomScale = 0.6 + Math.random() * 0.4; // Scale between 0.6 and 1.0
			tween(obstacle, {
				scaleX: randomScale,
				scaleY: randomScale
			}, {
				duration: 0
			});
			obstacles.push(obstacle);
			game.addChild(obstacle);
		}
	} else {
		// Single pterodactyl
		var obstacle = new Obstacle(obstacleType);
		obstacle.x = 2048 + 50;
		obstacle.speed = gameSpeed;
		obstacles.push(obstacle);
		game.addChild(obstacle);
	}
}
// Spawn cloud function
function spawnCloud() {
	var cloud = new Cloud();
	cloud.x = 2048 + 50;
	cloud.y = Math.random() * 400 + 100;
	cloud.speed = gameSpeed * 0.3;
	clouds.push(cloud);
	game.addChild(cloud);
}
// Main game loop
game.update = function () {
	if (!isGameRunning) {
		return;
	}
	// Update distance and score
	distance += gameSpeed * 0.1;
	var currentScore = Math.floor(distance);
	LK.setScore(currentScore);
	scoreText.setText(currentScore);
	// Update high score if current score is higher
	if (currentScore > highScore) {
		highScore = currentScore;
		storage.highScore = highScore;
		highScoreText.setText('en yüksek skor: ' + highScore);
	}
	// Check for score milestones (every 1000 points)
	var currentScore = Math.floor(distance);
	var currentMilestone = Math.floor(currentScore / 1000) * 1000;
	var lastMilestone = Math.floor(lastMilestoneScore / 1000) * 1000;
	if (currentMilestone > lastMilestone && currentMilestone > 0) {
		// Milestone reached - no sound
	}
	lastMilestoneScore = currentScore;
	// Increase game speed gradually
	gameSpeed += speedIncrease;
	// Spawn obstacles
	obstacleSpawnTimer++;
	if (obstacleSpawnTimer >= obstacleSpawnDelay) {
		spawnObstacle();
		obstacleSpawnTimer = 0;
		obstacleSpawnDelay = Math.max(60, obstacleSpawnDelay - 0.5);
	}
	// Spawn clouds
	cloudSpawnTimer++;
	if (cloudSpawnTimer >= cloudSpawnDelay) {
		spawnCloud();
		cloudSpawnTimer = 0;
	}
	// Update and manage obstacles
	for (var i = obstacles.length - 1; i >= 0; i--) {
		var obstacle = obstacles[i];
		obstacle.speed = gameSpeed;
		// Check collision
		if (dinosaur.intersects(obstacle)) {
			isGameRunning = false;
			LK.showGameOver();
			return;
		}
		// Remove off-screen obstacles
		if (obstacle.x < -100) {
			obstacle.destroy();
			obstacles.splice(i, 1);
		}
	}
	// Update and manage clouds
	for (var j = clouds.length - 1; j >= 0; j--) {
		var cloud = clouds[j];
		cloud.speed = gameSpeed * 0.3;
		// Remove off-screen clouds
		if (cloud.x < -100) {
			cloud.destroy();
			clouds.splice(j, 1);
		}
	}
}; /**** 
* Plugins
****/ 
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/**** 
* Classes
****/ 
var Cloud = Container.expand(function () {
	var self = Container.call(this);
	var cloudGraphics = self.attachAsset('cloud', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.speed = 2;
	// Add floating animation to clouds
	tween(cloudGraphics, {
		y: -10
	}, {
		duration: 2000,
		easing: tween.easeInOut,
		onFinish: function onFinish() {
			tween(cloudGraphics, {
				y: 10
			}, {
				duration: 2000,
				easing: tween.easeInOut,
				onFinish: function onFinish() {
					tween(cloudGraphics, {
						y: 0
					}, {
						duration: 2000,
						easing: tween.easeInOut
					});
				}
			});
		}
	});
	self.update = function () {
		self.x -= self.speed;
	};
	return self;
});
var Dinosaur = Container.expand(function () {
	var self = Container.call(this);
	var dinoGraphics = self.attachAsset('dino', {
		anchorX: 0.5,
		anchorY: 1.0
	});
	self.isJumping = false;
	self.isDucking = false;
	self.groundY = 0;
	self.jumpSpeed = 0;
	self.gravity = 0.8;
	self.normalHeight = 80;
	self.duckHeight = 40;
	self.jump = function () {
		if (!self.isJumping && !self.isDucking) {
			self.isJumping = true;
			self.jumpSpeed = self.jumpPower;
			LK.getSound('jump').play();
			// Add bounce animation to dinosaur graphics
			tween(dinoGraphics, {
				scaleX: 1.2,
				scaleY: 0.8
			}, {
				duration: 100,
				easing: tween.easeOut,
				onFinish: function onFinish() {
					tween(dinoGraphics, {
						scaleX: 1.0,
						scaleY: 1.0
					}, {
						duration: 100,
						easing: tween.easeIn
					});
				}
			});
		}
	};
	self.startDuck = function () {
		if (!self.isJumping && !self.isDucking) {
			self.isDucking = true;
			dinoGraphics.height = self.duckHeight;
			// Add squash animation when ducking
			tween(dinoGraphics, {
				scaleX: 1.3,
				scaleY: 0.6
			}, {
				duration: 150,
				easing: tween.easeOut
			});
		}
	};
	self.stopDuck = function () {
		if (self.isDucking) {
			self.isDucking = false;
			dinoGraphics.height = self.normalHeight;
			// Return to normal scale when stopping duck
			tween(dinoGraphics, {
				scaleX: 1.0,
				scaleY: 1.0
			}, {
				duration: 150,
				easing: tween.easeIn
			});
		}
	};
	self.update = function () {
		if (self.isJumping) {
			self.jumpSpeed += self.gravity;
			self.y += self.jumpSpeed;
			if (self.y >= self.groundY) {
				self.y = self.groundY;
				self.isJumping = false;
				self.jumpSpeed = 0;
			}
		}
	};
	return self;
});
var Obstacle = Container.expand(function (type) {
	var self = Container.call(this);
	self.type = type;
	self.speed = 8;
	if (type === 'cactus') {
		var obstacleGraphics = self.attachAsset('cactus', {
			anchorX: 0.5,
			anchorY: 1.0
		});
		self.y = groundLevel;
	} else if (type === 'pterodactyl') {
		var obstacleGraphics = self.attachAsset('pterodactyl', {
			anchorX: 0.5,
			anchorY: 0.5
		});
		self.y = groundLevel - 120;
	}
	self.update = function () {
		self.x -= self.speed;
	};
	return self;
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x87CEEB
});
/**** 
* Game Code
****/ 
var groundLevel = 2732 - 200;
var gameSpeed = 8;
var speedIncrease = 0.005;
var distance = 0;
var isGameRunning = true;
var isDucking = false;
var lastMilestoneScore = 0;
// Create ground
var ground = game.addChild(LK.getAsset('ground', {
	anchorX: 0,
	anchorY: 0,
	x: 0,
	y: groundLevel
}));
// Create dinosaur
var dinosaur = game.addChild(new Dinosaur());
dinosaur.x = 2048 / 2; // Center horizontally on screen
dinosaur.y = groundLevel;
dinosaur.groundY = groundLevel;
dinosaur.jumpPower = -19; // Set jump power for higher jumps
// Create score display
var scoreText = new Text2('0', {
	size: 60,
	fill: 0x000000
});
scoreText.anchor.set(1, 0);
LK.gui.topRight.addChild(scoreText);
// Create high score display
var highScore = storage.highScore || 0;
var highScoreText = new Text2('highest score: ' + highScore, {
	size: 40,
	fill: 0x666666
});
highScoreText.anchor.set(1, 0);
highScoreText.y = 70;
LK.gui.topRight.addChild(highScoreText);
// Create sun in top left area
var sun = game.addChild(LK.getAsset('sun', {
	anchorX: 0.5,
	anchorY: 0.5,
	x: 430,
	y: 400
}));
// Arrays for game objects
var obstacles = [];
var clouds = [];
// Obstacle spawning variables
var obstacleSpawnTimer = 0;
var obstacleSpawnDelay = 120;
var cloudSpawnTimer = 0;
var cloudSpawnDelay = 200;
// Input handling
game.down = function (x, y, obj) {
	if (isGameRunning) {
		dinosaur.jump();
		isDucking = true;
		dinosaur.startDuck();
	}
};
game.up = function (x, y, obj) {
	if (isGameRunning) {
		isDucking = false;
		dinosaur.stopDuck();
	}
};
// Spawn obstacle function
function spawnObstacle() {
	var obstacleType = Math.random() < 0.85 ? 'cactus' : 'pterodactyl';
	if (obstacleType === 'cactus') {
		// Spawn 1, 2, or 3 cacti randomly
		var cactusCount = Math.floor(Math.random() * 3) + 1; // 1, 2, or 3
		var baseX = 2048 + 50;
		for (var k = 0; k < cactusCount; k++) {
			var obstacle = new Obstacle(obstacleType);
			obstacle.x = baseX + k * 80; // Space cacti 80 pixels apart
			obstacle.speed = gameSpeed;
			// Add random scale variation to make some cacti smaller
			var randomScale = 0.6 + Math.random() * 0.4; // Scale between 0.6 and 1.0
			tween(obstacle, {
				scaleX: randomScale,
				scaleY: randomScale
			}, {
				duration: 0
			});
			obstacles.push(obstacle);
			game.addChild(obstacle);
		}
	} else {
		// Single pterodactyl
		var obstacle = new Obstacle(obstacleType);
		obstacle.x = 2048 + 50;
		obstacle.speed = gameSpeed;
		obstacles.push(obstacle);
		game.addChild(obstacle);
	}
}
// Spawn cloud function
function spawnCloud() {
	var cloud = new Cloud();
	cloud.x = 2048 + 50;
	cloud.y = Math.random() * 400 + 100;
	cloud.speed = gameSpeed * 0.3;
	clouds.push(cloud);
	game.addChild(cloud);
}
// Main game loop
game.update = function () {
	if (!isGameRunning) {
		return;
	}
	// Update distance and score
	distance += gameSpeed * 0.1;
	var currentScore = Math.floor(distance);
	LK.setScore(currentScore);
	scoreText.setText(currentScore);
	// Update high score if current score is higher
	if (currentScore > highScore) {
		highScore = currentScore;
		storage.highScore = highScore;
		highScoreText.setText('en yüksek skor: ' + highScore);
	}
	// Check for score milestones (every 1000 points)
	var currentScore = Math.floor(distance);
	var currentMilestone = Math.floor(currentScore / 1000) * 1000;
	var lastMilestone = Math.floor(lastMilestoneScore / 1000) * 1000;
	if (currentMilestone > lastMilestone && currentMilestone > 0) {
		// Milestone reached - no sound
	}
	lastMilestoneScore = currentScore;
	// Increase game speed gradually
	gameSpeed += speedIncrease;
	// Spawn obstacles
	obstacleSpawnTimer++;
	if (obstacleSpawnTimer >= obstacleSpawnDelay) {
		spawnObstacle();
		obstacleSpawnTimer = 0;
		obstacleSpawnDelay = Math.max(60, obstacleSpawnDelay - 0.5);
	}
	// Spawn clouds
	cloudSpawnTimer++;
	if (cloudSpawnTimer >= cloudSpawnDelay) {
		spawnCloud();
		cloudSpawnTimer = 0;
	}
	// Update and manage obstacles
	for (var i = obstacles.length - 1; i >= 0; i--) {
		var obstacle = obstacles[i];
		obstacle.speed = gameSpeed;
		// Check collision
		if (dinosaur.intersects(obstacle)) {
			isGameRunning = false;
			LK.showGameOver();
			return;
		}
		// Remove off-screen obstacles
		if (obstacle.x < -100) {
			obstacle.destroy();
			obstacles.splice(i, 1);
		}
	}
	// Update and manage clouds
	for (var j = clouds.length - 1; j >= 0; j--) {
		var cloud = clouds[j];
		cloud.speed = gameSpeed * 0.3;
		// Remove off-screen clouds
		if (cloud.x < -100) {
			cloud.destroy();
			clouds.splice(j, 1);
		}
	}
};
 sand. In-Game asset. No shadows. pixel
 cloudy. In-Game asset. No shadows. pixel
 cactus. No background. Transparent background. Blank background. No shadows. pixel. In-Game asset. flat
 white and black dinosaur. In-Game asset. No shadows. pixel
 beyaz siyah uçan dinazor kuş. In-Game asset. No shadows. pixel
 güneş. In-Game asset. No shadows. pixel