/**** * Classes ****/ // Airplane class var Airplane = Container.expand(function () { var self = Container.call(this); var airplaneGraphics = self.attachAsset('airplane', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -7.5; self.update = function () { self.x += self.speed; if (self.x < -airplaneGraphics.width / 2) { self.x = 2048 + airplaneGraphics.width / 2; } }; }); // Gift class var Gift = Container.expand(function () { var self = Container.call(this); var giftGraphics = self.attachAsset('gift', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y += self.speed; }; }); // Roof class var Roof = Container.expand(function () { var self = Container.call(this); var sizeFactor = Math.random() * 0.4 + 0.8; // Random factor between 0.8 and 1.2 var roofGraphics = self.attachAsset('roof', { anchorX: 0.5, anchorY: 0.5, scaleX: sizeFactor, scaleY: sizeFactor }); self.speed = -5; self.update = function () { self.x += self.speed; if (self.x < -roofGraphics.width / 2) { self.x = 2048 + roofGraphics.width / 2; } }; }); //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Santa's Sleigh class var SantaSleigh = Container.expand(function () { var self = Container.call(this); var sleighGraphics = self.attachAsset('santaSleigh', { anchorX: 0.5, anchorY: 0.5 }); self.velocity = 0; self.gravity = 0.5; self.lift = -10; self.update = function () { self.velocity += self.gravity; self.y += self.velocity; if (self.y > 2732 - sleighGraphics.height / 2) { self.y = 2732 - sleighGraphics.height / 2; self.velocity = 0; } if (self.y < sleighGraphics.height / 2) { self.y = sleighGraphics.height / 2; self.velocity = 0; } }; self.flap = function () { self.velocity = self.lift; }; self.dropGift = function () { var gift = new Gift(); gift.x = self.x; gift.y = self.y; game.addChild(gift); }; self.leaveRoof = function () { LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); }; }); // Create a new Text2 object to display the counter at the center top of the map // Snowflake class var Snowflake = Container.expand(function () { var self = Container.call(this); var snowflakeGraphics = self.attachAsset('snowflake', { anchorX: 0.5, anchorY: 0.5 }); self.speed = Math.random() * 2 + 1; // Random speed between 1 and 3 self.update = function () { self.y += self.speed; if (self.y > 2732 + snowflakeGraphics.height / 2) { self.y = -snowflakeGraphics.height / 2; self.x = Math.random() * 2048; // Random x-coordinate } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Black background }); /**** * Game Code ****/ // Add a gift asset above the counter var giftIcon = LK.getAsset('gift', { anchorX: 0.5, anchorY: 0.5 }); // Create a new Text2 object to display the counter at the center bottom of the map var scoreTxt = new Text2('0', { size: giftIcon.width, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 1); LK.gui.bottom.addChild(scoreTxt); giftIcon.x = scoreTxt.x; giftIcon.y = scoreTxt.y - scoreTxt.height - giftIcon.height / 2 - 10; // 10 is the space between the gift icon and the score text LK.gui.bottom.addChild(giftIcon); var wallpaper = game.attachAsset('wallpaper', { anchorX: 0.0, anchorY: 0.0 }); // Initialize game elements var santaSleigh = game.addChild(new SantaSleigh()); santaSleigh.x = 400; santaSleigh.y = 1366; // Center vertically // Initialize a counter variable var counter = 0; var roofs = []; var airplanes = []; // Delay loading roofs for 2 seconds LK.setTimeout(function () { // Create two roofs with half the original distance var roof1 = new Roof(); roof1.x = 2048; roof1.y = 2732 - 100; // Bottom of the screen roofs.push(roof1); game.addChild(roof1); var roof2 = new Roof(); roof2.x = 2048 / 2; roof2.y = 2732 - 100; // Bottom of the screen roofs.push(roof2); game.addChild(roof2); }, 2000); // Initialize snowflakes var snowflakes = []; for (var i = 0; i < 100; i++) { // Create 100 snowflakes var snowflake = new Snowflake(); snowflake.x = Math.random() * 2048; // Random x-coordinate snowflake.y = Math.random() * 2732; // Random y-coordinate snowflakes.push(snowflake); game.addChild(snowflake); } // Create airplane var airplane = new Airplane(); airplane.x = 2048; airplane.y = Math.random() * (1366 - 200) + 200; // Randomize y-coordinate in the upper half of the screen airplanes.push(airplane); game.addChild(airplane); // Handle game events game.down = function (x, y, obj) { santaSleigh.flap(); }; // Update game state var gifts = []; game.update = function () { santaSleigh.update(); for (var i = 0; i < roofs.length; i++) { roofs[i].update(); if (santaSleigh.intersects(roofs[i])) { santaSleigh.dropGift(); LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } else { if (LK.ticks % 8 == 0) { santaSleigh.leaveRoof(); } } } for (var j = 0; j < airplanes.length; j++) { airplanes[j].update(); if (santaSleigh.intersects(airplanes[j])) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } // Play Sleighbell sound every 5 seconds if (LK.ticks % 300 == 0) { LK.getSound('Sleighbell').play(); } // Play Hohoho sound every 7 seconds if (LK.ticks % 420 == 0) { LK.getSound('Hohoho').play(); } // Display the counter variable in the score text scoreTxt.setText(counter); for (var k = 0; k < snowflakes.length; k++) { snowflakes[k].update(); } for (var l = 0; l < gifts.length; l++) { gifts[l].update(); if (gifts[l].y > 2732) { gifts[l].destroy(); gifts.splice(l, 1); } } // Increment the counter variable every eighth tick if (LK.ticks % 8 == 0) { counter++; } };
/****
* Classes
****/
// Airplane class
var Airplane = Container.expand(function () {
var self = Container.call(this);
var airplaneGraphics = self.attachAsset('airplane', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -7.5;
self.update = function () {
self.x += self.speed;
if (self.x < -airplaneGraphics.width / 2) {
self.x = 2048 + airplaneGraphics.width / 2;
}
};
});
// Gift class
var Gift = Container.expand(function () {
var self = Container.call(this);
var giftGraphics = self.attachAsset('gift', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
self.y += self.speed;
};
});
// Roof class
var Roof = Container.expand(function () {
var self = Container.call(this);
var sizeFactor = Math.random() * 0.4 + 0.8; // Random factor between 0.8 and 1.2
var roofGraphics = self.attachAsset('roof', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: sizeFactor,
scaleY: sizeFactor
});
self.speed = -5;
self.update = function () {
self.x += self.speed;
if (self.x < -roofGraphics.width / 2) {
self.x = 2048 + roofGraphics.width / 2;
}
};
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Santa's Sleigh class
var SantaSleigh = Container.expand(function () {
var self = Container.call(this);
var sleighGraphics = self.attachAsset('santaSleigh', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocity = 0;
self.gravity = 0.5;
self.lift = -10;
self.update = function () {
self.velocity += self.gravity;
self.y += self.velocity;
if (self.y > 2732 - sleighGraphics.height / 2) {
self.y = 2732 - sleighGraphics.height / 2;
self.velocity = 0;
}
if (self.y < sleighGraphics.height / 2) {
self.y = sleighGraphics.height / 2;
self.velocity = 0;
}
};
self.flap = function () {
self.velocity = self.lift;
};
self.dropGift = function () {
var gift = new Gift();
gift.x = self.x;
gift.y = self.y;
game.addChild(gift);
};
self.leaveRoof = function () {
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
};
});
// Create a new Text2 object to display the counter at the center top of the map
// Snowflake class
var Snowflake = Container.expand(function () {
var self = Container.call(this);
var snowflakeGraphics = self.attachAsset('snowflake', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = Math.random() * 2 + 1; // Random speed between 1 and 3
self.update = function () {
self.y += self.speed;
if (self.y > 2732 + snowflakeGraphics.height / 2) {
self.y = -snowflakeGraphics.height / 2;
self.x = Math.random() * 2048; // Random x-coordinate
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Black background
});
/****
* Game Code
****/
// Add a gift asset above the counter
var giftIcon = LK.getAsset('gift', {
anchorX: 0.5,
anchorY: 0.5
});
// Create a new Text2 object to display the counter at the center bottom of the map
var scoreTxt = new Text2('0', {
size: giftIcon.width,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 1);
LK.gui.bottom.addChild(scoreTxt);
giftIcon.x = scoreTxt.x;
giftIcon.y = scoreTxt.y - scoreTxt.height - giftIcon.height / 2 - 10; // 10 is the space between the gift icon and the score text
LK.gui.bottom.addChild(giftIcon);
var wallpaper = game.attachAsset('wallpaper', {
anchorX: 0.0,
anchorY: 0.0
});
// Initialize game elements
var santaSleigh = game.addChild(new SantaSleigh());
santaSleigh.x = 400;
santaSleigh.y = 1366; // Center vertically
// Initialize a counter variable
var counter = 0;
var roofs = [];
var airplanes = [];
// Delay loading roofs for 2 seconds
LK.setTimeout(function () {
// Create two roofs with half the original distance
var roof1 = new Roof();
roof1.x = 2048;
roof1.y = 2732 - 100; // Bottom of the screen
roofs.push(roof1);
game.addChild(roof1);
var roof2 = new Roof();
roof2.x = 2048 / 2;
roof2.y = 2732 - 100; // Bottom of the screen
roofs.push(roof2);
game.addChild(roof2);
}, 2000);
// Initialize snowflakes
var snowflakes = [];
for (var i = 0; i < 100; i++) {
// Create 100 snowflakes
var snowflake = new Snowflake();
snowflake.x = Math.random() * 2048; // Random x-coordinate
snowflake.y = Math.random() * 2732; // Random y-coordinate
snowflakes.push(snowflake);
game.addChild(snowflake);
}
// Create airplane
var airplane = new Airplane();
airplane.x = 2048;
airplane.y = Math.random() * (1366 - 200) + 200; // Randomize y-coordinate in the upper half of the screen
airplanes.push(airplane);
game.addChild(airplane);
// Handle game events
game.down = function (x, y, obj) {
santaSleigh.flap();
};
// Update game state
var gifts = [];
game.update = function () {
santaSleigh.update();
for (var i = 0; i < roofs.length; i++) {
roofs[i].update();
if (santaSleigh.intersects(roofs[i])) {
santaSleigh.dropGift();
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
} else {
if (LK.ticks % 8 == 0) {
santaSleigh.leaveRoof();
}
}
}
for (var j = 0; j < airplanes.length; j++) {
airplanes[j].update();
if (santaSleigh.intersects(airplanes[j])) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
}
// Play Sleighbell sound every 5 seconds
if (LK.ticks % 300 == 0) {
LK.getSound('Sleighbell').play();
}
// Play Hohoho sound every 7 seconds
if (LK.ticks % 420 == 0) {
LK.getSound('Hohoho').play();
}
// Display the counter variable in the score text
scoreTxt.setText(counter);
for (var k = 0; k < snowflakes.length; k++) {
snowflakes[k].update();
}
for (var l = 0; l < gifts.length; l++) {
gifts[l].update();
if (gifts[l].y > 2732) {
gifts[l].destroy();
gifts.splice(l, 1);
}
}
// Increment the counter variable every eighth tick
if (LK.ticks % 8 == 0) {
counter++;
}
};
Santa's sleigh with reindeers. profile view
Air coaching airplane at night, from profile view
snowflake
Photorealistic office house at New york night from front view.
Photorealistic and ultrawide panoramic landscape from New york at night.
gift package with christmas decor
Santa's face. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.