/**** * Classes ****/ // Cloud class var Cloud = Container.expand(function () { var self = Container.call(this); var cloudGraphics = self.attachAsset('cloud', { anchorX: 0.5, anchorY: 0.5 }); cloudGraphics.alpha = 0.75; self.speed = Math.random() * 2; self.update = function () { self.y += self.speed; }; }); // Headwind class var Headwind = Container.expand(function () { var self = Container.call(this); var headwindGraphics = self.attachAsset('headwind', { anchorX: 0.5, anchorY: 0.5 }); self.speed = Math.random() * 3.33; self.update = function () { self.y += self.speed; }; }); // Lightning class var Lightning = Container.expand(function () { var self = Container.call(this); var lightningGraphics = self.attachAsset('lightning', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { if (self.intersects(seagull)) { seagull.speed = 0; seagull.x = 2048 / 2; seagull.y = 2732 - 200; } LK.setTimeout(function () { self.destroy(); }, 500); }; }); //<Assets used in the game will automatically appear here> // Seagull class var Seagull = Container.expand(function () { var self = Container.call(this); var seagullGraphics = self.attachAsset('seagull', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 1; self.update = function () { // Move the seagull towards the top of the screen self.y -= self.speed; }; }); // Thermal class var Thermal = Container.expand(function () { var self = Container.call(this); var thermalGraphics = self.attachAsset('thermal', { anchorX: 0.5, anchorY: 0.5 }); self.speed = Math.random() * 7.5; self.rotationSpeed = 0.02; // Set rotation speed self.update = function () { self.y += self.speed; self.rotation += self.rotationSpeed; // Rotate the thermal }; }); // Wave class var Wave = Container.expand(function () { var self = Container.call(this); var waveGraphics = self.attachAsset('wave', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 1; self.update = function () { self.y -= self.speed; if (self.y < -100) { self.destroy(); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB //Init game with sky blue background }); /**** * Game Code ****/ var speedTxt = new Text2('Speed: 1', { size: 50, fill: "#333333", background: "#ffffff" }); speedTxt.anchor.set(0.5, 0.5); LK.gui.center.addChildAt(speedTxt, LK.gui.center.children.length); var seagull = game.addChild(new Seagull()); seagull.x = 2048 / 2; seagull.y = 2732 - 200; var thermals = []; var headwinds = []; function handleMove(x, y, obj) { // Remove the seagull's momentum seagull.x += (x - seagull.x) * 0.1; } game.move = handleMove; game.update = function () { for (var i = thermals.length - 1; i >= 0; i--) { if (thermals[i].intersects(seagull)) { if (speedBoostTimer) { LK.clearTimeout(speedBoostTimer); // Clear the previous speed boost timer } if (seagull.speed == 0) { seagull.speed = 1.00; // Set seagull speed to +1.00 if it's currently 0 } else { seagull.speed = Math.min(Math.max(seagull.speed * 2, -1.00), 4.00); // Double seagull speed when it intersects with thermal, but ensure it's at least -1.00 and at most 4.00 } var speedBoostTimer = LK.setTimeout(function () { seagull.speed = Math.min(Math.max(seagull.speed / 2, -1.00), 4.00); // Halve seagull speed after 3 seconds, but ensure it's at least -1.00 and at most 4.00 }, 3000); thermals[i].destroy(); thermals.splice(i, 1); } if (thermals[i] && thermals[i].y > 2732) { thermals[i].destroy(); thermals.splice(i, 1); } } for (var j = headwinds.length - 1; j >= 0; j--) { if (headwinds[j].intersects(seagull)) { seagull.speed = Math.min(Math.max(seagull.speed / 2, -1.00), 4.00); // Cut the seagull's speed by half, but ensure it's at least -1.00 and at most 4.00 seagull.y += 60; // Push the seagull back farther headwinds[j].destroy(); // Destroy the headwind headwinds.splice(j, 1); var speedRecoveryTimer = LK.setTimeout(function () { seagull.speed = Math.min(Math.max(seagull.speed * 2, -1.00), 4.00); // Reverse the speed reduction after 2 seconds, but ensure it's at least -1.00 and at most 4.00 if (seagull.speed < 0) { // If speed is still negative after recovery var negativeSpeedTimer = LK.setTimeout(function () { seagull.speed = Math.min(Math.max(1, -1.00), 4.00); // Reset speed to 1 after 5 seconds, but ensure it's at least -1.00 and at most 4.00 }, 5000); } }, 2000); } if (headwinds[j] && headwinds[j].y > 2732) { headwinds[j].destroy(); headwinds.splice(j, 1); } } var seagullHeightRatio = 1 - seagull.y / 2732; if (LK.ticks % Math.floor(120 / (seagullHeightRatio + 1)) == 0) { var newThermal = new Thermal(); newThermal.x = Math.random() * 2048; newThermal.y = -50; thermals.push(newThermal); game.addChild(newThermal); } if (LK.ticks % Math.floor(45 * (seagullHeightRatio + 1)) == 0) { var newHeadwind = new Headwind(); newHeadwind.x = Math.random() * 2048; newHeadwind.y = -50; headwinds.push(newHeadwind); game.addChild(newHeadwind); } if (LK.ticks % Math.floor(60 * (seagullHeightRatio + 1)) == 0) { var newCloud1 = new Cloud(); newCloud1.x = Math.random() * 2048; newCloud1.y = -50; game.addChild(newCloud1); var newCloud2 = new Cloud(); newCloud2.x = Math.random() * 2048; newCloud2.y = -50; game.addChild(newCloud2); } // Check if the seagull reaches the top edge of the screen if (seagull.y <= 0) { // Show game over with a win message LK.showGameOver("Congratulations! You've reached the top. Victory is yours!"); // End the game return; } // Add lightning to the game if (Math.random() < 0.005 * (seagullHeightRatio + 1)) { var newLightning = new Lightning(); newLightning.x = Math.random() * 2048; newLightning.y = Math.random() * 2732; game.addChild(newLightning); } // Remove clouds that have moved off the screen for (var i = game.children.length - 1; i >= 0; i--) { if (game.children[i] instanceof Cloud && game.children[i].y > 2732) { game.children[i].destroy(); } } // Check if the seagull reaches the bottom edge of the screen if (seagull.y >= 2732) { // Show game over with a lose message LK.showGameOver("Oh no! You've lost the game."); return; } // Update the speed counter speedTxt.setText('Speed: ' + seagull.speed.toFixed(2)); }; // Add waves to the game if (LK.ticks % 120 == 0) { var newWave = new Wave(); newWave.x = Math.random() * 2048; newWave.y = 2732 - newWave.height; game.addChild(newWave); }
/****
* Classes
****/
// Cloud class
var Cloud = Container.expand(function () {
var self = Container.call(this);
var cloudGraphics = self.attachAsset('cloud', {
anchorX: 0.5,
anchorY: 0.5
});
cloudGraphics.alpha = 0.75;
self.speed = Math.random() * 2;
self.update = function () {
self.y += self.speed;
};
});
// Headwind class
var Headwind = Container.expand(function () {
var self = Container.call(this);
var headwindGraphics = self.attachAsset('headwind', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = Math.random() * 3.33;
self.update = function () {
self.y += self.speed;
};
});
// Lightning class
var Lightning = Container.expand(function () {
var self = Container.call(this);
var lightningGraphics = self.attachAsset('lightning', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
if (self.intersects(seagull)) {
seagull.speed = 0;
seagull.x = 2048 / 2;
seagull.y = 2732 - 200;
}
LK.setTimeout(function () {
self.destroy();
}, 500);
};
});
//<Assets used in the game will automatically appear here>
// Seagull class
var Seagull = Container.expand(function () {
var self = Container.call(this);
var seagullGraphics = self.attachAsset('seagull', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 1;
self.update = function () {
// Move the seagull towards the top of the screen
self.y -= self.speed;
};
});
// Thermal class
var Thermal = Container.expand(function () {
var self = Container.call(this);
var thermalGraphics = self.attachAsset('thermal', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = Math.random() * 7.5;
self.rotationSpeed = 0.02; // Set rotation speed
self.update = function () {
self.y += self.speed;
self.rotation += self.rotationSpeed; // Rotate the thermal
};
});
// Wave class
var Wave = Container.expand(function () {
var self = Container.call(this);
var waveGraphics = self.attachAsset('wave', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 1;
self.update = function () {
self.y -= self.speed;
if (self.y < -100) {
self.destroy();
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB //Init game with sky blue background
});
/****
* Game Code
****/
var speedTxt = new Text2('Speed: 1', {
size: 50,
fill: "#333333",
background: "#ffffff"
});
speedTxt.anchor.set(0.5, 0.5);
LK.gui.center.addChildAt(speedTxt, LK.gui.center.children.length);
var seagull = game.addChild(new Seagull());
seagull.x = 2048 / 2;
seagull.y = 2732 - 200;
var thermals = [];
var headwinds = [];
function handleMove(x, y, obj) {
// Remove the seagull's momentum
seagull.x += (x - seagull.x) * 0.1;
}
game.move = handleMove;
game.update = function () {
for (var i = thermals.length - 1; i >= 0; i--) {
if (thermals[i].intersects(seagull)) {
if (speedBoostTimer) {
LK.clearTimeout(speedBoostTimer); // Clear the previous speed boost timer
}
if (seagull.speed == 0) {
seagull.speed = 1.00; // Set seagull speed to +1.00 if it's currently 0
} else {
seagull.speed = Math.min(Math.max(seagull.speed * 2, -1.00), 4.00); // Double seagull speed when it intersects with thermal, but ensure it's at least -1.00 and at most 4.00
}
var speedBoostTimer = LK.setTimeout(function () {
seagull.speed = Math.min(Math.max(seagull.speed / 2, -1.00), 4.00); // Halve seagull speed after 3 seconds, but ensure it's at least -1.00 and at most 4.00
}, 3000);
thermals[i].destroy();
thermals.splice(i, 1);
}
if (thermals[i] && thermals[i].y > 2732) {
thermals[i].destroy();
thermals.splice(i, 1);
}
}
for (var j = headwinds.length - 1; j >= 0; j--) {
if (headwinds[j].intersects(seagull)) {
seagull.speed = Math.min(Math.max(seagull.speed / 2, -1.00), 4.00); // Cut the seagull's speed by half, but ensure it's at least -1.00 and at most 4.00
seagull.y += 60; // Push the seagull back farther
headwinds[j].destroy(); // Destroy the headwind
headwinds.splice(j, 1);
var speedRecoveryTimer = LK.setTimeout(function () {
seagull.speed = Math.min(Math.max(seagull.speed * 2, -1.00), 4.00); // Reverse the speed reduction after 2 seconds, but ensure it's at least -1.00 and at most 4.00
if (seagull.speed < 0) {
// If speed is still negative after recovery
var negativeSpeedTimer = LK.setTimeout(function () {
seagull.speed = Math.min(Math.max(1, -1.00), 4.00); // Reset speed to 1 after 5 seconds, but ensure it's at least -1.00 and at most 4.00
}, 5000);
}
}, 2000);
}
if (headwinds[j] && headwinds[j].y > 2732) {
headwinds[j].destroy();
headwinds.splice(j, 1);
}
}
var seagullHeightRatio = 1 - seagull.y / 2732;
if (LK.ticks % Math.floor(120 / (seagullHeightRatio + 1)) == 0) {
var newThermal = new Thermal();
newThermal.x = Math.random() * 2048;
newThermal.y = -50;
thermals.push(newThermal);
game.addChild(newThermal);
}
if (LK.ticks % Math.floor(45 * (seagullHeightRatio + 1)) == 0) {
var newHeadwind = new Headwind();
newHeadwind.x = Math.random() * 2048;
newHeadwind.y = -50;
headwinds.push(newHeadwind);
game.addChild(newHeadwind);
}
if (LK.ticks % Math.floor(60 * (seagullHeightRatio + 1)) == 0) {
var newCloud1 = new Cloud();
newCloud1.x = Math.random() * 2048;
newCloud1.y = -50;
game.addChild(newCloud1);
var newCloud2 = new Cloud();
newCloud2.x = Math.random() * 2048;
newCloud2.y = -50;
game.addChild(newCloud2);
}
// Check if the seagull reaches the top edge of the screen
if (seagull.y <= 0) {
// Show game over with a win message
LK.showGameOver("Congratulations! You've reached the top. Victory is yours!");
// End the game
return;
}
// Add lightning to the game
if (Math.random() < 0.005 * (seagullHeightRatio + 1)) {
var newLightning = new Lightning();
newLightning.x = Math.random() * 2048;
newLightning.y = Math.random() * 2732;
game.addChild(newLightning);
}
// Remove clouds that have moved off the screen
for (var i = game.children.length - 1; i >= 0; i--) {
if (game.children[i] instanceof Cloud && game.children[i].y > 2732) {
game.children[i].destroy();
}
}
// Check if the seagull reaches the bottom edge of the screen
if (seagull.y >= 2732) {
// Show game over with a lose message
LK.showGameOver("Oh no! You've lost the game.");
return;
}
// Update the speed counter
speedTxt.setText('Speed: ' + seagull.speed.toFixed(2));
};
// Add waves to the game
if (LK.ticks % 120 == 0) {
var newWave = new Wave();
newWave.x = Math.random() * 2048;
newWave.y = 2732 - newWave.height;
game.addChild(newWave);
}
whirling spiral wind squiggles. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
fluffy cloud. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
storm cloud. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
ocean surface overhead view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cresting wave. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
seagull with wings spread, seen from above. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
lightning bolt. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.