/**** * Classes ****/ //<Assets used in the game will automatically appear here> // Bird class to represent the flying bird var Bird = Container.expand(function () { var self = Container.call(this); var birdGraphics = self.attachAsset('bird', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.y = 0; // Reset position if it goes off screen } }; }); // Grass class to represent grass in the background var Grass = Container.expand(function () { var self = Container.call(this); var grassGraphics = self.attachAsset('grass', { anchorX: 0, anchorY: 1 }); self.speed = -2; self.update = function () { self.x += self.speed; if (self.x < 0) { self.x = 2048; // Reset position if it goes off screen } }; }); // Obstacle class to represent obstacles in the sky var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -3; self.update = function () { self.x += self.speed; if (self.x < 0) { self.x = 2048; // Reset position if it goes off screen } }; }); // Tree class to represent trees in the background var Tree = Container.expand(function () { var self = Container.call(this); var treeGraphics = self.attachAsset('tree', { anchorX: 0.5, anchorY: 1 }); self.speed = -1; self.update = function () { self.x += self.speed; if (self.x < 0) { self.x = 2048; // Reset position if it goes off screen } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xADD8E6 // Light blue background }); /**** * Game Code ****/ // Initialize bird and obstacles var bird = game.addChild(new Bird()); bird.x = 1024; // Center horizontally bird.y = 1366; // Center vertically var obstacles = []; for (var i = 0; i < 10; i++) { // Increase the number of obstacles to 10 var obstacle = new Obstacle(); obstacle.x = 2048 + i * 200; // Decrease the horizontal gap between obstacles obstacle.y = Math.random() * 2732; // Random vertical position obstacles.push(obstacle); game.addChild(obstacle); } var grass = game.addChild(new Grass()); LK.playMusic('satisfySong'); grass.x = 0; grass.y = 2732; // Play the satisfying song when the game starts LK.playMusic('satisfySong'); // Handle touch events to make the bird fly upwards game.down = function (x, y, obj) { bird.speed = -10; // Move bird upwards }; game.up = function (x, y, obj) { bird.speed = 10; // Move bird downwards }; // Update game logic game.update = function () { for (var i = 0; i < obstacles.length; i++) { if (bird.intersects(obstacles[i])) { LK.effects.flashScreen(0xff0000, 1000); // Flash screen red LK.showGameOver(); // End game } } };
/****
* Classes
****/
//<Assets used in the game will automatically appear here>
// Bird class to represent the flying bird
var Bird = Container.expand(function () {
var self = Container.call(this);
var birdGraphics = self.attachAsset('bird', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.y = 0; // Reset position if it goes off screen
}
};
});
// Grass class to represent grass in the background
var Grass = Container.expand(function () {
var self = Container.call(this);
var grassGraphics = self.attachAsset('grass', {
anchorX: 0,
anchorY: 1
});
self.speed = -2;
self.update = function () {
self.x += self.speed;
if (self.x < 0) {
self.x = 2048; // Reset position if it goes off screen
}
};
});
// Obstacle class to represent obstacles in the sky
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -3;
self.update = function () {
self.x += self.speed;
if (self.x < 0) {
self.x = 2048; // Reset position if it goes off screen
}
};
});
// Tree class to represent trees in the background
var Tree = Container.expand(function () {
var self = Container.call(this);
var treeGraphics = self.attachAsset('tree', {
anchorX: 0.5,
anchorY: 1
});
self.speed = -1;
self.update = function () {
self.x += self.speed;
if (self.x < 0) {
self.x = 2048; // Reset position if it goes off screen
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xADD8E6 // Light blue background
});
/****
* Game Code
****/
// Initialize bird and obstacles
var bird = game.addChild(new Bird());
bird.x = 1024; // Center horizontally
bird.y = 1366; // Center vertically
var obstacles = [];
for (var i = 0; i < 10; i++) {
// Increase the number of obstacles to 10
var obstacle = new Obstacle();
obstacle.x = 2048 + i * 200; // Decrease the horizontal gap between obstacles
obstacle.y = Math.random() * 2732; // Random vertical position
obstacles.push(obstacle);
game.addChild(obstacle);
}
var grass = game.addChild(new Grass());
LK.playMusic('satisfySong');
grass.x = 0;
grass.y = 2732;
// Play the satisfying song when the game starts
LK.playMusic('satisfySong');
// Handle touch events to make the bird fly upwards
game.down = function (x, y, obj) {
bird.speed = -10; // Move bird upwards
};
game.up = function (x, y, obj) {
bird.speed = 10; // Move bird downwards
};
// Update game logic
game.update = function () {
for (var i = 0; i < obstacles.length; i++) {
if (bird.intersects(obstacles[i])) {
LK.effects.flashScreen(0xff0000, 1000); // Flash screen red
LK.showGameOver(); // End game
}
}
};
Make a 🐦. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Make a triangle with sharp edges. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Make a small Make a small grass. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.