User prompt
present topper should move at the same speed and direction as the chimney
User prompt
add a permanent asset right on top of the chimney once the present has been delivered
User prompt
change the color of the chimney once it has collided with a present. it should grey out
User prompt
increase game difficulty
User prompt
random mover should reduce it movement area to the midel 60% of the screen
User prompt
when santa collides with randommover present count should go back to 5 and randommover should be hidden
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'visible')' in this line: 'this.parent.parent.rudolph.visible = false;' Line Number: 76
User prompt
Fix Bug: 'ReferenceError: rudolph is not defined' in this line: 'rudolph.move();' Line Number: 256
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'visible')' in this line: 'this.parent.rudolph.visible = false;' Line Number: 76
User prompt
hide randommover until present count is equal to 0
User prompt
rename randomMover to rudolph
User prompt
delete rudolph from game
User prompt
random mover should bounce on the screen limits
User prompt
randommover should only move below the top 20% of the screen and above the bottom 20%
User prompt
incresase speed of random mover by 4 times
User prompt
add new asset that moves randomly all over the screen
User prompt
add movement to rudolph
Code edit (1 edits merged)
Please save this source code
User prompt
only add point and show present delivery effect if the present hits the top 10% of the chimney
User prompt
if present collides with the side of the chimney it should not add a point to the score and the present should blink and not show the present delivery effect
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'forEach')' in this line: 'this.parent.chimneys.forEach((function (chimney) {' Line Number: 82
User prompt
Fix Bug: 'ReferenceError: chimneys is not defined' in this line: 'chimneys.forEach((function (chimney) {' Line Number: 82
User prompt
if present collides with the side of the chimney it should not add a point to the score and the present should blink and not show the present delivery effect. only add a point and show the present delivery effect when it touches the top 10% of the chimney
User prompt
if present collides with the side of the chimney it should not add a point to the score and the present should blink and not show the present delivery effect
User prompt
rudolph should move
var PresentDeliveryEffect = Container.expand(function () {
var self = Container.call(this);
var effectGraphics = self.createAsset('presentDeliveryEffect', 'Present Delivery Effect', 0.5, 0.5);
self.animate = function () {
self.alpha = 1;
var fadeOut = function () {
if (self.alpha > 0) {
self.alpha -= 0.05;
LK.setTimeout(fadeOut, 50);
} else {
self.destroy();
}
};
fadeOut();
};
});
var LifeIcon = Container.expand(function () {
var self = Container.call(this);
var lifeIconGraphics = self.createAsset('lifeIcon', 'Life Icon', 0.5, 0.5);
});
var Star = Container.expand(function () {
var self = Container.call(this);
var starGraphics = self.createAsset('star', 'Star', 0.5, 0.5);
self.speed = 2 + Math.random() * 3;
self.move = function () {
self.x -= self.speed;
if (self.x < -self.width) {
self.destroy();
return true;
}
return false;
};
});
var Santa = Container.expand(function () {
var self = Container.call(this);
self.resetPresents = function () {
this.presentCounter = 5;
this.parent.presentCounterTxt.setText(this.presentCounter.toString());
};
var santaGraphics = self.createAsset('santa', 'Santa character', .5, .5);
self.move = function (pos) {
self.x += (pos.x - self.x) * 0.1;
self.y += (pos.y - self.y) * 0.1;
};
self.throwPresent = function () {
if (this.presentCounter > 0) {
var present = new Present();
present.x = this.x;
present.y = this.y;
this.parent.addChild(present);
this.parent.presents.push(present);
this.presentCounter--;
this.parent.presentCounterTxt.setText(this.presentCounter.toString());
}
if (this.presentCounter === 0) {
this.parent.hazardSpeed *= 1.2;
this.parent.hazardSpawnRate = Math.max(this.parent.hazardSpawnRate * 0.9, 30);
if (!this.parent.rudolph) {
this.parent.rudolph = this.parent.addChild(new Rudolph());
this.parent.rudolph.x = Math.random() * 2048;
this.parent.rudolph.y = Math.random() * (2732 * 0.55 - 2732 * 0.2) + 2732 * 0.2;
this.parent.rudolph.speedX = (Math.random() * 2 - 1) * this.parent.hazardSpeed;
this.parent.rudolph.speedY = (Math.random() * 2 - 1) * this.parent.hazardSpeed;
this.parent.rudolphSpawnCounter++;
}
}
};
});
var Present = Container.expand(function () {
var self = Container.call(this);
var presentGraphics = self.createAsset('present', 'Present', .5, .5);
self.move = function (hazards) {
this.y += 5;
hazards.forEach((function (hazard) {
if (this.intersects(hazard)) {
LK.effects.flashObject(this, 0xff0000, 300);
LK.setTimeout((function () {
this.destroy();
}).bind(this), 300);
}
}).bind(this));
};
});
var Chimney = Container.expand(function () {
var self = Container.call(this);
var chimneyGraphics = self.createAsset('chimney', 'Chimney', .5, .5);
self.originalTint = 0xFFFFFF;
self.presentDeliveredTint = 0x00FF00;
self.hasPresent = false;
self.speed = 2;
self.move = function () {
self.x -= self.speed;
if (self.x < -self.width) {
self.x = 2048;
}
};
self.checkCollision = function () {};
});
var Hazard = Container.expand(function () {
var self = Container.call(this);
var hazardGraphics = self.createAsset('hazard', 'Hazard', .5, .5);
self.move = function () {
self.x -= self.speed;
if (self.x < -self.width) {
self.destroy();
return true;
}
return false;
};
});
var Rudolph = Container.expand(function () {
var self = Container.call(this);
var rudolphGraphics = self.createAsset('rudolph', 'Rudolph', 0.5, 0.5);
self.angle = 0;
self.radius = 200;
self.speed = 0.05;
self.move = function () {
self.x += self.speedX;
self.y += self.speedY;
if (self.x < 0 || self.x > 2048 || self.y < 0 || self.y > 2732) {
self.speedX = -self.speedX;
self.speedY = -self.speedY;
}
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
self.stars = [];
var starSpawnRate = 15;
var starSpawnCounter = 0;
var santa = self.addChild(new Santa());
santa.x = 2048 / 2;
santa.y = 2732 / 2;
santa.lives = 3;
self.lifeIcons = [];
var lifeIconSpacing = 20;
var lifeIconSize = 64;
for (var i = 0; i < santa.lives; i++) {
var lifeIcon = new LifeIcon();
lifeIcon.x = lifeIconSpacing + 50 + i * (lifeIconSize + lifeIconSpacing);
lifeIcon.y = lifeIconSpacing + 50;
self.lifeIcons.push(lifeIcon);
LK.gui.topLeft.addChild(lifeIcon);
}
santa.presentCounter = 5;
self.presents = [];
var chimneys = [];
var hazards = [];
var hazardSpeed = 5;
var hazardSpawnRate = 120;
var hazardSpawnCounter = 0;
var rudolphSpawnCounter = 0;
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
var presentIcon = self.createAsset('presentIcon', 'Present Icon', 0.5, 0);
presentIcon.x = 60;
presentIcon.y = self.lifeIcons[self.lifeIcons.length - 1].y + lifeIconSize + lifeIconSpacing;
LK.gui.topLeft.addChild(presentIcon);
var presentCounterTxt = new Text2(santa.presentCounter.toString(), {
size: 80,
fill: "#ffffff"
});
presentCounterTxt.x = presentIcon.x + presentIcon.width + 10;
presentCounterTxt.y = presentIcon.y;
self.presentCounterTxt = presentCounterTxt;
LK.gui.topLeft.addChild(presentCounterTxt);
var maxChimneys = 5;
LK.on('tick', function () {
if (starSpawnCounter++ >= starSpawnRate) {
var newStar = new Star();
newStar.x = 2048;
newStar.y = Math.random() * (2732 * 0.8);
self.stars.push(newStar);
self.addChild(newStar);
starSpawnCounter = 0;
}
if (chimneys.length < maxChimneys) {
var lastChimney = chimneys[chimneys.length - 1];
var chimneySpacing = 500;
if (!lastChimney || lastChimney.x < 2048 - chimneySpacing) {
var newChimney = new Chimney();
newChimney.x = 2048;
newChimney.y = 2732 - newChimney.height - Math.random() * 500 + 750;
chimneys.push(newChimney);
self.addChild(newChimney);
}
}
chimneys.forEach(function (chimney) {
chimney.move();
self.presents.forEach(function (present, index) {
if (present.intersects(chimney) && !chimney.hasPresent) {
present.destroy();
self.presents.splice(index, 1);
chimney.hasPresent = true;
var deliveryEffect = new PresentDeliveryEffect();
deliveryEffect.x = chimney.x;
deliveryEffect.y = chimney.y - chimney.height / 2;
self.addChild(deliveryEffect);
deliveryEffect.animate();
var newScore = LK.getScore() + 1;
LK.setScore(newScore);
scoreTxt.setText(newScore.toString());
}
});
});
chimneys = chimneys.filter(function (chimney) {
return chimney.x + chimney.width > 0;
});
});
scoreTxt.anchor.set(.5, 0);
LK.gui.topCenter.addChild(scoreTxt);
LK.on('tick', function () {
for (var i = 0; i < self.presents.length; i++) {
self.presents[i].move(hazards);
}
for (var i = 0; i < chimneys.length; i++) {
chimneys[i].checkCollision();
}
if (hazardSpawnCounter++ >= hazardSpawnRate) {
var newHazard = new Hazard();
newHazard.x = 2048;
newHazard.y = Math.random() * (2732 * 0.6) + 2732 * 0.2;
newHazard.speed = hazardSpeed;
hazards.push(newHazard);
self.addChild(newHazard);
hazardSpawnCounter = 0;
}
hazards = hazards.filter(function (hazard) {
return !hazard.move();
});
var santaHit = false;
if (self.rudolph && santa.intersects(self.rudolph)) {
santa.resetPresents();
self.rudolph.destroy();
self.rudolph = null;
} else {
hazards.forEach(function (hazard, index) {
if (!santaHit && santa.intersects(hazard)) {
LK.effects.flashObject(santa, 0xff0000, 500);
hazard.destroy();
hazards.splice(index, 1);
santaHit = true;
santa.lives--;
if (self.lifeIcons.length > santa.lives) {
var removedLifeIcon = self.lifeIcons.pop();
removedLifeIcon.destroy();
}
if (santa.lives <= 0) {
LK.showGameOver();
}
}
});
}
hazards = hazards.filter(function (hazard) {
return !hazard.hitSanta;
});
self.stars = self.stars.filter(function (star) {
return !star.move();
});
});
stage.on('move', function (obj) {
var pos = obj.event.getLocalPosition(self);
if (pos.y < 2732 * 0.8 && pos.y > 2732 * 0.2) {
santa.move(pos);
}
});
stage.on('up', function (obj) {
santa.throwPresent();
});
});
8-bit cloud with lightning. in game asset. white cloude. yellow lighning. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
8 bit x mas pressent. in game asset. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
8-bit. cartoon. santa on sledge. smiling. in game asset. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.