User prompt
Fix Bug: 'Uncaught ReferenceError: Bell is not defined' in this line: 'var bell = isSpecialBell ? foreground.addChild(new SpecialBell(nextScore)) : foreground.addChild(new Bell(nextScore));' Line Number: 178
User prompt
When player touches special bell they will get more points and jump 3 times higher than normal
User prompt
Special bells will spwan randomly betweem bells
User prompt
Create a new class for a specialbell.
User prompt
Remove anowflake
User prompt
Snowflake should not rotate
Remix started
Copy Dreams of Winterbells
var Bell = Container.expand(function (score) { var self = Container.call(this); self.score = score; var bellGraphics = self.createAsset('bell', 'Bell Graphic', .5, .5); self.move = function () { self.y += self.parent.parent.bellSpeed; }; }); 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: 120, fill: '#ffffff', weight: 400, stroke: '#000000', strokeThickness: 10 }); scoreText.anchor.set(.5, .5); scoreText.scale.set(0, 0); self.addChild(scoreText); var scaleIncrease = 0.05; LK.on('tick', function () { if (scoreText.scale.x < 1) { scoreText.scale.x += scaleIncrease; scoreText.scale.y += scaleIncrease; } }); self.move = function () { 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 SpecialBell = Container.expand(function (score, specialEffect) { var self = Container.call(this); self.score = score; self.specialEffect = specialEffect; var bellBackground = self.createAsset('specialBellBackground', 'Special Bell Background', .5, .5); self.addChild(bellBackground); var bellGraphics = self.createAsset('specialBell', 'Special Christmas Bell', .5, .5); bellGraphics.blendMode = 1; self.addChild(bellGraphics); self.move = function () { self.y += self.parent.parent.bellSpeed; if (self.specialEffect) { self.specialEffect(self); } }; }); 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; 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 = []; 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 isSpecialBell = Math.random() < 0.1; var bell = isSpecialBell ? foreground.addChild(new SpecialBell(nextScore)) : foreground.addChild(new Bell(nextScore)); bell.x = Math.random() * (2048 - bell.width); bell.y = lastBellY - (Math.random() * (2732 / 4 - 2732 / 6) + 2732 / 6); bells.push(bell); }; for (var i = 0; i < 8; i++) { self.addBell(); } var player; var scoreTxt; var isGameOver = false; LK.on('tick', function () { player.update(); var targetParallaxValue = 1366 - player.y + 500; 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])) { var jumpMultiplier = bells[i] instanceof SpecialBell ? 3 : 1; player.speedy = -15 * jumpMultiplier; player.hasJumped = true; self.score += bells[i].score * jumpMultiplier; scoreTxt.setText(self.score); self.bellSpeed += self.bellSpeedIncreaseFactor * jumpMultiplier; for (var p = 0; p < 20; p++) { var layerDeltaY = forest.actualY - foreground.actualY; var particle = new Particle(bells[i].x, bells[i].y - layerDeltaY, p); 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; }); });
===================================================================
--- original.js
+++ change.js
@@ -1,4 +1,12 @@
+var Bell = Container.expand(function (score) {
+ var self = Container.call(this);
+ self.score = score;
+ var bellGraphics = self.createAsset('bell', 'Bell Graphic', .5, .5);
+ self.move = function () {
+ self.y += self.parent.parent.bellSpeed;
+ };
+});
var ScoreText = Container.expand(function (score, x, y) {
var self = Container.call(this);
self.x = x;
self.y = y;
Cute cartoon monkey jumping. Looking front. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Palmtrees line. Cartoon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Sunrise, dawn, looking up. Cartoon style. Above clouds Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Jungle Scenic view. Open in the top Cartoon. Black background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Simple rain drop. Blue. Cartoon. Black background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Cartoon banana. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
jungle background. Big green mount in the back. Cartoon. In game asset. No shadaw. High contrast. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.