Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Use 5 different bell chime sounds
User prompt
Play a bell chime when you touch a bell
User prompt
Migrate to the latest version of LK
User prompt
Also submit scores to LK.setScore when scores are updated
User prompt
Update code to use LK scote
User prompt
add 8 bells when the game starts
User prompt
set speed y to -15 when hitting a bell
User prompt
Half the y modifier when spawning a new bell
Code edit (1 edits merged)
Please save this source code
User prompt
Add 500px to targetParallaxValue
Code edit (2 edits merged)
Please save this source code
User prompt
slowly increase bellSpeed each time you collect a bell
User prompt
in ScoreText set font weight to 400.
User prompt
Start score text scale at zero in ScoreText, then quickly scale to a max of one
User prompt
Update score text move method, such that a score first animates in from scale zero, then stays on screen for a bit and then scales down again together with alpha
User prompt
do not move y in score text move method
User prompt
when creating a particle, just pass p
Code edit (1 edits merged)
Please save this source code
User prompt
Subtract 4 from score y speed rather than 2
User prompt
On score text in ScoreText label add a 10px black outline
User prompt
Set score text text2 node, in ScoreText class, to size to 120. Sweet weight:200 and remove the drop shadow
User prompt
Set score text text2 node size to 120. Sweet weight:200 and remove the drop shadow
User prompt
add score texts to the particle array
var ScoreText = Container.expand(function (score, x, y) {
var self = Container.call(this);
self.x = x;
self.y = y;
var scoreText = new Text2(score.toString(), {
size: 50,
fill: '#ffffff',
weight: 800,
dropShadow: true,
dropShadowColor: '#000000',
dropShadowAngle: Math.PI / 6,
dropShadowDistance: 6
});
scoreText.anchor.set(.5, .5);
self.addChild(scoreText);
self.move = function () {
self.y -= 2;
self.alpha -= 0.02;
if (self.alpha <= 0) self.destroy();
};
});
var Particle = Container.expand(function (x, y, index) {
var self = Container.call(this, x, y);
self.index = index;
var particleGraphics = self.createAsset('particle', 'Particle Graphic', 0.5, 0.5);
self.x = x;
self.y = y;
var angle = index % 20 * (Math.PI * 2 / 20);
self.fixedSpeed = 30;
self.angle = angle;
self.move = function () {
self.fixedSpeed *= 0.95;
self.x += Math.cos(self.angle) * self.fixedSpeed;
self.y += Math.sin(self.angle) * self.fixedSpeed;
self.cachedAlpha = (self.cachedAlpha || 3) - 0.04;
self.alpha = Math.max(0, self.cachedAlpha);
if (self.cachedAlpha <= 0) self.destroy();
};
});
var ParallaxLayer = Container.expand(function (speed) {
var self = Container.call(this);
self.actualY = 0;
self.speed = typeof speed !== 'undefined' ? speed : 1;
self.setParallaxY = function (y) {
self.actualY = y * self.speed;
self.y = self.actualY;
};
});
var Bell = Container.expand(function (score) {
var self = Container.call(this);
self.score = score;
var bellBackground = self.createAsset('bellBackground', 'Bell Background', .5, .5);
self.addChild(bellBackground);
var bellGraphics = self.createAsset('bell', 'Christmas Bell', .5, .5);
bellGraphics.blendMode = 1;
self.addChild(bellGraphics);
self.move = function () {
self.y += self.parent.parent.bellSpeed;
};
});
var Player = Container.expand(function () {
var self = Container.call(this);
self.targetX = self.x;
var playerGraphics = self.createAsset('player', 'Player Character', .5, .5);
self.hasJumped = false;
self.jump = function () {
if (!self.hasJumped) {
self.speedy = -30;
self.hasJumped = true;
}
};
self.fall = function () {};
self.update = function () {
var distance = Math.abs(self.x - self.targetX);
var speed = Math.max(1, distance / 25);
if (self.x < self.targetX) {
self.x += Math.min(speed, self.targetX - self.x);
playerGraphics.scale.x = -1;
} else if (self.x > self.targetX) {
self.x -= Math.min(speed, self.x - self.targetX);
playerGraphics.scale.x = 1;
}
self.y += self.speedy;
self.speedy += 0.28;
};
});
var Snowflake = Container.expand(function () {
var self = Container.call(this);
var flakeGraphics = self.createAsset('snowflake', 'Snowflake Graphic', 0.5, 0.5);
self.speedy = Math.random() * 2 + 1;
self.speedx = Math.random() * 1 - 0.5;
self.rotationSpeed = Math.random() * 0.05 - 0.025;
self.move = function () {
self.y += self.speedy;
self.scale.set(self.speedy / 3, self.speedy / 3);
self.x += self.speedx;
self.rotation += self.rotationSpeed;
if (self.y > 2732 - self.parent.actualY) {
self.y = -50 - self.parent.actualY;
}
if (self.x > 2048) {
self.x = -50;
} else if (self.x < -50) {
self.x = 2048;
}
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
self.bellSpeed = 5;
self.bellSpeedIncreaseFactor = 0.001;
self.totalTicks = 0;
self.layers = [];
var background = self.createAsset('backgroundGraphics', 'Background Graphics', 0.5, 0.5);
background.x = 2048 / 2;
background.y = 2732 / 2;
background.alpha = 0.5;
self.addChildAt(background, 0);
var mountains = self.addChild(new ParallaxLayer(.3 / 4 / 4 / 4));
var mountainGraphics = mountains.createAsset('mountainGraphics', 'Background Element', .5, 1);
mountainGraphics.x = 2048 / 2;
mountainGraphics.y = 2732;
mountains.addChild(mountainGraphics);
self.layers.push(mountains);
var valley = self.addChild(new ParallaxLayer(.3 / 4 / 4));
var valleyGraphics = valley.createAsset('valleyGraphics', 'Background Element', .5, 1);
valleyGraphics.x = 2048 / 2;
valleyGraphics.y = 2732;
valley.addChild(valleyGraphics);
self.layers.push(valley);
var forest = new ParallaxLayer(.3 / 2);
var forestGraphics = forest.createAsset('forestGraphics', 'Background Element', .5, 1);
forestGraphics.x = 2048 / 2;
forestGraphics.y = 2732 - 150 + 50;
forest.addChild(forestGraphics);
self.layers.push(forest);
var foreground = new ParallaxLayer();
self.layers.push(foreground);
self.particles = [];
for (var i = 0; i < 100; i++) {
var snowflake = new Snowflake();
snowflake.x = Math.random() * 2048;
snowflake.y = Math.random() * 2732;
forest.addChild(snowflake);
self.particles.push(snowflake);
}
var groundLayer = new ParallaxLayer(.3);
var groundGraphics = groundLayer.createAsset('groundGraphics', 'Ground Element', .5, 1);
groundGraphics.x = 2048 / 2;
groundGraphics.y = 2732 + 195;
groundLayer.addChild(groundGraphics);
self.layers.push(groundLayer);
self.addChild(forest);
self.addChild(foreground);
self.addChild(groundLayer);
var player = foreground.addChild(new Player());
player.x = 2048 / 2;
player.targetX = player.x;
player.y = 2732 - player.height - 80;
self.score = 0;
scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff",
weight: 800,
dropShadow: true,
dropShadowColor: '#000000',
dropShadowAngle: Math.PI / 6,
dropShadowDistance: 6
});
scoreTxt.anchor.set(.5, 0);
LK.gui.topCenter.addChild(scoreTxt);
var bells = [];
self.addBell = function () {
var lastBellY = bells.length > 0 ? bells[bells.length - 1].y : 2732;
var nextScore = bells.length > 0 ? bells[bells.length - 1].score + 1 : 1;
var bell = foreground.addChild(new Bell(nextScore));
bell.x = Math.random() * (2048 - bell.width);
bell.y = lastBellY - (Math.random() * (2732 / 2 - 2732 / 3) + 2732 / 3);
bells.push(bell);
};
for (var i = 0; i < 5; i++) {
self.addBell();
}
var player;
var scoreTxt;
var isGameOver = false;
LK.on('tick', function () {
player.update();
var targetParallaxValue = 1366 - player.y;
var currentParallaxValue = foreground.actualY;
var parallaxDifference = targetParallaxValue - currentParallaxValue;
var parallaxSpeed = Math.max(1, Math.abs(parallaxDifference) / 10);
background.alpha = Math.min(1, (-2790 - player.y) / 500000 + 0.5);
if (currentParallaxValue < targetParallaxValue) {
self.layers.forEach(function (layer) {
layer.setParallaxY(currentParallaxValue + Math.min(parallaxSpeed, targetParallaxValue - currentParallaxValue));
});
}
for (var i = 0; i < bells.length; i++) {
bells[i].move();
if (player.intersects(bells[i])) {
player.speedy = -25;
player.hasJumped = true;
self.score += bells[i].score;
scoreTxt.setText(self.score);
for (var p = 0; p < 20; p++) {
var layerDeltaY = forest.actualY - foreground.actualY;
var particle = new Particle(bells[i].x, bells[i].y - layerDeltaY, self.particles.length);
self.particles.push(particle);
forest.addChild(particle);
var scoreText = new ScoreText(bells[i].score, bells[i].x, bells[i].y - layerDeltaY);
self.particles.push(scoreText);
forest.addChild(scoreText);
}
bells[i].destroy();
bells.splice(i, 1);
self.addBell();
} else if (bells[i].y + foreground.actualY > 2832) {
bells[i].destroy();
bells.splice(i, 1);
self.addBell();
}
}
if (player.y + foreground.y > 2732) {
isGameOver = true;
}
self.particles.forEach(function (particle) {
particle.move();
if (particle.alpha <= 0) {
var index = self.particles.indexOf(particle);
if (index > -1) {
self.particles.splice(index, 1);
}
}
});
self.totalTicks++;
self.bellSpeed += self.bellSpeedIncreaseFactor;
if (isGameOver) {
LK.effects.flashScreen(0xffffff, 1000);
LK.showGameOver();
}
});
stage.on('down', function (obj) {
var event = obj.event;
var pos = event.getLocalPosition(self);
player.targetX = pos.x;
player.jump();
});
stage.on('move', function (obj) {
var event = obj.event;
var pos = event.getLocalPosition(self);
player.targetX = pos.x;
});
});
Tree line of snowy pine trees. Cartoon. Black background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Mountain valley with snowy trees. Scenic view. Nighttime. Cartoon. Black background. New moon Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Background mountains, nighttime, snow topped Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d platform snowy ground. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Cute cartoon rabbit, jumping upwards facing camera. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Starry night sky, northern lights, looking up. Cartoon style. Above clouds Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Single White Christmas bell. White decorations. Cartoon. Outline Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
White Simple Cartoon snowflake Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.