User prompt
fix this countdown timer to reset once it hits 0
User prompt
make sure the countdown is always running
User prompt
when the countdown hits 0, spawn a badelf and restart the countdown
User prompt
start a 10 seconds countdown when a badelf is created
User prompt
every 100 points, spawn an extra mistletoe
User prompt
every minute spawn an additional mistletoe somewhere on the screen
Code edit (5 edits merged)
Please save this source code
User prompt
Fix Bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'x')' in this line: 'var extraBadElf = new BadElf(location.x, location.y, self);' Line Number: 567
Code edit (5 edits merged)
Please save this source code
User prompt
ix Bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'x')' in this line: 'var extraBadElf = new BadElf(location.x, location.y, self);'
User prompt
fix Bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'x')' in this line: 'var extraBadElf = new BadElf(location.x, location.y, self);'
User prompt
Fix Bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'x')' in this line: 'var extraBadElf = new BadElf(location.x, location.y, self);' Line Number: 548
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'x')' in this line: 'var extraBadElf = new BadElf(location.x, location.y, self);' Line Number: 548
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'x')' in this line: 'var extraBadElf = new BadElf(location.x, location.y, self);' Line Number: 573
User prompt
Fix Bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'x')' in this line: 'var extraBadElf = new BadElf(location.x, location.y, self);' Line Number: 577
Code edit (5 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'y')' in this line: 'heart.y = santa.y - santa.santaGraphics.height - heart.height / 2 + 350;' Line Number: 276
Code edit (9 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: barn is not defined' in this line: 'console.log("Barn Object" + barn);' Line Number: 160
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'x')' in this line: 'var extraBadElf = new BadElf(location.x, location.y, self);' Line Number: 565
User prompt
Fix Bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'x')' in this line: 'var extraBadElf = new BadElf(location.x, location.y, self);' Line Number: 569
User prompt
Fix Bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'x')' in this line: 'var extraBadElf = new BadElf(location.x, location.y, self);' Line Number: 565
===================================================================
--- original.js
+++ change.js
@@ -262,9 +262,24 @@
self.y = -crosshairGraphics.height / 2;
});
var Game = Container.expand(function () {
var self = Container.call(this);
- this.barnMovedDown = false;
+ var isGameOver = false;
+ var tickOffset = 0;
+ var leftClickPressed = false;
+ var barnMovedDown = false;
+ var lastClickTime = 0;
+ var playerLives = 6;
+ var hearts = [];
+ for (var i = 0; i < playerLives; i++) {
+ var heart = new Heart();
+ heart.x = 1125 + i * (heart.width + 5);
+ if (santa.santaGraphics) {
+ heart.y = santa.y - santa.santaGraphics.height - heart.height / 2 + 350;
+ } else {}
+ hearts.push(heart);
+ LK.gui.topLeft.addChild(heart);
+ }
this.triggerGameOver = function () {
this.isGameOver = true;
LK.showGameOver();
LK.on('tick', function () {
@@ -292,31 +307,8 @@
this.triggerGameOver = function () {
this.isGameOver = true;
LK.showGameOver();
};
- self.maxMagicAllowed = 3;
- if (self.activeMagicCount < self.maxMagicAllowed && LK.gui.topCenter.children[0] && LK.gui.topCenter.children[0].visible && self.activeBadElves > 0) {
- var magicInstance = new Magic(this.magicSpawnX, this.magicSpawnY, self);
- self.addChild(magicInstance);
- self.activeMagicCount++;
- }
- self.respawnReindeer = function (reindeer) {
- LK.setTimeout(function () {
- var newReindeer = new Reindeer(self);
- var spawnLeftSide = Math.random() < 0.5;
- newReindeer.x = spawnLeftSide ? 0 : 2048;
- newReindeer.y = Math.random() * (2732 / 4 - newReindeer.height) + newReindeer.height;
- newReindeer.arcDirection = spawnLeftSide ? 1 : -1;
- newReindeer.arcRadius = 2048 / 2;
- newReindeer.arcAngle = spawnLeftSide ? Math.PI : 0;
- var scale = Math.random() * 0.25 + 0.75;
- newReindeer.scale.set(scale);
- self.addChild(newReindeer);
- LK.on('tick', function () {
- newReindeer.moveHorizontally();
- });
- }, Math.random() < 0.5 ? 8000 : 12000);
- };
self.showGreatText = function (x, y) {
var greatText = new Text2('Nice!', {
size: 40,
fill: '#ffffff',
@@ -345,8 +337,31 @@
snowflake.y = Math.random() * 2732;
self.addChild(snowflake);
}, 1000);
};
+ self.maxMagicAllowed = 3;
+ if (self.activeMagicCount < self.maxMagicAllowed && LK.gui.topCenter.children[0] && LK.gui.topCenter.children[0].visible && self.activeBadElves > 0) {
+ var magicInstance = new Magic(this.magicSpawnX, this.magicSpawnY, self);
+ self.addChild(magicInstance);
+ self.activeMagicCount++;
+ }
+ self.respawnReindeer = function (reindeer) {
+ LK.setTimeout(function () {
+ var newReindeer = new Reindeer(self);
+ var spawnLeftSide = Math.random() < 0.5;
+ newReindeer.x = spawnLeftSide ? 0 : 2048;
+ newReindeer.y = Math.random() * (2732 / 4 - newReindeer.height) + newReindeer.height;
+ newReindeer.arcDirection = spawnLeftSide ? 1 : -1;
+ newReindeer.arcRadius = 2048 / 2;
+ newReindeer.arcAngle = spawnLeftSide ? Math.PI : 0;
+ var scale = Math.random() * 0.25 + 0.75;
+ newReindeer.scale.set(scale);
+ self.addChild(newReindeer);
+ LK.on('tick', function () {
+ newReindeer.moveHorizontally();
+ });
+ }, Math.random() < 0.5 ? 8000 : 12000);
+ };
LK.setTimeout(function () {
var fadeOutDuration = 2000;
var fadeOutStep = 0.05;
var fadeOutInterval = LK.setInterval(function () {
@@ -406,51 +421,8 @@
});
}, 12000);
LK.setTimeout(self.generateMistletoes, 8000);
}, 2000);
- stage.on('move', function (obj) {
- crosshair.move(obj.event);
- });
- stage.on('down', function (obj) {
- var pos = obj.event.getLocalPosition(self);
- crosshair.x = pos.x;
- crosshair.y = pos.y;
- if (hearts.length > 0) {
- muzzleFlash.show();
- leftClickPressed = true;
- lastClickTime = LK.ticks;
- if (!barnMovedDown) {
- self.children.forEach(function (child) {
- if (child instanceof BadElf) {
- child.y += 100;
- }
- });
- barnBackground.y += 460;
- room1Background.y += 100;
- boxBackground.y += 100;
- crateBackground.y += 100;
- missBackground.y += 460;
- tireBackground.y += 100;
- barnMovedDown = true;
- if (Math.random() < 0.10) {
- var messages = ["Santa's special delivery!", "This is for the naughty list!", "Ho, ho, ho-hold this!"];
- if (!self.randomTextActive) {
- self.randomTextActive = true;
- var randomText = new RandomText();
- randomText.display(santa.x, santa.y - santa.santaGraphics.height / 2, messages);
- self.addChild(randomText);
- }
- }
- }
- var heart = hearts.pop();
- heart.destroy();
- }
- self.children.forEach(function (child) {
- if (child instanceof BadElf && leftClickPressed && LK.ticks - lastClickTime > 30) {
- child.y -= 100;
- }
- });
- });
var room1Background = self.createAsset('Room1', 'Room1 background', 0, 0);
room1Background.anchor.set(0.5, 0.5);
room1Background.x = 2048 / 2;
room1Background.y = 2732 / 2;
@@ -516,8 +488,16 @@
}, {
x: 100,
y: 1100
}];
+ var muzzleFlash = new MuzzleFlash();
+ muzzleFlash.x = santa.x - santa.santaGraphics.width + 400;
+ muzzleFlash.y = santa.y - 90;
+ self.addChild(muzzleFlash);
+ self.addChild(santa);
+ var crosshair = self.addChild(new Crosshair());
+ crosshair.x = 2048 / 2;
+ crosshair.y = 2732 / 2;
var usedSpawnLocations = [];
var spawnLocationCounter = 0;
self.activeBadElves = 0;
self.spawnBadElf = function () {
@@ -580,30 +560,8 @@
self.activeBadElves++;
}
}
};
- var muzzleFlash = new MuzzleFlash();
- muzzleFlash.x = santa.x - santa.santaGraphics.width + 400;
- muzzleFlash.y = santa.y - 90;
- self.addChild(muzzleFlash);
- self.addChild(santa);
- var crosshair = self.addChild(new Crosshair());
- crosshair.x = 2048 / 2;
- crosshair.y = 2732 / 2;
- var isGameOver = false;
- var tickOffset = 0;
- var leftClickPressed = false;
- var barnMovedDown = false;
- var lastClickTime = 0;
- var playerLives = 6;
- var hearts = [];
- for (var i = 0; i < playerLives; i++) {
- var heart = new Heart();
- heart.x = 1125 + i * (heart.width + 5);
- heart.y = santa.y - santa.santaGraphics.height - heart.height / 2 + 350;
- hearts.push(heart);
- LK.gui.topLeft.addChild(heart);
- }
LK.on('tick', function () {
santa.move();
for (var i = 0; i < self.children.length; i++) {
var child = self.children[i];
@@ -641,5 +599,50 @@
LK.gui.topLeft.addChild(heart);
}
}
});
+ stage.on('move', function (obj) {
+ crosshair.move(obj.event);
+ });
+ stage.on('down', function (obj) {
+ var pos = obj.event.getLocalPosition(self);
+ crosshair.x = pos.x;
+ crosshair.y = pos.y;
+ if (hearts.length > 0) {
+ muzzleFlash.show();
+ leftClickPressed = true;
+ lastClickTime = LK.ticks;
+ if (!barnMovedDown) {
+ self.children.forEach(function (child) {
+ if (child instanceof BadElf) {
+ child.y += 100;
+ }
+ });
+ barnBackground.y += 460;
+ room1Background.y += 100;
+ boxBackground.y += 100;
+ crateBackground.y += 100;
+ missBackground.y += 460;
+ tireBackground.y += 100;
+ this.barnMovedDown = true;
+ console.log("Barn moved down = " + barnMovedDown);
+ console.log(self);
+ if (Math.random() < 0.10) {
+ var messages = ["Santa's special delivery!", "This is for the naughty list!", "Ho, ho, ho-hold this!"];
+ if (!self.randomTextActive) {
+ self.randomTextActive = true;
+ var randomText = new RandomText();
+ randomText.display(santa.x, santa.y - santa.santaGraphics.height / 2, messages);
+ self.addChild(randomText);
+ }
+ }
+ }
+ var heart = hearts.pop();
+ heart.destroy();
+ }
+ self.children.forEach(function (child) {
+ if (child instanceof BadElf && leftClickPressed && LK.ticks - lastClickTime > 30) {
+ child.y -= 100;
+ }
+ });
+ });
});
over the shoulder santa firing a revolver Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d transparent christmas crosshair Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d 3rd person front view of a christmas town square with a starry sky Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Christmas sparkles png Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
circular christmas golden star pattern transparent png Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d christmas brick wall Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d opened christmas crate Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d diagonal christmas car or truck in snow Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas poster showcasing miss santa clause Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a single white snowflake Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d stacked christmas winter tire Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d stacked christmas winter tire Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d christmas magical mistletoe Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d christmas 357 Magnum bullets Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d silhouette of a flying reindeer with a red glowy nose Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d christmas dark sparkles Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d christmas evil robot elf with a gun 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.
2d pile of gray and red nuts and bolts Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
transparent snow sphere. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
snd_pistol
Sound effect
snd_enemyshot
Sound effect
snd_obstacle
Sound effect
snd_messages
Sound effect
snd_ricochet
Sound effect
snd_reindeer
Sound effect
snd_mistletoe
Sound effect
snd_reindeershot
Sound effect
snd_mistletoeshot
Sound effect
snd_christmasmusic
Music
snd_reload
Sound effect
snd_blastwave
Sound effect