User prompt
when the sleigh touches the beam disable the movement like in the function
User prompt
add a function where the santa cant move further when set to true
User prompt
when collision is detected add a console message
User prompt
make sure the `ufoBeam`'s `active` state is being set or checked correctly.
User prompt
Fix Bug: 'ReferenceError: ufoBeam is not defined' in this line: 'if (!ufoBeam || !ufoBeam.active || !self.intersects(ufoBeam)) {' Line Number: 99
User prompt
instead of going game over, when santa intesects. make it so the santa cant move through the beam.
User prompt
make a check for when santa and the ufobeam collide
User prompt
when the ufo beam is spawned, check if the position of the beam and the sleigh overlap. if so dont update the sleigh movement
User prompt
make a function for when the ufo beam spawns
User prompt
Update Santa's position: If there's no overlap, allow Santa to move to the new position as usual.
User prompt
Check Santa's position against the beam's area: During Santa's movement logic, before updating Santa's position, check if the new position would overlap with the area covered by the UFO beam.
User prompt
Fix Bug: 'ReferenceError: ufoBeam is not defined' in this line: 'if (!ufoBeam) {' Line Number: 272
User prompt
Fix Bug: 'ReferenceError: ufoBeam is not defined' in this line: 'if (ufoBeam && (ufo.x < 1024 - ufo.width / 2 || ufo.x > 1024 + ufo.width / 2)) {' Line Number: 281
User prompt
Fix Bug: 'ReferenceError: ufoBeam is not defined' in this line: 'if (ufoBeam && ufoBeam.isActive()) {' Line Number: 108
User prompt
Fix Bug: 'ReferenceError: ufoBeam is not defined' in this line: 'if (ufoBeam && ufoBeam.isActive()) {' Line Number: 108
User prompt
Fix Bug: 'ReferenceError: ufoBeam is not defined' in this line: 'if (ufoBeam && ufoBeam.isActive()) {' Line Number: 108
User prompt
Fix Bug: 'ReferenceError: ufoBeam is not defined' in this line: 'if (ufoBeam && ufoBeam.isActive()) {' Line Number: 108
User prompt
Fix Bug: 'ReferenceError: ufoBeam is not defined' in this line: 'if (ufoBeam && ufoBeam.isActive()) {' Line Number: 108
User prompt
Fix Bug: 'ReferenceError: ufoBeam is not defined' in this line: 'if (ufoBeam && ufoBeam.isActive()) {' Line Number: 108
User prompt
Fix Bug: 'ReferenceError: ufoBeam is not defined' in this line: 'if (ufoBeam && ufoBeam.isActive()) {' Line Number: 108
User prompt
Fix Bug: 'ReferenceError: ufoBeam is not defined' in this line: 'if (ufoBeam && ufoBeam.isActive()) {' Line Number: 108
User prompt
Determine the beam's position and size: Obtain the x, y coordinates, width, and height of the UFO beam to establish the area it occupies on the screen.
User prompt
Check if the UFO beam is active: You would need a flag or a property within the UFOBeam class that indicates whether the beam is currently active and visible on the screen.
User prompt
Fix Bug: 'ReferenceError: solidObjects is not defined' in this line: 'solidObjects.forEach(function (solidObject) {' Line Number: 116
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'push')' in this line: 'solidObjects.push(newSolidObject);' Line Number: 199
var SolidObject = Container.expand(function () {
var self = Container.call(this);
var solidObjectGraphics = self.createAsset('solidObject', 'Solid Object Graphics', .5, .5);
self.isSolid = true;
});
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerUpGraphics = self.createAsset('powerUp', 'PowerUp Graphics', .5, .5);
});
var Cloud = Container.expand(function () {
var self = Container.call(this);
var cloudGraphics = self.createAsset('cloud', 'Cloud Graphics', .5, .5);
self.move = function () {};
});
var ThanksAsset = Container.expand(function () {
var self = Container.call(this);
var thanksGraphics = self.createAsset('thanks', 'Thanks Graphics', .5, .5);
});
var Chimney2 = Container.expand(function () {
var self = Container.call(this);
var chimney2Graphics = self.createAsset('chimney2', 'Chimney2 Graphics', .5, .5);
self.touchedByGift = false;
});
var UFOBeam = Container.expand(function () {
var self = Container.call(this);
var ufoBeamGraphics = self.createAsset('ufoBeam', 'UFO Beam Graphics', .5, 1);
self.active = false;
self.activateBeam = function () {
self.active = true;
self.alpha = 0.8;
self.y += 2250;
};
self.deactivateBeam = function () {
self.active = false;
self.alpha = 0;
};
});
var Snow3 = Container.expand(function () {
var self = Container.call(this);
var snowGraphics = self.createAsset('snow3', 'Snow3 Graphics', .5, .5);
self.speed = Math.random() * 5;
self.move = function () {
self.y += self.speed;
self.rotation += 0.01;
if (self.y > 2732) {
self.y = 0;
self.speed += 0.01;
if (self.speed > 5) self.speed = 5;
}
};
});
var Snow2 = Container.expand(function () {
var self = Container.call(this);
var snowGraphics = self.createAsset('snow2', 'Snow2 Graphics', .5, .5);
self.speed = Math.random() * 5;
self.move = function () {
self.y += self.speed;
self.rotation += 0.01;
if (self.y > 2732) {
self.y = 0;
self.speed += 0.01;
if (self.speed > 5) self.speed = 5;
}
};
});
var Chimney3 = Container.expand(function () {
var self = Container.call(this);
var chimney3Graphics = self.createAsset('chimney3', 'Chimney3 Graphics', .5, .5);
self.touchedByGift = false;
});
var Grinch = Container.expand(function () {
var self = Container.call(this);
var grinchGraphics = self.createAsset('grinch', 'Grinch Graphics', .5, .5);
self.speed = 12;
self.direction = 1;
self.lifespan = 600;
self.move = function () {
if (self.x + self.width / 2 >= 2048 || self.x - self.width / 2 <= 0) {
self.direction *= -1;
}
var potentialX = self.x + self.speed * self.direction;
var canMove = true;
solidObjects.forEach(function (solidObject) {
if (self.intersects(solidObject)) {
canMove = false;
self.direction *= -1;
}
});
if (canMove) {
self.x = potentialX;
}
if (--self.lifespan <= 0) {
if (self.x < 2048 / 2) {
self.x -= self.speed;
} else {
self.x += self.speed;
}
if (self.x + self.width / 2 < 0 || self.x - self.width / 2 > 2048) {
self.destroy();
}
}
};
});
var SantaSleigh = Container.expand(function () {
var self = Container.call(this);
self.updatePosition = function (mouseX) {
self.targetX = mouseX;
};
self.move = function () {
var delayFactor = 0.1;
var maxSpeed = 10;
var moveAmount = (self.targetX - self.x) * delayFactor;
moveAmount = Math.max(Math.min(moveAmount, maxSpeed), -maxSpeed);
var potentialX = self.x + moveAmount;
var canMove = true;
solidObjects.forEach(function (solidObject) {
if (self.intersects(solidObject)) {
canMove = false;
}
});
if (canMove) {
self.x = potentialX;
}
};
var santaSleighGraphics = self.createAsset('santaSleigh', 'Santa in sleigh', .5, .5);
self.targetX = self.x;
});
var UFO = Container.expand(function () {
var self = Container.call(this);
var ufoGraphics = self.createAsset('ufo', 'UFO Graphics', .5, .5);
self.speed = 3;
self.move = function () {
self.x += self.speed;
if (self.x > 2048 || self.x < 0) self.speed *= -1;
};
});
var Gift = Container.expand(function () {
var self = Container.call(this);
var giftGraphics = self.createAsset('gift', 'Gift Graphics', .5, .5);
self.speed = 0;
self.gravity = 0.2;
self.move = function () {
self.speed += self.gravity;
self.y += self.speed;
if (!self.initialFlingDone) {
self.x += 150 / 60;
self.rotation += 0.1;
self.flingTicks = (self.flingTicks || 0) + 1;
if (self.flingTicks >= 400) {
self.initialFlingDone = true;
}
}
};
});
var Chimney = Container.expand(function () {
var self = Container.call(this);
var chimneyGraphics = self.createAsset('chimney', 'Chimney Graphics', .5, .5);
self.touchedByGift = false;
self.thanksAsset = null;
});
var Game = Container.expand(function () {
var self = Container.call(this);
var chimneyType = 0;
function spawnChimney() {
var chimneyClasses = [Chimney, Chimney2, Chimney, Chimney3, Chimney2, Chimney, Chimney2, Chimney3];
var newChimney = new chimneyClasses[chimneyType % chimneyClasses.length]();
newChimney.x = 2048;
newChimney.y = 2500 + Math.floor(Math.random() * 301) - 100;
chimneys.push(newChimney);
self.addChild(newChimney);
chimneyType++;
}
stage.on('move', function (obj) {
var event = obj.event;
var pos = event.getLocalPosition(self);
santaSleigh.updatePosition(pos.x);
});
stage.on('down', function (obj) {
if (throwPowerUpActive && LK.ticks - lastThrowTick >= 30 || !throwPowerUpActive && LK.ticks - lastThrowTick >= 120) {
if (throwPowerUpActive && LK.ticks - powerUpTimer >= 300) {
throwPowerUpActive = false;
lastThrowTick = LK.ticks;
}
var event = obj.event;
var pos = event.getLocalPosition(self);
var newGift = self.addChild(new Gift());
newGift.x = santaSleigh.x;
newGift.y = santaSleigh.y;
gifts.push(newGift);
lastThrowTick = LK.ticks;
}
});
LK.stageContainer.setBackgroundColor(0x000000);
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
var solidObjects = [];
var newSolidObject = self.addChild(new SolidObject());
solidObjects.push(newSolidObject);
var santaSleigh = self.addChild(new SantaSleigh());
santaSleigh.x = 2048 / 2;
santaSleigh.y = 2732 / 4;
var snow = [];
for (var i = 0; i < 10; i++) {
var newSnow3 = self.addChild(new Snow3());
newSnow3.x = Math.random() * 2048;
newSnow3.y = Math.random() * 2732;
snow.push(newSnow3);
self.setChildIndex(newSnow3, self.children.length - 1);
var newSnow2 = self.addChild(new Snow2());
newSnow2.x = Math.random() * 2048;
newSnow2.y = Math.random() * 2732;
snow.push(newSnow2);
self.setChildIndex(newSnow2, self.children.length - 1);
var newSnow3 = self.addChild(new Snow3());
newSnow3.x = Math.random() * 2048;
newSnow3.y = Math.random() * 2732;
snow.push(newSnow3);
self.setChildIndex(newSnow3, self.children.length - 1);
}
var cloud = self.addChild(new Cloud());
cloud.x = 2048 / 2;
cloud.y = 2732 / 2;
self.setChildIndex(cloud, 0);
self.setChildIndex(santaSleigh, 1);
scoreTxt.anchor.set(.5, 0);
LK.gui.topCenter.addChild(scoreTxt);
var gifts = [];
var chimneys = [];
var score = 0;
var solidObjects = [];
var isGameOver = false;
var tickOffset = 0;
var giftThrowSpeed = -5;
var chimneySpeed = 2;
spawnChimney();
LK.on('tick', function () {
santaSleigh.move();
cloud.move();
for (var i = 0; i < snow.length; i++) {
snow[i].move();
}
for (var i = chimneys.length - 1; i >= 0; i--) {
var chimney = chimneys[i];
if (chimney.x < 0) {
if (chimney.thanksAsset) {
chimney.thanksAsset.destroy();
}
chimney.destroy();
chimneys.splice(i, 1);
}
}
if (isGameOver) {
LK.clearInterval(chimneySpawnInterval);
}
if (LK.ticks - lastGrinchSpawnTick >= 1800) {
var newGrinch = self.addChild(new Grinch());
newGrinch.x = 2048 / 2;
newGrinch.y = 2732 / 2;
grinches.push(newGrinch);
lastGrinchSpawnTick = LK.ticks;
}
if (LK.ticks - lastUFOSpawnTick >= 1200 && !ufo) {
ufo = self.addChild(new UFO());
ufo.x = 2048;
ufo.y = 250;
ufoMoveTick = LK.ticks;
lastUFOSpawnTick = LK.ticks;
}
if (ufo && LK.ticks - ufoMoveTick <= 260) {
if (ufo.x > 2048 / 2) {
ufo.x -= 5;
} else if (ufo.x < 2048 / 2) {
ufo.x += 5;
}
}
if (ufo && LK.ticks - ufoMoveTick > 260 && LK.ticks - ufoMoveTick <= 860) {
if (ufo.x >= 1024 - ufo.width / 2 && ufo.x <= 1024 + ufo.width / 2) {
if (!ufoBeam) {
ufoBeam = self.addChild(new UFOBeam());
ufoBeam.x = ufo.x;
ufoBeam.y = ufo.y + ufo.height;
ufoBeam.activateBeam();
console.log('UFO beam spawned and activated under the UFO');
}
}
}
if (ufoBeam && (ufo.x < 1024 - ufo.width / 2 || ufo.x > 1024 + ufo.width / 2)) {
ufoBeam.deactivateBeam();
ufoBeam.destroy();
ufoBeam = null;
console.log('UFO beam deactivated and destroyed due to UFO position');
}
if (ufo && LK.ticks - ufoMoveTick > 860) {
ufo.x += 5;
if (ufo.x > 2048) {
ufo.destroy();
ufo = null;
}
}
if (LK.ticks - lastPowerUpSpawnTick >= 2400) {
var newPowerUp = self.addChild(new PowerUp());
newPowerUp.x = Math.random() * 2048;
newPowerUp.y = 1800;
powerUps.push(newPowerUp);
lastPowerUpSpawnTick = LK.ticks;
self.setChildIndex(newPowerUp, self.children.length - 1);
}
for (var i = 0; i < grinches.length; i++) {
var grinch = grinches[i];
grinch.move();
for (var j = gifts.length - 1; j >= 0; j--) {
var gift = gifts[j];
if (gift.intersects(grinch)) {
gift.destroy();
gifts.splice(j, 1);
}
}
}
});
var lastThrowTick = -120;
var lastGrinchSpawnTick = 0;
var lastPowerUpSpawnTick = 0;
var lastUFOSpawnTick = 0;
var ufoMoveTick = 0;
var ufoWaitTick = 0;
var ufo = null;
var ufoBeam = null;
var grinches = [];
var powerUps = [];
var throwPowerUpActive = false;
var powerUpTimer = 0;
LK.on('tick', function () {
for (var i = gifts.length - 1; i >= 0; i--) {
var gift = gifts[i];
gift.move();
if (gift.y < 0) {
gift.destroy();
gifts.splice(i, 1);
}
}
for (var i = chimneys.length - 1; i >= 0; i--) {
var chimney = chimneys[i];
chimney.x -= chimneySpeed;
if (chimney.thanksAsset) {
chimney.thanksAsset.x = chimney.x;
if (chimney.thanksAsset.x < 0) {
chimney.thanksAsset.destroy();
chimney.thanksAsset = null;
}
}
if (chimney.x < 0) {
if (!chimney.touchedByGift) {
score -= 2;
scoreTxt.setText(score);
if (score < 0) {
isGameOver = true;
if (score < 0) {
scoreTxt.setText('You disappointed too many kids');
scoreTxt.scale.set(0.6);
}
}
LK.effects.flashScreen(0xff0000, 1000);
spawnChimney();
}
chimneys.splice(i, 1);
chimney.destroy();
}
}
for (var i = gifts.length - 1; i >= 0; i--) {
var gift = gifts[i];
for (var j = chimneys.length - 1; j >= 0; j--) {
var chimney = chimneys[j];
if (gift.intersects(chimney) && !chimney.touchedByGift) {
score++;
scoreTxt.setText(score);
chimney.touchedByGift = true;
chimney.thanksAsset = self.addChild(new ThanksAsset());
chimney.thanksAsset.x = chimney.x;
chimney.thanksAsset.y = chimney.y - chimney.height / 2 - chimney.thanksAsset.height / 2;
LK.effects.flashScreen(0x00ff00, 500);
gift.destroy();
gifts.splice(i, 1);
chimneySpeed += 0.2;
spawnChimney();
break;
}
}
for (var k = powerUps.length - 1; k >= 0; k--) {
var powerUp = powerUps[k];
if (gift.intersects(powerUp)) {
LK.effects.flashScreen(0x0000ff, 500);
powerUp.destroy();
powerUps.splice(k, 1);
lastThrowTick = LK.ticks - 60;
throwPowerUpActive = true;
powerUpTimer = LK.ticks;
break;
}
}
}
if (isGameOver) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
});
});
chimney. pixelart. residential chimney. only chimney. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
gift. pixelart. christmas. green and red. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
night sky. pixelart. seamless. clouds. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixelart. christmas. santa in sleigh. from the side. flying. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
grinch. green monster. pixelart. only face. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixelart. chistmas present. powerup. game art Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.