/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Background = Container.expand(function () { var self = Container.call(this); var backgroundSprite = self.attachAsset('background', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 25; // Move slower than clouds for parallax effect self.update = function () { if (gameStarted) { self.x -= self.speed * (1 / 60); } }; return self; }); var Bird = Container.expand(function () { var self = Container.call(this); // Create three bird sprites for animation var birdSprite1 = self.attachAsset('bird1', { anchorX: 0.5, anchorY: 0.5 }); var birdSprite2 = self.attachAsset('bird2', { anchorX: 0.5, anchorY: 0.5 }); var birdSprite3 = self.attachAsset('bird3', { anchorX: 0.5, anchorY: 0.5 }); // Hide sprites 2 and 3 initially birdSprite2.visible = false; birdSprite3.visible = false; // Store sprites in array for easy access self.sprites = [birdSprite1, birdSprite2, birdSprite3]; self.currentSprite = birdSprite1; self.velocity = 0; self.gravity = 2400; self.jumpStrength = -800; self.speed = 300; self.animFrame = 0; self.animTimer = 0; self.jump = function () { self.velocity = self.jumpStrength; LK.getSound('jump').play(); // Bird jump animation on current sprite tween(self.currentSprite, { rotation: -0.3 }, { duration: 150 }); tween(self.currentSprite, { rotation: 0 }, { duration: 300 }); }; self.update = function () { // Apply gravity only when game has started if (gameStarted) { self.velocity += self.gravity * (1 / 60); self.y += self.velocity * (1 / 60); // Move forward only when game has started self.x += self.speed * (1 / 60); } else { // Float without falling before game starts self.velocity = 0; } // Animate bird frame switching self.animTimer++; if (self.animTimer >= 10) { // 6 FPS (60/10 = 6) for smoother wing flapping // Hide current sprite self.currentSprite.visible = false; // Switch to next frame self.animFrame = (self.animFrame + 1) % 3; self.currentSprite = self.sprites[self.animFrame]; // Show new sprite self.currentSprite.visible = true; // Copy rotation from previous sprite self.currentSprite.rotation = self.sprites[(self.animFrame + 2) % 3].rotation; self.animTimer = 0; } // Rotation based on velocity (apply to current sprite) self.currentSprite.rotation = Math.max(-0.5, Math.min(0.5, self.velocity * 0.001)); }; return self; }); var Cloud = Container.expand(function () { var self = Container.call(this); var cloudSprite = self.attachAsset('cloud', { anchorX: 0.5, anchorY: 0.5 }); var cloudGlowSprite = self.attachAsset('cloudGlow', { anchorX: 0.5, anchorY: 0.5 }); cloudGlowSprite.alpha = 0; self.speed = 50; self.glowTimer = Math.random() * 300; // Random start for glow animation self.update = function () { if (gameStarted) { self.x -= self.speed * (1 / 60); // Reset cloud position when it goes off screen if (self.x < -100) { self.x = 2148; self.y = Math.random() * 800 + 200; } } // Glow animation self.glowTimer++; var glowIntensity = Math.sin(self.glowTimer * 0.02) * 0.3 + 0.3; cloudGlowSprite.alpha = Math.max(0, glowIntensity); }; return self; }); var Ground = Container.expand(function () { var self = Container.call(this); var groundSprite = self.attachAsset('ground', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 300; self.update = function () { if (gameStarted) { self.x -= self.speed * (1 / 60); } }; return self; }); var Pipe = Container.expand(function () { var self = Container.call(this); self.gapHeight = 400; self.speed = 300; self.passed = false; var topPipe = self.attachAsset('pipe', { anchorX: 0.5, anchorY: 1 }); var bottomPipe = self.attachAsset('pipe', { anchorX: 0.5, anchorY: 0 }); var topPipeGlow = self.attachAsset('pipeGlow', { anchorX: 0.5, anchorY: 1 }); var bottomPipeGlow = self.attachAsset('pipeGlow', { anchorX: 0.5, anchorY: 0 }); topPipeGlow.alpha = 0; bottomPipeGlow.alpha = 0; self.glowTimer = Math.random() * 200; // Random start for glow animation self.setGapPosition = function (gapY) { topPipe.y = gapY - self.gapHeight / 2; bottomPipe.y = gapY + self.gapHeight / 2; topPipeGlow.y = gapY - self.gapHeight / 2; bottomPipeGlow.y = gapY + self.gapHeight / 2; }; self.update = function () { if (gameStarted) { self.x -= self.speed * (1 / 60); // Check if bird passed this pipe if (!self.passed && self.x < bird.x) { self.passed = true; score++; scoreTxt.setText('SCORE: ' + score); LK.getSound('score').play(); LK.setScore(score); // Update best score if current score is higher if (score > bestScore) { bestScore = score; storage.bestScore = bestScore; bestScoreTxt.setText('BEST: ' + bestScore); } // Flash effect for scoring LK.effects.flashScreen(0x00FF00, 200); } } // Glow animation self.glowTimer++; var glowIntensity = Math.sin(self.glowTimer * 0.03) * 0.4 + 0.4; topPipeGlow.alpha = Math.max(0, glowIntensity); bottomPipeGlow.alpha = Math.max(0, glowIntensity); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Game variables var bird; var pipes = []; var clouds = []; var grounds = []; var backgrounds = []; var score = 0; var gameStarted = false; var pipeSpawnTimer = 0; var pipeSpawnInterval = 240; // 4 seconds at 60 FPS for better spacing and visibility var cameraX = 0; var bestScore = storage.bestScore || 0; // UI Elements var scoreTxt = new Text2('SCORE: 0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var instructionTxt = new Text2('TAP TO JUMP', { size: 80, fill: 0xFFFFFF }); instructionTxt.anchor.set(0.5, 0.5); instructionTxt.y = -200; LK.gui.center.addChild(instructionTxt); var bestScoreTxt = new Text2('BEST: ' + bestScore, { size: 80, fill: 0xFFFFFF }); bestScoreTxt.anchor.set(1, 0); LK.gui.topRight.addChild(bestScoreTxt); var creatorTxt = new Text2('Created by: Jhef_012\nPowered by: Upit AI', { size: 40, fill: 0xFFFFFF }); creatorTxt.anchor.set(0, 1); LK.gui.bottomLeft.addChild(creatorTxt); // Initialize background landscape sections first (at the back) for (var i = 0; i < 5; i++) { var background = game.addChild(new Background()); background.x = i * 2048 - 2048; // Space background sections seamlessly background.y = 1366; // Center vertically backgrounds.push(background); } // Initialize clouds for parallax background for (var i = 0; i < 20; i++) { var cloud = game.addChild(new Cloud()); cloud.x = Math.random() * 8000 - 2000; // Spread clouds across wider area cloud.y = Math.random() * 1500 + 100; // Cover more vertical space cloud.alpha = 0.7; clouds.push(cloud); } // Initialize ground sections for (var i = 0; i < 10; i++) { var ground = game.addChild(new Ground()); ground.x = i * 4000 - 2000; // Space ground sections across the level ground.y = 2650; // Position near bottom of screen grounds.push(ground); } // Initialize bird (in front of background elements) bird = game.addChild(new Bird()); bird.x = 300; bird.y = 1366; // Center of screen // Start background music immediately LK.playMusic('background'); // Spawn initial pipe off-screen var firstPipe = game.addChild(new Pipe()); firstPipe.x = 3000; // Start further off-screen to the right var minY = 2732 * 0.3; var maxY = 2732 * 0.7; var gapY = minY + Math.random() * (maxY - minY); firstPipe.setGapPosition(gapY); pipes.push(firstPipe); // Spawn first pipe function spawnPipe() { var pipe = game.addChild(new Pipe()); pipe.x = bird.x + 2500; // Spawn pipes further off-screen to the right // Random gap position (30-70% of screen height) var minY = 2732 * 0.3; var maxY = 2732 * 0.7; var gapY = minY + Math.random() * (maxY - minY); pipe.setGapPosition(gapY); pipes.push(pipe); LK.getSound('spawn').play(); } // Game controls game.down = function (x, y, obj) { if (!gameStarted) { gameStarted = true; instructionTxt.alpha = 0; } bird.jump(); }; // Main game loop game.update = function () { // Update camera to follow bird if (gameStarted) { var targetCameraX = bird.x - 500; // Show more area to the right for pipe visibility cameraX += (targetCameraX - cameraX) * 0.15; // Smooth camera lerp game.x = -cameraX; // Spawn pipes pipeSpawnTimer++; if (pipeSpawnTimer >= pipeSpawnInterval) { spawnPipe(); pipeSpawnTimer = 0; } } // Only process game logic when game has started if (gameStarted) { // Check boundaries - bird goes off screen or hits ground if (bird.y < 0 || bird.y > 2732) { gameOver(); return; } // Update background sections for (var b = 0; b < backgrounds.length; b++) { var background = backgrounds[b]; // Reset background position when it goes far off screen if (background.x < bird.x - 4000) { background.x = bird.x + 6000; } } // Check ground collisions for (var k = 0; k < grounds.length; k++) { var ground = grounds[k]; if (bird.intersects(ground)) { gameOver(); return; } // Reset ground position when it goes far off screen if (ground.x < bird.x - 6000) { ground.x = bird.x + 8000; } } // Check pipe collisions and cleanup for (var i = pipes.length - 1; i >= 0; i--) { var pipe = pipes[i]; // Check collision with bird if (bird.intersects(pipe)) { gameOver(); return; } // Remove pipes that are far off screen if (pipe.x < bird.x - 1000) { pipe.destroy(); pipes.splice(i, 1); } } // Difficulty scaling every 10 points if (score > 0 && score % 10 === 0) { // Increase bird speed bird.speed = 300 + score / 10 * 20; // Decrease spawn interval (increase difficulty) pipeSpawnInterval = Math.max(60, 90 - score / 10 * 3); // Minimum 1 second // Increase pipe speed to match bird for (var j = 0; j < pipes.length; j++) { pipes[j].speed = bird.speed; } } } }; function gameOver() { LK.getSound('crash').play(); // Screen shake effect tween(game, { y: -20 }, { duration: 100 }); tween(game, { y: 20 }, { duration: 100 }); tween(game, { y: 0 }, { duration: 100 }); // Flash red LK.effects.flashScreen(0xFF0000, 500); // Show game over LK.setTimeout(function () { LK.showGameOver(); }, 500); }
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Background = Container.expand(function () {
var self = Container.call(this);
var backgroundSprite = self.attachAsset('background', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 25; // Move slower than clouds for parallax effect
self.update = function () {
if (gameStarted) {
self.x -= self.speed * (1 / 60);
}
};
return self;
});
var Bird = Container.expand(function () {
var self = Container.call(this);
// Create three bird sprites for animation
var birdSprite1 = self.attachAsset('bird1', {
anchorX: 0.5,
anchorY: 0.5
});
var birdSprite2 = self.attachAsset('bird2', {
anchorX: 0.5,
anchorY: 0.5
});
var birdSprite3 = self.attachAsset('bird3', {
anchorX: 0.5,
anchorY: 0.5
});
// Hide sprites 2 and 3 initially
birdSprite2.visible = false;
birdSprite3.visible = false;
// Store sprites in array for easy access
self.sprites = [birdSprite1, birdSprite2, birdSprite3];
self.currentSprite = birdSprite1;
self.velocity = 0;
self.gravity = 2400;
self.jumpStrength = -800;
self.speed = 300;
self.animFrame = 0;
self.animTimer = 0;
self.jump = function () {
self.velocity = self.jumpStrength;
LK.getSound('jump').play();
// Bird jump animation on current sprite
tween(self.currentSprite, {
rotation: -0.3
}, {
duration: 150
});
tween(self.currentSprite, {
rotation: 0
}, {
duration: 300
});
};
self.update = function () {
// Apply gravity only when game has started
if (gameStarted) {
self.velocity += self.gravity * (1 / 60);
self.y += self.velocity * (1 / 60);
// Move forward only when game has started
self.x += self.speed * (1 / 60);
} else {
// Float without falling before game starts
self.velocity = 0;
}
// Animate bird frame switching
self.animTimer++;
if (self.animTimer >= 10) {
// 6 FPS (60/10 = 6) for smoother wing flapping
// Hide current sprite
self.currentSprite.visible = false;
// Switch to next frame
self.animFrame = (self.animFrame + 1) % 3;
self.currentSprite = self.sprites[self.animFrame];
// Show new sprite
self.currentSprite.visible = true;
// Copy rotation from previous sprite
self.currentSprite.rotation = self.sprites[(self.animFrame + 2) % 3].rotation;
self.animTimer = 0;
}
// Rotation based on velocity (apply to current sprite)
self.currentSprite.rotation = Math.max(-0.5, Math.min(0.5, self.velocity * 0.001));
};
return self;
});
var Cloud = Container.expand(function () {
var self = Container.call(this);
var cloudSprite = self.attachAsset('cloud', {
anchorX: 0.5,
anchorY: 0.5
});
var cloudGlowSprite = self.attachAsset('cloudGlow', {
anchorX: 0.5,
anchorY: 0.5
});
cloudGlowSprite.alpha = 0;
self.speed = 50;
self.glowTimer = Math.random() * 300; // Random start for glow animation
self.update = function () {
if (gameStarted) {
self.x -= self.speed * (1 / 60);
// Reset cloud position when it goes off screen
if (self.x < -100) {
self.x = 2148;
self.y = Math.random() * 800 + 200;
}
}
// Glow animation
self.glowTimer++;
var glowIntensity = Math.sin(self.glowTimer * 0.02) * 0.3 + 0.3;
cloudGlowSprite.alpha = Math.max(0, glowIntensity);
};
return self;
});
var Ground = Container.expand(function () {
var self = Container.call(this);
var groundSprite = self.attachAsset('ground', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 300;
self.update = function () {
if (gameStarted) {
self.x -= self.speed * (1 / 60);
}
};
return self;
});
var Pipe = Container.expand(function () {
var self = Container.call(this);
self.gapHeight = 400;
self.speed = 300;
self.passed = false;
var topPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 1
});
var bottomPipe = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: 0
});
var topPipeGlow = self.attachAsset('pipeGlow', {
anchorX: 0.5,
anchorY: 1
});
var bottomPipeGlow = self.attachAsset('pipeGlow', {
anchorX: 0.5,
anchorY: 0
});
topPipeGlow.alpha = 0;
bottomPipeGlow.alpha = 0;
self.glowTimer = Math.random() * 200; // Random start for glow animation
self.setGapPosition = function (gapY) {
topPipe.y = gapY - self.gapHeight / 2;
bottomPipe.y = gapY + self.gapHeight / 2;
topPipeGlow.y = gapY - self.gapHeight / 2;
bottomPipeGlow.y = gapY + self.gapHeight / 2;
};
self.update = function () {
if (gameStarted) {
self.x -= self.speed * (1 / 60);
// Check if bird passed this pipe
if (!self.passed && self.x < bird.x) {
self.passed = true;
score++;
scoreTxt.setText('SCORE: ' + score);
LK.getSound('score').play();
LK.setScore(score);
// Update best score if current score is higher
if (score > bestScore) {
bestScore = score;
storage.bestScore = bestScore;
bestScoreTxt.setText('BEST: ' + bestScore);
}
// Flash effect for scoring
LK.effects.flashScreen(0x00FF00, 200);
}
}
// Glow animation
self.glowTimer++;
var glowIntensity = Math.sin(self.glowTimer * 0.03) * 0.4 + 0.4;
topPipeGlow.alpha = Math.max(0, glowIntensity);
bottomPipeGlow.alpha = Math.max(0, glowIntensity);
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Game variables
var bird;
var pipes = [];
var clouds = [];
var grounds = [];
var backgrounds = [];
var score = 0;
var gameStarted = false;
var pipeSpawnTimer = 0;
var pipeSpawnInterval = 240; // 4 seconds at 60 FPS for better spacing and visibility
var cameraX = 0;
var bestScore = storage.bestScore || 0;
// UI Elements
var scoreTxt = new Text2('SCORE: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var instructionTxt = new Text2('TAP TO JUMP', {
size: 80,
fill: 0xFFFFFF
});
instructionTxt.anchor.set(0.5, 0.5);
instructionTxt.y = -200;
LK.gui.center.addChild(instructionTxt);
var bestScoreTxt = new Text2('BEST: ' + bestScore, {
size: 80,
fill: 0xFFFFFF
});
bestScoreTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(bestScoreTxt);
var creatorTxt = new Text2('Created by: Jhef_012\nPowered by: Upit AI', {
size: 40,
fill: 0xFFFFFF
});
creatorTxt.anchor.set(0, 1);
LK.gui.bottomLeft.addChild(creatorTxt);
// Initialize background landscape sections first (at the back)
for (var i = 0; i < 5; i++) {
var background = game.addChild(new Background());
background.x = i * 2048 - 2048; // Space background sections seamlessly
background.y = 1366; // Center vertically
backgrounds.push(background);
}
// Initialize clouds for parallax background
for (var i = 0; i < 20; i++) {
var cloud = game.addChild(new Cloud());
cloud.x = Math.random() * 8000 - 2000; // Spread clouds across wider area
cloud.y = Math.random() * 1500 + 100; // Cover more vertical space
cloud.alpha = 0.7;
clouds.push(cloud);
}
// Initialize ground sections
for (var i = 0; i < 10; i++) {
var ground = game.addChild(new Ground());
ground.x = i * 4000 - 2000; // Space ground sections across the level
ground.y = 2650; // Position near bottom of screen
grounds.push(ground);
}
// Initialize bird (in front of background elements)
bird = game.addChild(new Bird());
bird.x = 300;
bird.y = 1366; // Center of screen
// Start background music immediately
LK.playMusic('background');
// Spawn initial pipe off-screen
var firstPipe = game.addChild(new Pipe());
firstPipe.x = 3000; // Start further off-screen to the right
var minY = 2732 * 0.3;
var maxY = 2732 * 0.7;
var gapY = minY + Math.random() * (maxY - minY);
firstPipe.setGapPosition(gapY);
pipes.push(firstPipe);
// Spawn first pipe
function spawnPipe() {
var pipe = game.addChild(new Pipe());
pipe.x = bird.x + 2500; // Spawn pipes further off-screen to the right
// Random gap position (30-70% of screen height)
var minY = 2732 * 0.3;
var maxY = 2732 * 0.7;
var gapY = minY + Math.random() * (maxY - minY);
pipe.setGapPosition(gapY);
pipes.push(pipe);
LK.getSound('spawn').play();
}
// Game controls
game.down = function (x, y, obj) {
if (!gameStarted) {
gameStarted = true;
instructionTxt.alpha = 0;
}
bird.jump();
};
// Main game loop
game.update = function () {
// Update camera to follow bird
if (gameStarted) {
var targetCameraX = bird.x - 500; // Show more area to the right for pipe visibility
cameraX += (targetCameraX - cameraX) * 0.15; // Smooth camera lerp
game.x = -cameraX;
// Spawn pipes
pipeSpawnTimer++;
if (pipeSpawnTimer >= pipeSpawnInterval) {
spawnPipe();
pipeSpawnTimer = 0;
}
}
// Only process game logic when game has started
if (gameStarted) {
// Check boundaries - bird goes off screen or hits ground
if (bird.y < 0 || bird.y > 2732) {
gameOver();
return;
}
// Update background sections
for (var b = 0; b < backgrounds.length; b++) {
var background = backgrounds[b];
// Reset background position when it goes far off screen
if (background.x < bird.x - 4000) {
background.x = bird.x + 6000;
}
}
// Check ground collisions
for (var k = 0; k < grounds.length; k++) {
var ground = grounds[k];
if (bird.intersects(ground)) {
gameOver();
return;
}
// Reset ground position when it goes far off screen
if (ground.x < bird.x - 6000) {
ground.x = bird.x + 8000;
}
}
// Check pipe collisions and cleanup
for (var i = pipes.length - 1; i >= 0; i--) {
var pipe = pipes[i];
// Check collision with bird
if (bird.intersects(pipe)) {
gameOver();
return;
}
// Remove pipes that are far off screen
if (pipe.x < bird.x - 1000) {
pipe.destroy();
pipes.splice(i, 1);
}
}
// Difficulty scaling every 10 points
if (score > 0 && score % 10 === 0) {
// Increase bird speed
bird.speed = 300 + score / 10 * 20;
// Decrease spawn interval (increase difficulty)
pipeSpawnInterval = Math.max(60, 90 - score / 10 * 3); // Minimum 1 second
// Increase pipe speed to match bird
for (var j = 0; j < pipes.length; j++) {
pipes[j].speed = bird.speed;
}
}
}
};
function gameOver() {
LK.getSound('crash').play();
// Screen shake effect
tween(game, {
y: -20
}, {
duration: 100
});
tween(game, {
y: 20
}, {
duration: 100
});
tween(game, {
y: 0
}, {
duration: 100
});
// Flash red
LK.effects.flashScreen(0xFF0000, 500);
// Show game over
LK.setTimeout(function () {
LK.showGameOver();
}, 500);
}
Nube. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Tubería recta vertical color verde. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Primera de tres imagenes que crearan sensacion de movimiento a un pajaro. Esta tendra las alas extendidas
Segunda de tres imagenes que crearan sensacion de movimiento a un pajaro. Esta tendra las alas medio extendidas
Shine