Code edit (3 edits merged)
Please save this source code
User prompt
Add a new variable secondsBeforeChrismas and display its value at the bottom right of the screen
Code edit (5 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: LK.gui.bottomCenter is undefined' in this line: 'LK.gui.bottomCenter.addChild(secondsBeforeChristmasTxt);' Line Number: 88
Code edit (5 edits merged)
Please save this source code
User prompt
add a label above the score : "Gifts needed"
Code edit (7 edits merged)
Please save this source code
User prompt
create a variable humans = 8000000; update the score display to write the value : humans-score
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
add a new variable giftsNeeded = 8000000; display its value in the bottom right corner
User prompt
write a label "Gifts needed" above the gifsNeeded value
User prompt
Fix Bug: 'TypeError: giftsNeededTxt is undefined' in this line: 'giftsNeededLabel.y = LK.gui.bottomRight.height - giftsNeededTxt.height - giftsNeededLabel.height - 20;' Line Number: 90
Code edit (9 edits merged)
Please save this source code
User prompt
add a new label : "Xmas Countdown" above secondsBeforeChristmasTxt
Code edit (6 edits merged)
Please save this source code
User prompt
update the value of giftsNeeded to decrease when score increase
Code edit (1 edits merged)
Please save this source code
User prompt
change the color of giftsNeededTxt, giftsNeededLabel, xmasCountdownLabel and secondsBeforeChristmasTxt to a nice orange
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
change the color of xmasCountdownLabel and secondsBeforeChristmasTxt to a nice red
Code edit (3 edits merged)
Please save this source code
User prompt
Add a new function to format the secondsBeforeChristmasTxt text.The function take an argument 'nbSeconds'. if nbSeconds > 86400 return the rounded value in days else return the value formated in Hours:minutes:seconds (HH:MM:SS)
Code edit (4 edits merged)
Please save this source code
var score = 0;
var elves = 0;
var availableGiftsCounter = 0;
var WorkingElf = Container.expand(function () {
var self = Container.call(this);
var elfGraphics = self.createAsset('workingElf1', 'Working Elf Graphics', .5, .5);
self.speed = 3;
self.move = function () {
if (self.startFromLeft) {
self.x += self.speed;
} else {
self.x -= self.speed;
self.scale.x = -1;
}
};
});
var ElfGift = Container.expand(function () {
var self = Container.call(this);
var elfGiftGraphics = self.createAsset('elfGift', 'Elf Gift Graphics', .5, .5);
self.speed = 5;
self.move = function () {
self.y += self.speed;
};
});
var Gift = Container.expand(function () {
var self = Container.call(this);
var giftGraphics = self.createAsset('gift', 'Gift Graphics', .5, .5);
self.speed = 5;
self.move = function () {
self.y += self.speed;
};
});
var HireElfButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.createAsset('hireElf', 'Hire Elf Button', 0.5, 0.5);
buttonGraphics.scale.set(2);
buttonGraphics.tint = 0xffff00;
self.on('down', function () {
var elfCost = Math.pow(2, elves) * 5;
if (score >= elfCost) {
score -= elfCost;
elves += 1;
}
});
});
var Game = Container.expand(function () {
var self = Container.call(this);
var background = self.createAsset('background', 'Background Image', 0, 0);
background.scale.set(2, 3);
self.addChildAt(background, 0);
var giftWrapper = self.createAsset('giftWrapper', 'Big central button', 0.5, 0.5);
giftWrapper.scale.set(5);
giftWrapper.x = 2048 / 2;
giftWrapper.y = 2732 / 2;
giftWrapper.on('down', function () {
clickCount++;
score++;
availableGiftsCounter++;
giftWrapper.scale.set(4.5);
LK.setTimeout(function () {
giftWrapper.scale.set(5);
}, 300);
});
var gifts = [];
var workingElves = [];
var giftsPerSecond = 0;
var clickCount = 0;
var startTime = Date.now();
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
var elvesTxt = new Text2('0', {
size: 100,
fill: "#ffffff"
});
var giftsPerSecondTxt = new Text2('0', {
size: 50,
fill: "#ffffff"
});
var hireElfButton = self.addChild(new HireElfButton());
var elfCostTxt = new Text2('5G', {
size: 50,
fill: "#ffffff"
});
elfCostTxt.anchor.set(0.5, 0);
hireElfButton.x = 2048 - hireElfButton.width / 2 - 40;
hireElfButton.y = hireElfButton.height / 2 + 40;
elfCostTxt.x = 1340;
elfCostTxt.y = 175;
LK.gui.addChild(elfCostTxt);
scoreTxt.anchor.set(.5, 0);
LK.gui.topCenter.addChild(scoreTxt);
LK.gui.topCenter.addChild(elvesTxt);
elvesTxt.x = scoreTxt.x + 460;
elvesTxt.y = scoreTxt.y + 40;
LK.gui.topLeft.addChild(giftsPerSecondTxt);
giftsPerSecondTxt.anchor.set(0, -1);
var giftSpawnTimer = LK.setInterval(function () {
if (elves > 0) {
score += elves;
var newElfGift = new ElfGift();
newElfGift.x = Math.random() * 2048;
newElfGift.y = 0;
gifts.push(newElfGift);
self.addChild(newElfGift);
if (workingElves.length < elves) {
var workingElf = new WorkingElf();
workingElf.startFromLeft = false;
workingElf.x = workingElf.startFromLeft ? -workingElf.width : 2048 + workingElf.width;
workingElf.y = Math.random() * (2732 - workingElf.height);
workingElves.push(workingElf);
self.addChild(workingElf);
}
}
if (availableGiftsCounter > 0) {
availableGiftsCounter--;
giftWrapper.destroy();
hireElfButton.destroy();
var newGift = new Gift();
newGift.x = Math.random() * 2048;
newGift.y = 0;
gifts.push(newGift);
self.addChild(newGift);
self.addChild(giftWrapper);
self.addChild(hireElfButton);
}
}, 1000);
LK.on('tick', function () {
var currentTime = Date.now();
var elapsedTime = (currentTime - startTime) / 1000;
giftsPerSecond = (clickCount + elves * elapsedTime) / elapsedTime;
for (var a = gifts.length - 1; a >= 0; a--) {
gifts[a].move();
if (gifts[a].y > 2732 + gifts[a].height) {
gifts[a].destroy();
gifts.splice(a, 1);
}
}
for (var e = workingElves.length - 1; e >= 0; e--) {
workingElves[e].move();
if (workingElves[e].startFromLeft && workingElves[e].x > 2048 + workingElves[e].width || !workingElves[e].startFromLeft && workingElves[e].x < -200) {
workingElves[e].destroy();
workingElves.splice(e, 1);
}
}
scoreTxt.setText(score + 'G');
elvesTxt.setText(elves);
var elfCost = Math.pow(2, elves) * 5;
elfCostTxt.setText(elfCost + 'G');
hireElfButton.alpha = score < elfCost ? 0.5 : 1;
hireElfButton.interactive = score >= elfCost;
giftsPerSecondTxt.setText('Gifts/sec: ' + Math.round(giftsPerSecond));
});
stage.on('down', function (obj) {
var event = obj.event;
var pos = event.getLocalPosition(self);
for (var a = gifts.length - 1; a >= 0; a--) {
if (gifts[a].intersects({
x: pos.x,
y: pos.y,
width: 1,
height: 1
})) {
clickCount++;
gifts[a].destroy();
gifts.splice(a, 1);
score++;
}
}
});
});
A big red christmas gift, isometric view Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Top view of a round gift box with a ribbon Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cute elf Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A big green christmas gift, isometric view Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Profil view of a cute little elf with a green hat, standing with his hands in front of him.no background . no floor. In-Game asset. 2d. Blank background. High contrast. No shadows.
A feerical landscape with santa's house, pines, snow, glowing lights, at night. In the front, cute elves with gree hats, gingerbread boys, teddy bears, celebrating, but no Santa Clauss in the image. Background image. High contrast. No shadows.
Provile view of Santa clauss in his sleigh with reindeer, smiling and making a sign with his hand game Asset. High contrast. No shadows.
A sad landscape with santa's house, pines, snow, mountains in the back, at night. A cute sad santa crying with big tears in the front. clean feeric style. Background image. 2d. Blank background. Color. High contrast. No shadows.
a cute gingerbread boy Single Game Texture. 2d. Transparent background. High contrast. No shadows.
A big gingerbread christmas gift, isometric view Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A right profile drawing of one single cute little gingerbread boy, standing with his hands in front of him. In-Game asset. 2d. No background. High contrast. No shadows. Color. digital art
a cute smiling teddy bear standing Single Game Texture. 2d. Transparent background. High contrast. No shadows. No border.
A cute brown teddy bear from his right profile, standing, looking to the right direction and smiling with his hands in front of him. Feeric style. No background. No shadows. No back light. High contrast. Single Game Texture. In-Game asset. 2d.
a little green soldier toy standing Single Game Texture. 2d. Transparent background. High contrast. No shadows.
Profil view of a little green soldier toy, walking. no background . no floor. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cute little santa's reindeer with a red nose sitting Single Game Texture. 2d. Transparent background. High contrast. No shadows.
A big white and red dotted christmas gift, isometric view Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Profil view of a cute little santa's reindeer with a red nose, walking in the right direction. no background . no floor. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cute little grinch standing with a santa's hat Single Game Texture. 2d. Transparent background. High contrast. No shadows.
A big purple and green dotted christmas gift, isometric view Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Profile view of a mischievous little green grinch with a red scarf, big ears but no tail. Walking in the right direction. no background . no floor. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cute little fairy standing with a santa hat and a magic wand Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A big light blue decorated christmas gift, isometric view Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Profile view of a cute little fairy with a santa hat and a magic wand. Flying in the right direction. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a landscape with santa's house on the left, pines with chistmas lights, snow, at night Background image. 2d. High contrast.
a big light brown and yellow christmas gift decorated with holly leaf. isometric view. no floor. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a big green and white christmas gift ornated. isometric view. nothing under. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.