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", {
maxPassUnlocked: 1
});
/****
* 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;
var obstacles = [];
var score = 0;
var gameActive = false;
var obstacleSpawnRate = 80;
var spawnCounter = 0;
var difficulty = 1;
var difficultyIncrement = 0.0002;
var scoreTxt;
var currentPass = 1;
var maxPassUnlocked = 1;
// Load saved pass data
maxPassUnlocked = storage.maxPassUnlocked || 1;
// Pass configuration system
var passConfig = {
1: {
name: 'Rookie',
difficultyMultiplier: 0.8,
spawnRate: 100,
reward: 'Bronze Badge'
},
2: {
name: 'Pro',
difficultyMultiplier: 1.0,
spawnRate: 80,
reward: 'Silver Badge'
},
3: {
name: 'Expert',
difficultyMultiplier: 1.2,
spawnRate: 60,
reward: 'Gold Badge'
},
4: {
name: 'Master',
difficultyMultiplier: 1.5,
spawnRate: 50,
reward: 'Platinum Badge'
},
5: {
name: 'Legend',
difficultyMultiplier: 1.8,
spawnRate: 40,
reward: 'Diamond Badge'
}
};
var currentPassConfig = passConfig[currentPass];
function initializeGame() {
if (bird) {
bird.destroy();
}
bird = game.addChild(new Bird());
bird.x = 300;
bird.y = bird.baseY;
obstacles = [];
score = 0;
gameActive = true;
spawnCounter = 0;
difficulty = 1;
currentPassConfig = passConfig[currentPass];
obstacleSpawnRate = currentPassConfig.spawnRate;
if (!scoreTxt) {
scoreTxt = new Text2('0', {
size: 100,
fill: 0x000000
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
}
updateScore();
hideMainMenu();
}
function showMainMenu() {
gameActive = false;
LK.gui.center.removeChildren();
var menuContainer = new Container();
LK.gui.center.addChild(menuContainer);
var titleTxt = new Text2('FLIPY BIRD YAP', {
size: 80,
fill: 0x000000
});
titleTxt.anchor.set(0.5, 0.5);
titleTxt.y = -200;
menuContainer.addChild(titleTxt);
var currentPassData = passConfig[currentPass];
var passLabelTxt = new Text2('Pass: ' + currentPass + ' / ' + maxPassUnlocked, {
size: 50,
fill: 0x000000
});
passLabelTxt.anchor.set(0.5, 0.5);
passLabelTxt.y = -50;
menuContainer.addChild(passLabelTxt);
var passNameTxt = new Text2(currentPassData.name + ' - ' + currentPassData.reward, {
size: 35,
fill: 0x4CAF50
});
passNameTxt.anchor.set(0.5, 0.5);
passNameTxt.y = 20;
menuContainer.addChild(passNameTxt);
var playButtonBg = LK.getAsset('gap', {
anchorX: 0.5,
anchorY: 0.5
});
playButtonBg.tint = 0x4CAF50;
playButtonBg.x = 0;
playButtonBg.y = 80;
playButtonBg.width = 300;
playButtonBg.height = 100;
menuContainer.addChild(playButtonBg);
var playTxt = new Text2('PLAY', {
size: 60,
fill: 0xffffff
});
playTxt.anchor.set(0.5, 0.5);
playTxt.x = 0;
playTxt.y = 80;
menuContainer.addChild(playTxt);
playButtonBg.interactive = true;
playButtonBg.down = function () {
initializeGame();
};
if (currentPass > 1) {
var prevButtonBg = LK.getAsset('gap', {
anchorX: 0.5,
anchorY: 0.5
});
prevButtonBg.tint = 0x2196F3;
prevButtonBg.x = -180;
prevButtonBg.y = 250;
prevButtonBg.width = 120;
prevButtonBg.height = 80;
menuContainer.addChild(prevButtonBg);
var prevTxt = new Text2('<', {
size: 50,
fill: 0xffffff
});
prevTxt.anchor.set(0.5, 0.5);
prevTxt.x = -180;
prevTxt.y = 250;
menuContainer.addChild(prevTxt);
prevButtonBg.interactive = true;
prevButtonBg.down = function () {
currentPass = Math.max(1, currentPass - 1);
currentPassConfig = passConfig[currentPass];
showMainMenu();
};
}
if (currentPass < maxPassUnlocked) {
var nextButtonBg = LK.getAsset('gap', {
anchorX: 0.5,
anchorY: 0.5
});
nextButtonBg.tint = 0x2196F3;
nextButtonBg.x = 180;
nextButtonBg.y = 250;
nextButtonBg.width = 120;
nextButtonBg.height = 80;
menuContainer.addChild(nextButtonBg);
var nextTxt = new Text2('>', {
size: 50,
fill: 0xffffff
});
nextTxt.anchor.set(0.5, 0.5);
nextTxt.x = 180;
nextTxt.y = 250;
menuContainer.addChild(nextTxt);
nextButtonBg.interactive = true;
nextButtonBg.down = function () {
currentPass = Math.min(maxPassUnlocked, currentPass + 1);
currentPassConfig = passConfig[currentPass];
showMainMenu();
};
}
}
function hideMainMenu() {
LK.gui.center.removeChildren();
}
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 * currentPassConfig.difficultyMultiplier;
obstacleSpawnRate = Math.max(40, currentPassConfig.spawnRate - 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) * currentPassConfig.difficultyMultiplier;
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;
if (currentPass === maxPassUnlocked) {
maxPassUnlocked++;
storage.maxPassUnlocked = maxPassUnlocked;
}
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
});
showMainMenu(); /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
maxPassUnlocked: 1
});
/****
* 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;
var obstacles = [];
var score = 0;
var gameActive = false;
var obstacleSpawnRate = 80;
var spawnCounter = 0;
var difficulty = 1;
var difficultyIncrement = 0.0002;
var scoreTxt;
var currentPass = 1;
var maxPassUnlocked = 1;
// Load saved pass data
maxPassUnlocked = storage.maxPassUnlocked || 1;
// Pass configuration system
var passConfig = {
1: {
name: 'Rookie',
difficultyMultiplier: 0.8,
spawnRate: 100,
reward: 'Bronze Badge'
},
2: {
name: 'Pro',
difficultyMultiplier: 1.0,
spawnRate: 80,
reward: 'Silver Badge'
},
3: {
name: 'Expert',
difficultyMultiplier: 1.2,
spawnRate: 60,
reward: 'Gold Badge'
},
4: {
name: 'Master',
difficultyMultiplier: 1.5,
spawnRate: 50,
reward: 'Platinum Badge'
},
5: {
name: 'Legend',
difficultyMultiplier: 1.8,
spawnRate: 40,
reward: 'Diamond Badge'
}
};
var currentPassConfig = passConfig[currentPass];
function initializeGame() {
if (bird) {
bird.destroy();
}
bird = game.addChild(new Bird());
bird.x = 300;
bird.y = bird.baseY;
obstacles = [];
score = 0;
gameActive = true;
spawnCounter = 0;
difficulty = 1;
currentPassConfig = passConfig[currentPass];
obstacleSpawnRate = currentPassConfig.spawnRate;
if (!scoreTxt) {
scoreTxt = new Text2('0', {
size: 100,
fill: 0x000000
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
}
updateScore();
hideMainMenu();
}
function showMainMenu() {
gameActive = false;
LK.gui.center.removeChildren();
var menuContainer = new Container();
LK.gui.center.addChild(menuContainer);
var titleTxt = new Text2('FLIPY BIRD YAP', {
size: 80,
fill: 0x000000
});
titleTxt.anchor.set(0.5, 0.5);
titleTxt.y = -200;
menuContainer.addChild(titleTxt);
var currentPassData = passConfig[currentPass];
var passLabelTxt = new Text2('Pass: ' + currentPass + ' / ' + maxPassUnlocked, {
size: 50,
fill: 0x000000
});
passLabelTxt.anchor.set(0.5, 0.5);
passLabelTxt.y = -50;
menuContainer.addChild(passLabelTxt);
var passNameTxt = new Text2(currentPassData.name + ' - ' + currentPassData.reward, {
size: 35,
fill: 0x4CAF50
});
passNameTxt.anchor.set(0.5, 0.5);
passNameTxt.y = 20;
menuContainer.addChild(passNameTxt);
var playButtonBg = LK.getAsset('gap', {
anchorX: 0.5,
anchorY: 0.5
});
playButtonBg.tint = 0x4CAF50;
playButtonBg.x = 0;
playButtonBg.y = 80;
playButtonBg.width = 300;
playButtonBg.height = 100;
menuContainer.addChild(playButtonBg);
var playTxt = new Text2('PLAY', {
size: 60,
fill: 0xffffff
});
playTxt.anchor.set(0.5, 0.5);
playTxt.x = 0;
playTxt.y = 80;
menuContainer.addChild(playTxt);
playButtonBg.interactive = true;
playButtonBg.down = function () {
initializeGame();
};
if (currentPass > 1) {
var prevButtonBg = LK.getAsset('gap', {
anchorX: 0.5,
anchorY: 0.5
});
prevButtonBg.tint = 0x2196F3;
prevButtonBg.x = -180;
prevButtonBg.y = 250;
prevButtonBg.width = 120;
prevButtonBg.height = 80;
menuContainer.addChild(prevButtonBg);
var prevTxt = new Text2('<', {
size: 50,
fill: 0xffffff
});
prevTxt.anchor.set(0.5, 0.5);
prevTxt.x = -180;
prevTxt.y = 250;
menuContainer.addChild(prevTxt);
prevButtonBg.interactive = true;
prevButtonBg.down = function () {
currentPass = Math.max(1, currentPass - 1);
currentPassConfig = passConfig[currentPass];
showMainMenu();
};
}
if (currentPass < maxPassUnlocked) {
var nextButtonBg = LK.getAsset('gap', {
anchorX: 0.5,
anchorY: 0.5
});
nextButtonBg.tint = 0x2196F3;
nextButtonBg.x = 180;
nextButtonBg.y = 250;
nextButtonBg.width = 120;
nextButtonBg.height = 80;
menuContainer.addChild(nextButtonBg);
var nextTxt = new Text2('>', {
size: 50,
fill: 0xffffff
});
nextTxt.anchor.set(0.5, 0.5);
nextTxt.x = 180;
nextTxt.y = 250;
menuContainer.addChild(nextTxt);
nextButtonBg.interactive = true;
nextButtonBg.down = function () {
currentPass = Math.min(maxPassUnlocked, currentPass + 1);
currentPassConfig = passConfig[currentPass];
showMainMenu();
};
}
}
function hideMainMenu() {
LK.gui.center.removeChildren();
}
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 * currentPassConfig.difficultyMultiplier;
obstacleSpawnRate = Math.max(40, currentPassConfig.spawnRate - 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) * currentPassConfig.difficultyMultiplier;
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;
if (currentPass === maxPassUnlocked) {
maxPassUnlocked++;
storage.maxPassUnlocked = maxPassUnlocked;
}
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
});
showMainMenu();