User prompt
boru sayısını yarı yarıya azalt
User prompt
borular zemine veya tavana tam yapışık olsun. boruların arasındaki mesafe daha uzak olsun.
Code edit (1 edits merged)
Please save this source code
User prompt
Sky Dash Runner
Initial prompt
"Create a 2D side-scrolling endless runner game similar to Flappy Bird. The player controls a flying character that moves forward automatically and must tap to flap and avoid obstacles. Add randomly generated vertical gaps between pipes. The game ends when the player hits an obstacle or the ground. Include a score counter at the top. Use cartoon-style visuals. Add background music and simple flap sound effects. The difficulty should increase over time with faster scrolling and tighter gaps
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bird = Container.expand(function () {
var self = Container.call(this);
var birdGraphics = self.attachAsset('bird', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocity = 0;
self.gravity = 0.8;
self.flapStrength = -12;
self.update = function () {
self.velocity += self.gravity;
self.y += self.velocity;
// Rotate bird based on velocity
birdGraphics.rotation = Math.max(-0.5, Math.min(0.5, self.velocity * 0.05));
// Check ground collision
if (self.y > gameHeight - groundHeight - 30) {
gameOver();
}
// Check ceiling collision
if (self.y < 30) {
gameOver();
}
};
self.flap = function () {
self.velocity = self.flapStrength;
LK.getSound('flap').play();
};
return self;
});
var Pipe = Container.expand(function () {
var self = Container.call(this);
var topPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 1
});
var bottomPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 0
});
self.speed = -4;
self.gapSize = 450;
self.scored = false;
self.setupPipes = function (gapY) {
// Position top pipe so it extends from top of screen to gap start
topPipe.y = gapY - self.gapSize / 2;
// Position bottom pipe so it extends from gap end to ground
bottomPipe.y = gapY + self.gapSize / 2;
};
self.update = function () {
self.x += self.speed;
// Check if pipe has passed bird and award score
if (!self.scored && self.x < bird.x) {
self.scored = true;
score++;
scoreTxt.setText(score);
LK.setScore(score);
}
// Remove pipe when off screen
if (self.x < -100) {
self.destroy();
for (var i = pipes.length - 1; i >= 0; i--) {
if (pipes[i] === self) {
pipes.splice(i, 1);
break;
}
}
}
};
self.checkCollision = function (birdObj) {
var birdBounds = {
left: birdObj.x - 30,
right: birdObj.x + 30,
top: birdObj.y - 25,
bottom: birdObj.y + 25
};
var topPipeBounds = {
left: self.x - 60,
right: self.x + 60,
top: 0,
bottom: topPipe.y
};
var bottomPipeBounds = {
left: self.x - 60,
right: self.x + 60,
top: bottomPipe.y,
bottom: gameHeight
};
// Check collision with top pipe
if (birdBounds.right > topPipeBounds.left && birdBounds.left < topPipeBounds.right && birdBounds.top < topPipeBounds.bottom) {
return true;
}
// Check collision with bottom pipe
if (birdBounds.right > bottomPipeBounds.left && birdBounds.left < bottomPipeBounds.right && birdBounds.bottom > bottomPipeBounds.top) {
return true;
}
return false;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var gameWidth = 2048;
var gameHeight = 2732;
var groundHeight = 100;
var bird;
var pipes = [];
var score = 0;
var gameRunning = true;
var pipeSpawnTimer = 0;
var difficultyTimer = 0;
// Create ground
var ground = game.addChild(LK.getAsset('ground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: gameHeight - groundHeight
}));
// Create bird
bird = game.addChild(new Bird());
bird.x = 300;
bird.y = gameHeight / 2;
// Create score display
var scoreTxt = new Text2('0', {
size: 120,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
function spawnPipe() {
var pipe = new Pipe();
pipe.x = gameWidth + 100;
// Random gap position (avoid too high or too low)
var minGapY = 200;
var maxGapY = gameHeight - groundHeight - 200;
var gapY = minGapY + Math.random() * (maxGapY - minGapY);
pipe.setupPipes(gapY);
pipes.push(pipe);
game.addChild(pipe);
}
function gameOver() {
if (!gameRunning) return;
gameRunning = false;
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
function increaseDifficulty() {
// Increase pipe speed slightly
for (var i = 0; i < pipes.length; i++) {
pipes[i].speed = Math.max(-8, pipes[i].speed - 0.1);
}
// Decrease gap size slightly for new pipes
if (Pipe.prototype.gapSize > 200) {
Pipe.prototype.gapSize -= 5;
}
}
// Touch controls
game.down = function (x, y, obj) {
if (gameRunning) {
bird.flap();
}
};
// Main game loop
game.update = function () {
if (!gameRunning) return;
// Spawn pipes
pipeSpawnTimer++;
if (pipeSpawnTimer >= 180) {
// Spawn pipe every 3 seconds (180 frames at 60fps)
spawnPipe();
pipeSpawnTimer = 0;
}
// Increase difficulty every 10 seconds
difficultyTimer++;
if (difficultyTimer >= 600) {
// 10 seconds at 60fps
increaseDifficulty();
difficultyTimer = 0;
}
// Check pipe collisions
for (var i = 0; i < pipes.length; i++) {
if (pipes[i].checkCollision(bird)) {
gameOver();
break;
}
}
};
// Start background music
LK.playMusic('bgmusic'); /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bird = Container.expand(function () {
var self = Container.call(this);
var birdGraphics = self.attachAsset('bird', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocity = 0;
self.gravity = 0.8;
self.flapStrength = -12;
self.update = function () {
self.velocity += self.gravity;
self.y += self.velocity;
// Rotate bird based on velocity
birdGraphics.rotation = Math.max(-0.5, Math.min(0.5, self.velocity * 0.05));
// Check ground collision
if (self.y > gameHeight - groundHeight - 30) {
gameOver();
}
// Check ceiling collision
if (self.y < 30) {
gameOver();
}
};
self.flap = function () {
self.velocity = self.flapStrength;
LK.getSound('flap').play();
};
return self;
});
var Pipe = Container.expand(function () {
var self = Container.call(this);
var topPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 1
});
var bottomPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 0
});
self.speed = -4;
self.gapSize = 450;
self.scored = false;
self.setupPipes = function (gapY) {
// Position top pipe so it extends from top of screen to gap start
topPipe.y = gapY - self.gapSize / 2;
// Position bottom pipe so it extends from gap end to ground
bottomPipe.y = gapY + self.gapSize / 2;
};
self.update = function () {
self.x += self.speed;
// Check if pipe has passed bird and award score
if (!self.scored && self.x < bird.x) {
self.scored = true;
score++;
scoreTxt.setText(score);
LK.setScore(score);
}
// Remove pipe when off screen
if (self.x < -100) {
self.destroy();
for (var i = pipes.length - 1; i >= 0; i--) {
if (pipes[i] === self) {
pipes.splice(i, 1);
break;
}
}
}
};
self.checkCollision = function (birdObj) {
var birdBounds = {
left: birdObj.x - 30,
right: birdObj.x + 30,
top: birdObj.y - 25,
bottom: birdObj.y + 25
};
var topPipeBounds = {
left: self.x - 60,
right: self.x + 60,
top: 0,
bottom: topPipe.y
};
var bottomPipeBounds = {
left: self.x - 60,
right: self.x + 60,
top: bottomPipe.y,
bottom: gameHeight
};
// Check collision with top pipe
if (birdBounds.right > topPipeBounds.left && birdBounds.left < topPipeBounds.right && birdBounds.top < topPipeBounds.bottom) {
return true;
}
// Check collision with bottom pipe
if (birdBounds.right > bottomPipeBounds.left && birdBounds.left < bottomPipeBounds.right && birdBounds.bottom > bottomPipeBounds.top) {
return true;
}
return false;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var gameWidth = 2048;
var gameHeight = 2732;
var groundHeight = 100;
var bird;
var pipes = [];
var score = 0;
var gameRunning = true;
var pipeSpawnTimer = 0;
var difficultyTimer = 0;
// Create ground
var ground = game.addChild(LK.getAsset('ground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: gameHeight - groundHeight
}));
// Create bird
bird = game.addChild(new Bird());
bird.x = 300;
bird.y = gameHeight / 2;
// Create score display
var scoreTxt = new Text2('0', {
size: 120,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
function spawnPipe() {
var pipe = new Pipe();
pipe.x = gameWidth + 100;
// Random gap position (avoid too high or too low)
var minGapY = 200;
var maxGapY = gameHeight - groundHeight - 200;
var gapY = minGapY + Math.random() * (maxGapY - minGapY);
pipe.setupPipes(gapY);
pipes.push(pipe);
game.addChild(pipe);
}
function gameOver() {
if (!gameRunning) return;
gameRunning = false;
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
function increaseDifficulty() {
// Increase pipe speed slightly
for (var i = 0; i < pipes.length; i++) {
pipes[i].speed = Math.max(-8, pipes[i].speed - 0.1);
}
// Decrease gap size slightly for new pipes
if (Pipe.prototype.gapSize > 200) {
Pipe.prototype.gapSize -= 5;
}
}
// Touch controls
game.down = function (x, y, obj) {
if (gameRunning) {
bird.flap();
}
};
// Main game loop
game.update = function () {
if (!gameRunning) return;
// Spawn pipes
pipeSpawnTimer++;
if (pipeSpawnTimer >= 180) {
// Spawn pipe every 3 seconds (180 frames at 60fps)
spawnPipe();
pipeSpawnTimer = 0;
}
// Increase difficulty every 10 seconds
difficultyTimer++;
if (difficultyTimer >= 600) {
// 10 seconds at 60fps
increaseDifficulty();
difficultyTimer = 0;
}
// Check pipe collisions
for (var i = 0; i < pipes.length; i++) {
if (pipes[i].checkCollision(bird)) {
gameOver();
break;
}
}
};
// Start background music
LK.playMusic('bgmusic');