User prompt
Pass dediğim ödül sistemi. Seviyelerde ekle arkadaş eklemede olsun ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Oyuna ana menü ve pass ekle ↪💡 Consider importing and using the following plugins: @upit/storage.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Flipy Bird Yap
Initial prompt
Bana flipy bird yap
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Bird = Container.expand(function () {
var self = Container.call(this);
var birdGraphics = self.attachAsset('bird', {
anchorX: 0.5,
anchorY: 0.5
});
self.isFlipped = false;
self.baseY = 1366; // Middle of screen (2732 / 2)
self.flippedY = 683; // Upper third
self.velocity = 0;
self.gravity = 0.4;
self.maxVelocity = 15;
self.flip = function () {
self.isFlipped = !self.isFlipped;
var targetY = self.isFlipped ? self.flippedY : self.baseY;
tween(self, {
y: targetY
}, {
duration: 200,
easing: tween.easeInOut
});
LK.getSound('flip').play();
};
self.update = function () {
if (!self.isFlipped) {
self.velocity += self.gravity;
if (self.velocity > self.maxVelocity) {
self.velocity = self.maxVelocity;
}
} else {
self.velocity -= self.gravity;
if (self.velocity < -self.maxVelocity) {
self.velocity = -self.maxVelocity;
}
}
self.y += self.velocity;
// Boundary check
if (self.y < 30) {
self.y = 30;
self.velocity = 0;
}
if (self.y > 2702) {
self.y = 2702;
self.velocity = 0;
}
};
return self;
});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
self.speed = 8;
self.gapSize = 300;
self.gapPosition = 0; // 0 = top, 1 = middle, 2 = bottom
var topPart = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
var bottomPart = LK.getAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.addChild(bottomPart);
self.setupObstacle = function (position) {
self.gapPosition = position;
var obstacleHeight = 200;
var screenHeight = 2732;
var gapSize = self.gapSize;
var totalHeight = screenHeight - gapSize;
if (position === 0) {
// Gap at top
topPart.y = -gapSize / 2 - obstacleHeight / 2;
bottomPart.y = gapSize / 2 + obstacleHeight / 2;
} else if (position === 1) {
// Gap in middle
topPart.y = -(gapSize / 2 + obstacleHeight / 2);
bottomPart.y = gapSize / 2 + obstacleHeight / 2;
} else {
// Gap at bottom
topPart.y = -gapSize / 2 - obstacleHeight / 2;
bottomPart.y = screenHeight - gapSize / 2 + obstacleHeight / 2;
}
};
self.update = function () {
self.x -= self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var bird = game.addChild(new Bird());
bird.x = 300;
bird.y = bird.baseY;
var obstacles = [];
var score = 0;
var gameActive = true;
var obstacleSpawnRate = 80;
var spawnCounter = 0;
var difficulty = 1;
var difficultyIncrement = 0.0002;
var scoreTxt = new Text2('0', {
size: 100,
fill: 0x000000
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
function updateScore() {
scoreTxt.setText(score);
LK.setScore(score);
}
function spawnObstacle() {
var obstacle = game.addChild(new Obstacle());
obstacle.x = 2048 + 200;
obstacle.y = 1366;
var positions = [0, 1, 2];
var randomPosition = positions[Math.floor(Math.random() * positions.length)];
obstacle.setupObstacle(randomPosition);
obstacle.passed = false;
obstacles.push(obstacle);
}
function endGame() {
gameActive = false;
LK.effects.flashScreen(0xFF0000, 500);
LK.getSound('hit').play();
LK.setTimeout(function () {
LK.showGameOver();
}, 500);
}
game.down = function (x, y, obj) {
if (gameActive) {
bird.flip();
}
};
game.move = function (x, y, obj) {
// Empty move handler required for touch compatibility
};
game.up = function (x, y, obj) {
// Empty up handler
};
game.update = function () {
if (!gameActive) {
return;
}
// Update difficulty
difficulty += difficultyIncrement;
obstacleSpawnRate = Math.max(40, 80 - Math.floor(difficulty * 5));
// Update bird
bird.update();
// Spawn obstacles
spawnCounter++;
if (spawnCounter >= obstacleSpawnRate) {
spawnObstacle();
spawnCounter = 0;
}
// Update obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
var obstacle = obstacles[i];
obstacle.speed = 8 + difficulty * 0.5;
obstacle.update();
// Check if bird passed obstacle
if (!obstacle.passed && bird.x > obstacle.x) {
obstacle.passed = true;
score++;
updateScore();
LK.getSound('score').play();
// Win condition
if (score >= 50) {
gameActive = false;
LK.effects.flashScreen(0x00FF00, 500);
LK.setTimeout(function () {
LK.showYouWin();
}, 500);
return;
}
}
// Check collision with bird
var birdRadius = 30;
var obstacleWidth = 80;
var gapSize = obstacle.gapSize;
var obstacleHeight = 200;
var birdLeft = bird.x - birdRadius;
var birdRight = bird.x + birdRadius;
var birdTop = bird.y - birdRadius;
var birdBottom = bird.y + birdRadius;
var obstacleLeft = obstacle.x - obstacleWidth / 2;
var obstacleRight = obstacle.x + obstacleWidth / 2;
if (birdRight > obstacleLeft && birdLeft < obstacleRight) {
// Check vertical collision
var gapCenter = obstacle.y;
var gapTop = gapCenter - gapSize / 2;
var gapBottom = gapCenter + gapSize / 2;
if (birdTop < gapTop || birdBottom > gapBottom) {
endGame();
return;
}
}
// Remove off-screen obstacles
if (obstacle.x < -200) {
obstacle.destroy();
obstacles.splice(i, 1);
}
}
// Boundary collision
if (bird.y - 30 <= 0 || bird.y + 30 >= 2732) {
endGame();
return;
}
};
LK.playMusic('bgmusic', {
loop: true
}); ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,228 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1");
+
+/****
+* Classes
+****/
+var Bird = Container.expand(function () {
+ var self = Container.call(this);
+ var birdGraphics = self.attachAsset('bird', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.isFlipped = false;
+ self.baseY = 1366; // Middle of screen (2732 / 2)
+ self.flippedY = 683; // Upper third
+ self.velocity = 0;
+ self.gravity = 0.4;
+ self.maxVelocity = 15;
+ self.flip = function () {
+ self.isFlipped = !self.isFlipped;
+ var targetY = self.isFlipped ? self.flippedY : self.baseY;
+ tween(self, {
+ y: targetY
+ }, {
+ duration: 200,
+ easing: tween.easeInOut
+ });
+ LK.getSound('flip').play();
+ };
+ self.update = function () {
+ if (!self.isFlipped) {
+ self.velocity += self.gravity;
+ if (self.velocity > self.maxVelocity) {
+ self.velocity = self.maxVelocity;
+ }
+ } else {
+ self.velocity -= self.gravity;
+ if (self.velocity < -self.maxVelocity) {
+ self.velocity = -self.maxVelocity;
+ }
+ }
+ self.y += self.velocity;
+ // Boundary check
+ if (self.y < 30) {
+ self.y = 30;
+ self.velocity = 0;
+ }
+ if (self.y > 2702) {
+ self.y = 2702;
+ self.velocity = 0;
+ }
+ };
+ return self;
+});
+var Obstacle = Container.expand(function () {
+ var self = Container.call(this);
+ self.speed = 8;
+ self.gapSize = 300;
+ self.gapPosition = 0; // 0 = top, 1 = middle, 2 = bottom
+ var topPart = self.attachAsset('obstacle', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var bottomPart = LK.getAsset('obstacle', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.addChild(bottomPart);
+ self.setupObstacle = function (position) {
+ self.gapPosition = position;
+ var obstacleHeight = 200;
+ var screenHeight = 2732;
+ var gapSize = self.gapSize;
+ var totalHeight = screenHeight - gapSize;
+ if (position === 0) {
+ // Gap at top
+ topPart.y = -gapSize / 2 - obstacleHeight / 2;
+ bottomPart.y = gapSize / 2 + obstacleHeight / 2;
+ } else if (position === 1) {
+ // Gap in middle
+ topPart.y = -(gapSize / 2 + obstacleHeight / 2);
+ bottomPart.y = gapSize / 2 + obstacleHeight / 2;
+ } else {
+ // Gap at bottom
+ topPart.y = -gapSize / 2 - obstacleHeight / 2;
+ bottomPart.y = screenHeight - gapSize / 2 + obstacleHeight / 2;
+ }
+ };
+ self.update = function () {
+ self.x -= self.speed;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
+ backgroundColor: 0x87CEEB
+});
+
+/****
+* Game Code
+****/
+var bird = game.addChild(new Bird());
+bird.x = 300;
+bird.y = bird.baseY;
+var obstacles = [];
+var score = 0;
+var gameActive = true;
+var obstacleSpawnRate = 80;
+var spawnCounter = 0;
+var difficulty = 1;
+var difficultyIncrement = 0.0002;
+var scoreTxt = new Text2('0', {
+ size: 100,
+ fill: 0x000000
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+function updateScore() {
+ scoreTxt.setText(score);
+ LK.setScore(score);
+}
+function spawnObstacle() {
+ var obstacle = game.addChild(new Obstacle());
+ obstacle.x = 2048 + 200;
+ obstacle.y = 1366;
+ var positions = [0, 1, 2];
+ var randomPosition = positions[Math.floor(Math.random() * positions.length)];
+ obstacle.setupObstacle(randomPosition);
+ obstacle.passed = false;
+ obstacles.push(obstacle);
+}
+function endGame() {
+ gameActive = false;
+ LK.effects.flashScreen(0xFF0000, 500);
+ LK.getSound('hit').play();
+ LK.setTimeout(function () {
+ LK.showGameOver();
+ }, 500);
+}
+game.down = function (x, y, obj) {
+ if (gameActive) {
+ bird.flip();
+ }
+};
+game.move = function (x, y, obj) {
+ // Empty move handler required for touch compatibility
+};
+game.up = function (x, y, obj) {
+ // Empty up handler
+};
+game.update = function () {
+ if (!gameActive) {
+ return;
+ }
+ // Update difficulty
+ difficulty += difficultyIncrement;
+ obstacleSpawnRate = Math.max(40, 80 - Math.floor(difficulty * 5));
+ // Update bird
+ bird.update();
+ // Spawn obstacles
+ spawnCounter++;
+ if (spawnCounter >= obstacleSpawnRate) {
+ spawnObstacle();
+ spawnCounter = 0;
+ }
+ // Update obstacles
+ for (var i = obstacles.length - 1; i >= 0; i--) {
+ var obstacle = obstacles[i];
+ obstacle.speed = 8 + difficulty * 0.5;
+ obstacle.update();
+ // Check if bird passed obstacle
+ if (!obstacle.passed && bird.x > obstacle.x) {
+ obstacle.passed = true;
+ score++;
+ updateScore();
+ LK.getSound('score').play();
+ // Win condition
+ if (score >= 50) {
+ gameActive = false;
+ LK.effects.flashScreen(0x00FF00, 500);
+ LK.setTimeout(function () {
+ LK.showYouWin();
+ }, 500);
+ return;
+ }
+ }
+ // Check collision with bird
+ var birdRadius = 30;
+ var obstacleWidth = 80;
+ var gapSize = obstacle.gapSize;
+ var obstacleHeight = 200;
+ var birdLeft = bird.x - birdRadius;
+ var birdRight = bird.x + birdRadius;
+ var birdTop = bird.y - birdRadius;
+ var birdBottom = bird.y + birdRadius;
+ var obstacleLeft = obstacle.x - obstacleWidth / 2;
+ var obstacleRight = obstacle.x + obstacleWidth / 2;
+ if (birdRight > obstacleLeft && birdLeft < obstacleRight) {
+ // Check vertical collision
+ var gapCenter = obstacle.y;
+ var gapTop = gapCenter - gapSize / 2;
+ var gapBottom = gapCenter + gapSize / 2;
+ if (birdTop < gapTop || birdBottom > gapBottom) {
+ endGame();
+ return;
+ }
+ }
+ // Remove off-screen obstacles
+ if (obstacle.x < -200) {
+ obstacle.destroy();
+ obstacles.splice(i, 1);
+ }
+ }
+ // Boundary collision
+ if (bird.y - 30 <= 0 || bird.y + 30 >= 2732) {
+ endGame();
+ return;
+ }
+};
+LK.playMusic('bgmusic', {
+ loop: true
});
\ No newline at end of file