User prompt
Please fix the bug: 'TypeError: undefined is not an object (evaluating 'self.getGameInstance().christmasGifts')' in or related to this line: 'return child instanceof LK.Game;' Line Number: 827
User prompt
Please fix the bug: 'TypeError: undefined is not an object (evaluating 'self.getGameInstance().christmasGifts')' in or related to this line: 'return child instanceof LK.Game;' Line Number: 826
User prompt
Migrate to the latest version of LK
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'christmasGifts')' in this line: '};' Line Number: 710
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'christmasGifts')' in this line: '};' Line Number: 710
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'christmasGifts')' in this line: '};' Line Number: 710
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'christmasGifts')' in this line: '};' Line Number: 710
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'christmasGifts')' in this line: '};' Line Number: 710
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'christmasGifts')' in this line: '};' Line Number: 710
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'christmasGifts')' in this line: '};' Line Number: 710
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'christmasGifts')' in this line: '};' Line Number: 710
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'christmasGifts')' in this line: '};' Line Number: 710
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'christmasGifts')' in this line: '};' Line Number: 710
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'christmasGifts')' in this line: '};' Line Number: 710
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'christmasGifts')' in this line: '};' Line Number: 710
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'christmasGifts')' in this line: '};' Line Number: 710
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'christmasGifts')' in this line: '};' Line Number: 710
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'christmasGifts')' in this line: '};' Line Number: 710
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'christmasGifts')' in this line: '};' Line Number: 710
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'christmasGifts')' in this line: '};' Line Number: 710
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'christmasGifts')' in this line: '};' Line Number: 710
/**** * Classes ****/ var Aim = Container.expand(function () { var self = Container.call(this); var aimGraphics = self.attachAsset('aim', { anchorX: 0.5, anchorY: 0.5 }); }); var ChristmasGift = Container.expand(function () { var self = Container.call(this); self.offScreenHandler = function () { if (self.y > 2732 || self.x < 0 || self.x > 2048 || self.y < 0) { self.flaggedForRemoval = true; } }; var giftTypes = ['christmasGift1', 'christmasGift2', 'christmasGift3']; var randomType = giftTypes[Math.floor(Math.random() * giftTypes.length)]; var christmasGiftGraphics = self.createAsset(randomType, { anchorX: 0.5, anchorY: 1 }); self.x = Math.random() * 1536 + 256; self.y = Math.random() * 1532 + 500; }); var Coin = Container.expand(function () { var self = Container.call(this); var coinGraphics = self.attachAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); self.init = function (coinLayer) { self.x = Math.random() * (2048 - self.width) + self.width / 2; self.y = Math.random() * (2732 - self.height) + self.height / 2; self.coinLayer = coinLayer; coinLayer.addCoin(self); }; self.on('down', function (x, y, obj) { self.coinLayer.removeCoin(self); coinAmount += 5; self.getGameInstance().wallet._update_migrated(); }); pulsate(self, 1.05, 0.01); }); var CoinLayer = Container.expand(function () { var self = Container.call(this); self.coins = []; self.x = 0; self.y = 0; self.addCoin = function (coin) { self.coins.push(coin); self.addChild(coin); }; self.removeCoin = function (coin) { var index = self.coins.indexOf(coin); if (index > -1) { self.coins.splice(index, 1); coin.destroy(); } }; self.updateCoinDisplay = function () { var gameInstance = self.getGameInstance(); if (gameInstance) { gameInstance.wallet.setCoinText(self.coins.length); } }; }); var DamageText = Container.expand(function (damage) { var self = Container.call(this); var damageText = new Text2((Math.round(damage) || '0').toString(), { size: 70, fill: '#ff0000', weight: 'bold', align: 'center' }); damageText.anchor.set(0.5, 0.5); self.addChild(damageText); self.init = function (x, y) { self.targetX = x + (Math.random() * 100 - 50); self.x = x; self.y = y; var fadeStep = 0.05; var moveStep = 1; var fadeInterval = LK.setInterval(function () { self.y -= moveStep; self.x += self.targetX / 1000; damageText.alpha -= fadeStep; if (damageText.alpha <= 0) { LK.clearInterval(fadeInterval); self.destroy(); } }, 3000 / 60); }; }); var GameOverScreen = Container.expand(function (score) { var self = Container.call(this); var gameOverBg = self.attachAsset('gameOverBg', {}); gameOverBg.width = LK.gui.width; gameOverBg.height = LK.gui.height; self.addChild(gameOverBg); var scoreText = new Text2('Score: ' + score, { size: 100, fill: '#ff0000', weight: 'bold', align: 'center' }); scoreText.anchor.set(0.5, 0.5); scoreText.x = LK.gui.width / 2; scoreText.y = 500; self.addChild(scoreText); }); var HardHitText = Container.expand(function (x, y) { var self = Container.call(this); var hardHitTexts = ['Chilled to the bone!', 'Snowball smackdown!', 'Frosty wallop!', 'Icy impact!', 'Blizzard bash!', 'Snowpocalypse strike!', 'Arctic assault!', 'Winter whack!', 'Hailstone hit!', 'Freeze frame!']; var randomIndex = Math.floor(Math.random() * hardHitTexts.length); var text = new Text2(hardHitTexts[randomIndex], { size: 40, fill: '#009900', weight: 'bold', align: 'center' }); text.anchor.set(0.5, 0.5); self.addChild(text); self.x = x; self.y = y; var fadeStep = 0.005; var moveStep = 1; var moveX = Math.random() * 1 - 0.5; var fadeInterval = LK.setInterval(function () { self.y -= moveStep; self.x += moveX; text.alpha -= fadeStep; if (text.alpha <= 0) { LK.clearInterval(fadeInterval); self.destroy(); } }, 1000 / 60); }); var HealthBar = Container.expand(function (maxHealth, size) { var self = Container.call(this); var healthBarBg = self.attachAsset('healthBarBg', { anchorY: 0.5 }); var healthBarFill = self.attachAsset('healthBarFill', { anchorY: 0.5 }); healthBarFill.tint = 0x00ff00; self.maxHealth = maxHealth; self.currentHealth = maxHealth; self.updateHealth = function (newHealth) { self.currentHealth = newHealth; var healthPercentage = self.currentHealth / self.maxHealth; healthBarFill.scale.x = healthPercentage; var redValue = (1 - healthPercentage) * 255; var greenValue = healthPercentage * 255; healthBarFill.tint = (redValue << 16) + (greenValue << 8); }; self.init = function () { var sizeMultiplier = size / 5 + 1; healthBarBg.width = 100 * sizeMultiplier; healthBarBg.height = 20 * sizeMultiplier; healthBarFill.width = 100 * sizeMultiplier; healthBarFill.height = 20 * sizeMultiplier; self.addChild(healthBarBg); self.addChild(healthBarFill); }; self.init(); }); var IntroScreen = Container.expand(function () { var self = Container.call(this); var upgradeBg = self.attachAsset('introBg', {}); var h = H_GUI; var w = W_GUI; upgradeBg.width = w; upgradeBg.height = h; self.addChild(upgradeBg); var logo = self.attachAsset('logo', { anchorX: 0.5, anchorY: 0.5 }); logo.x = w / 2; logo.y = h / 4 - 75; self.addChild(logo); var playButton = self.attachAsset('playButton', { anchorX: 0.5, anchorY: 0.5 }); playButton.x = w / 2; playButton.y = h - 250; var instructionsContainer = new Container(); var instructionsBg = self.attachAsset('instructionsBg', {}); instructionsBg.width = w / 1.5; instructionsBg.height = w / 2.2; instructionsBg.alpha = 0.7; instructionsContainer.addChild(instructionsBg); var instructionsText = new Text2('- Tap to throw snowballs!\n\n- Hold to throw harder\n\n- Hold and drag to add spin\n\n\n\nPROTECT THE CHRISTMAS GIFTS!', { size: 45, fill: '#000000', weight: 'bold', align: 'center' }); instructionsText.anchor.set(0.5, 0.5); instructionsText.x = instructionsBg.width / 2; instructionsText.y = instructionsBg.height / 2; instructionsContainer.addChild(instructionsText); instructionsContainer.x = w / 2 - instructionsBg.width / 2; instructionsContainer.y = h / 2 - instructionsBg.height / 2 + 150; self.addChild(instructionsContainer); var playButton2 = self.attachAsset('playButton', { anchorX: 0.5, anchorY: 0.5 }); playButton2.x = w / 2; playButton2.y = h - 250; self.addChild(playButton2); self.addChild(playButton); playButton.blendMode = 2; playButton2.blendMode = 1; playButton.on('down', function () { LK.gui.topLeft.removeChild(self); self.destroy(); game.startNextWave(); }); pulsate(playButton2, 1.1); pulsate(playButton, 1.05); }); var ParticleSplash = Container.expand(function (didHit) { var self = Container.call(this); var particleSplashGraphics = self.attachAsset('particleSplash', { anchorX: 0.5, anchorY: 0.5 }); var randomScale = 0.5 + Math.random() * 0.5; var alpha = 0.5 + Math.random() * 0.5; if (!didHit) { randomScale *= 0.5; } self.scale.x = randomScale; self.scale.y = randomScale; self.directionX = Math.random() * 2 - 1; self.directionY = Math.random() * 2 - 1; if (!didHit) { self.directionX *= 0.2; self.directionY *= 0.2; } self.animate = function () { if (didHit) { self.alpha -= 0.01; } else { self.alpha -= 0.03; } self.x += self.directionX; self.y += self.directionY; if (self.alpha <= 0) { self.destroy(); } }; }); var ProgressBar = Container.expand(function () { var self = Container.call(this); var progressBarGraphics = self.attachAsset('progressBar2', { anchorX: 0.5, anchorY: 0.5 }); self.updateProgress = function (progress) { progressBarGraphics.scale.x = progress; self.alpha = Math.max(progress, 0.15); }; self.init = function () { self.x = LK.gui.width / 2; self.y = LK.gui.height - 25; LK.gui.topLeft.addChild(self); }; self.alpha = 0.45; self.maxScale = LK.gui.width / 100; self.scale.x = self.maxScale; self.height = 45; self.init(); }); var Santa = Container.expand(function () { var self = Container.call(this); var santaGraphics = self.attachAsset('santa', { anchorX: 0.5, anchorY: 0.5 }); }); var Shadow = Container.expand(function () { var self = Container.call(this); var shadowGraphics = self.attachAsset('shadow', { anchorX: 0.5, anchorY: 0.5 }); self.follow = function (target) { self.x = target.x - (1 - target.percentFromHalf) * 100; self.y = target.y + (1 - target.percentFromHalf) * 100; var scale = target.scale.x * target.scale.x * 0.7; self.scale.x = self.scale.y = scale; self.scale.x = self.scale.y = scale; self.alpha = .5 * (target.percentFromHalf + .2); }; }); var Snowball = Container.expand(function () { var self = Container.call(this); var snowballGraphics = self.attachAsset('snowball', { anchorX: 0.5, anchorY: 0.5 }); self.speed = Math.pow(1.2, upgrades.snowballs + 1) * -10; self.speedX = 0; self.speedY = 0; self.totalDistance = 0; self.spinX = 10; self.moves = 0; self._move_migrated = function () { self.moves++; self.totalDistance = Math.sqrt(Math.pow(self.startX - self.x, 2) + Math.pow(self.y - self.startY, 2)); var halfDistance = self.targetTotalDistance / 2; var distanceFromHalf = 0; if (self.totalDistance < halfDistance) { distanceFromHalf = halfDistance - self.totalDistance; } else { distanceFromHalf = self.totalDistance - halfDistance; } var percentFromHalf = distanceFromHalf / halfDistance; self.percentFromHalf = percentFromHalf; if (percentFromHalf > 1.1) { self.shouldBeDestroyed = true; } else { var scaleAdj = 2 - percentFromHalf * 1.2; self.scale.x = 1 + scaleAdj; self.scale.y = 1 + scaleAdj; self.rotation += self.spinX; self.mayHit = scaleAdj < 0.8; self.x += self.speedX + self.spinX * self.moves * 3; self.y += self.speedY + self.spinY * 100; if (self.shadow) { self.shadow.follow(self); } } }; self.init = function () { self.targetTotalDistance = Math.sqrt(Math.pow(self.targetX - self.x, 2) + Math.pow(self.y - self.targetY, 2)); self.shadow = new Shadow(); self.shadow.follow(self); game.addChild(self.shadow); game.addChild(self); self.spinX = -self.spinX / 5000; self.spinY = -self.spinY / 5000; }; self.die = function () { self.shadow && self.shadow.destroy(); self.aim && self.aim.destroy(); self.destroy(); }; }); var UpgradeContainer = Container.expand(function () { var self = Container.call(this); var upgradeBg = self.attachAsset('upgradeBg', {}); var h = LK.gui.height; var w = LK.gui.width; upgradeBg.width = w; upgradeBg.height = h; self.addChild(upgradeBg); var upgradeTitleAsset = self.attachAsset('upgradeTitle', { anchorX: 0.5, anchorY: 0.5 }); upgradeTitleAsset.x = w / 2; upgradeTitleAsset.y = 230; self.addChild(upgradeTitleAsset); var u1 = new UpgradeItemContainer('snowballs', 'More Ho Ho Ho', 'More snowballs in the air', function () {}); self.addChild(u1); var u2 = new UpgradeItemContainer('strength', 'Increase Christmas Spirit', 'Santa throws harder', function () {}); self.addChild(u2); var u3 = new UpgradeItemContainer('gifts', 'Boost Joy and Laugter', 'Extra christmas gifts', function () { self.getGameInstance().placeGift(); }); self.updateAll = function () { u1._update_migrated(); u2._update_migrated(); u3._update_migrated(); }; self.addChild(u3); u1.y = 530; u2.y = u1.y + 320; u3.y = u2.y + 320; var playButton = self.attachAsset('playButton', { anchorX: 0.5, anchorY: 0.5 }); pulsate(playButton, 1.05); playButton.x = w / 2; playButton.y = h - 270; self.addChild(playButton); playButton.on('down', function () { LK.gui.top.visible = true; self.getGameInstance().startNextWave(); self.destroy(); }); }); var UpgradeItemContainer = Container.expand(function (upgradeType, labelText, infoText, onClickCallback) { var self = Container.call(this); var bg = self.attachAsset('upgradeItemBg', { anchorX: 0.5, anchorY: 0.5 }); bg.width = W_GUI * 0.6; bg.height = 265; bg.x = W_GUI / 2; bg.y = 95; self.addChild(bg); var text = new Text2(labelText, { size: 40, fill: '#006600', weight: 'bold' }); text.anchor.set(0, 0.5); text.x = W_GUI / 2 - bg.width / 2 + 50; text.y = 8; var textInfo = new Text2(infoText, { size: 30, fill: '#000000', weight: 'bold' }); textInfo.anchor.set(0, 0.5); textInfo.x = text.x; textInfo.y = text.y + 48; var priceText = new Text2('0', { size: 50, fill: '#000000', weight: 'bold', align: 'center' }); priceText.anchor.set(0, 0.5); self.addChild(textInfo); self.addChild(text); self.addChild(priceText); var button = self.attachAsset('upgradeButton', { anchorX: 0.5, anchorY: 0.5 }); button.x = W_GUI / 2 + bg.width / 2 - 50; button.y = bg.height / 2 - 45; pulsate(button, 1.02, 0.001); self.addChild(button); var dotContainer = new Container(); var dots = []; for (var i = 0; i < 10; i++) { var dot = self.attachAsset('dot', { anchorX: 0.5, anchorY: 1 }); dot.x = i * 55; dot.scale.x = 3; dot.y = 0; dots.push(dot); dotContainer.addChild(dot); } dotContainer.x = LK.gui.width / 2 - bg.width / 2 + 70; dotContainer.y = bg.height - 70; self.addChild(dotContainer); var coinSprite = self.attachAsset('coinSprite', { anchorY: 0.5 }); coinSprite.x = text.x - 2; coinSprite.y = text.y + 111; priceText.x = coinSprite.x + coinSprite.width + 20; priceText.y = coinSprite.y + 2; self.addChild(coinSprite); button.on('down', function () { self.buy(); onClickCallback(upgradeType); }); var price = basePrice[upgradeType]; self._update_migrated = function () { price = Math.ceil(basePrice[upgradeType] * Math.pow(1.5, upgrades[upgradeType] + 1)); priceText.setText(price); for (var i = 0; i < dots.length; i++) { var d = dots[i]; upgrades[upgradeType] > i ? d.tint = 0x00ee00 : d.tint = 0x555555; } if (coinAmount < price) { button.blendMode = 2; button.alpha = 0.5; } else { button.blendMode = 0; alpha = 1; } }; self.buy = function () { if (coinAmount < price) { return; } coinAmount -= price; self.getGameInstance().wallet._update_migrated(); upgrades[upgradeType]++; self.parent.updateAll(); }; self._update_migrated(); }); var Wallet = Container.expand(function () { var self = Container.call(this); self.setCoinText = function (coinCount) { self.coinText.setText(coinCount.toString()); }; var walletBackground = self.attachAsset('walletBg', { anchorX: 0.5, anchorY: 0.5 }); var walletForeground = self.attachAsset('walletFg', { anchorX: 1, anchorY: 0.5 }); walletBackground.alpha = 0.5; walletForeground.scale.x = walletForeground.scale.y = .7; self.init = function () { self.x = 1418 - walletBackground.width / 2; self.y = 110; self.coinText = new Text2('' + coinCount, { size: 50, weight: 700, fill: '#000000', align: 'center' }); self.coinText.x = walletForeground.x + 65; self.coinText.y = walletForeground.y; self.coinText.anchor.set(1, 0.5); self.addChild(self.coinText); LK.gui.topLeft.addChildAt(self, LK.gui.topLeft.children.length); }; self._update_migrated = function () { self.coinText.setText('' + coinAmount); LK.gui.topLeft.addChildAt(self, LK.gui.topLeft.children.length); }; }); var WaveCounterText = Container.expand(function (level) { var self = Container.call(this); var text = new Text2('Wave ' + level, { size: 250, weight: 700, fill: "#005500", align: 'center' }); text.anchor.set(.5, .5); text.x = 2048 / 2 + 100; text.y = 2732 / 2; self.addChild(text); var maxScale = 1.1; var minScale = 0.9; var scaleStep = 0.005; var growing = true; self.scale.x = self.scale.y = minScale; LK.on('tick', function () { if (growing) { text.scale.x += scaleStep; text.scale.y += scaleStep; if (text.scale.x >= maxScale) { growing = false; } } else { text.scale.x -= scaleStep; text.scale.y -= scaleStep; if (text.scale.x <= minScale) { growing = true; } } }); LK.setTimeout(function () { var fadeStep = 0.05; var fadeInterval = LK.setInterval(function () { text.alpha -= fadeStep; if (text.alpha <= 0) { LK.clearInterval(fadeInterval); self.destroy(); } }, 1000 / 60); }, 3000); }); var ZombieKid = Container.expand(function (size) { var self = Container.call(this); ZombieKid.prototype.startFadeOut = function () { var fadeStep = 0.05; self.healthBar.visible = false; var fadeInterval = LK.setInterval(function () { self.alpha -= fadeStep; if (self.alpha <= 0) { LK.clearInterval(fadeInterval); self.shouldBeDestroyed = true; } }, 1000 / 60); }; self.size = size; var zombieKidGraphics; switch (self.size) { case 1: zombieKidGraphics = self.attachAsset('zombieKidSmall', { anchorX: 0.5, anchorY: 0.8 }); break; case 2: zombieKidGraphics = self.attachAsset('zombieKidMedium', { anchorX: 0.5, anchorY: 0.8 }); break; case 3: zombieKidGraphics = self.attachAsset('zombieKidLarge', { anchorX: 0.5, anchorY: 0.8 }); break; case 4: zombieKidGraphics = self.attachAsset('zombieKidXLarge', { anchorX: 0.5, anchorY: 0.8 }); break; case 5: zombieKidGraphics = self.attachAsset('zombieKidXXLarge', { anchorX: 0.5, anchorY: 0.8 }); break; default: zombieKidGraphics = self.attachAsset('zombieKid', { anchorX: 0.5, anchorY: 0.8 }); } var health = [20, 50, 100, 200, 500][self.size - 1]; self.healthBar = new HealthBar(health, self.size); self.healthBar.y = 80; self.healthBar.x = -self.healthBar.width / 2; self.addChild(self.healthBar); self.speed = (Math.random() * 2 + 1.3) * (1 - (self.size - 1) * 0.1); self.hasGift = false; self.pickedUpGift = null; self.findNewTarget = function () { var availableGifts = []; var gifts = self.getGameInstance().christmasGifts; if (this.parent) { availableGifts = gifts.filter(function (g) { return !g.isDestroyed && !g.hasBeenPickedUp; }); } if (availableGifts.length > 0) { var randomIndex = Math.floor(Math.random() * availableGifts.length); this.targetGift = availableGifts[randomIndex]; } }; self._move_migrated = function () { if (!self.hasGift) { if (self.targetGift) { var dx = self.targetGift.x - self.x; var dy = self.targetGift.y - self.y; } else { return self.findNewTarget(); } var angle = Math.atan2(dy, dx); var mx = Math.cos(angle) * self.speed; if (mx < 0) { self.scale.x = -1; } else { self.scale.x = 1; } if (mx < 0) { self.healthBar.scale.x = -1; } else { self.healthBar.scale.x = 1; } if (mx > 0) { self.healthBar.x = -self.healthBar.width / 2; } else { self.healthBar.x = -self.healthBar.width / 2; } mx += +Math.random() * self.speed; self.x += mx; self.y += Math.sin(angle) * self.speed + Math.random() * self.speed * .5; if (self.targetGift && !self.targetGift.isDestroyed && !self.targetGift.hasBeenPickedUp && Math.abs(self.x - self.targetGift.x) < 10 && Math.abs(self.y - self.targetGift.y + 50) < 50) { self.hasGift = true; self.exitDirection = Math.random() < .5 ? -1 : 1; self.targetGift.hasBeenPickedUp = true; self.targetGift.owner = self; self.pickedUpGift = self.targetGift; if (self.pickedUpGift.parent) { self.pickedUpGift.parent.setChildIndex(self.pickedUpGift, self.pickedUpGift.parent.children.length - 1); } } else if (!self.targetGift || self.targetGift.isDestroyed || self.targetGift.hasBeenPickedUp) { self.findNewTarget(); } } else { if (self.hasGift && !self.speedIncreased) { self.speed *= 1.5; self.speedIncreased = true; } var mx = self.speed * self.exitDirection; if (mx < 0) { self.scale.x = -1; } else { self.scale.x = 1; } if (mx < 0) { self.healthBar.scale.x = -1; } else { self.healthBar.scale.x = 1; } if (mx > 0) { self.healthBar.x = -self.healthBar.width / 2; } else { self.healthBar.x = -self.healthBar.width / 2; } self.x += mx; self.y -= self.speed * Math.random(); if (self.pickedUpGift && !self.isDying) { self.pickedUpGift.x = self.x; self.pickedUpGift.y = self.y + 30; } } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var W_GUI = 1440; var H_GUI = 1920; var coinAmount = 0; var coinCount = 0; var snowballUpgrades = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; var baseStrength = .5; var upgrades = { snowballs: 0, strength: 0, gifts: 0 }; var basePrice = { snowballs: 10, strength: 5, gifts: 1 }; function pulsate(item, amount, scaleStep) { var maxScale = 1 * amount; var minScale = 1 / amount; var scaleStep = scaleStep || 0.004; var growing = true; item.scale.x = minScale; item.scale.y = minScale; LK.on('tick', function () { if (growing) { item.scale.x += scaleStep; item.scale.y += scaleStep; if (item.scale.x >= maxScale) { growing = false; } } else { item.scale.x -= scaleStep; item.scale.y -= scaleStep; if (item.scale.x <= minScale) { growing = true; } } }); } ; Container.prototype.getGameInstance = function () { var currentParent = this.parent; while (currentParent) { if (currentParent && currentParent instanceof LK.Game) { return currentParent; } currentParent = currentParent.parent; } if (currentParent === game) { return currentParent; } if (game && game.children) { return game.children.find(function (child) { return child instanceof LK.Game; }); } return null; }; var currentLevel = 0; var zombieKids = []; var christmasGifts = []; var levels = [{ zombieKidSizes: [1, 1, 2] }, { zombieKidSizes: [1, 1, 2, 2] }, { zombieKidSizes: [1, 1, 2, 2, 2, 3] }, { zombieKidSizes: [5] }, { zombieKidSizes: [2, 2, 2, 3, 4] }, { zombieKidSizes: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] }, { zombieKidSizes: [1, 1, 2, 2, 3, 3, 4, 4] }, { zombieKidSizes: [5, 5] }, { zombieKidSizes: [1, 1, 2, 2, 3, 3, 4, 4, 5] }, { zombieKidSizes: [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2] }, { zombieKidSizes: [3, 3, 3, 3, 3, 3, 3, 3, 3, 3] }, { zombieKidSizes: [1, 1, 2, 2, 3, 3, 4, 4, 4] }, { zombieKidSizes: [5, 5, 5, 5] }, { zombieKidSizes: [1, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4] }, { zombieKidSizes: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 5] }, { zombieKidSizes: [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5] }, { zombieKidSizes: [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2] }, { zombieKidSizes: [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3] }, { zombieKidSizes: [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4] }, { zombieKidSizes: [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5] }, { zombieKidSizes: [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5] }]; game.spawnSnowParticles = function (snowball, didHit) { var splashes = Math.abs(snowball.speedX) + Math.abs(snowball.speedY); for (var i = 0; i < Math.max(5, splashes / 5); i++) { var particleSplash = new ParticleSplash(didHit); particleSplash.x = snowball.x; particleSplash.y = snowball.y; particleSplash.directionX *= snowball.speedY; particleSplash.directionY *= snowball.speedY; this.addChild(particleSplash); } }; game.waveInProgress = false; game.showUpgradeContainer = function () { game.waveInProgress = false; var upgradeContainer = new UpgradeContainer(); LK.gui.topLeft.addChild(upgradeContainer); game.wallet._update_migrated(); LK.gui.top.visible = false; }; var introScreen = new IntroScreen(); LK.gui.topLeft.addChild(introScreen); LK.gui.top.visible = false; game.progressBar = new ProgressBar(); zombieKids = []; game.spawnZombieKids = function () { var zombieKidSizes = levels[currentLevel].zombieKidSizes || []; var adjustedLength = currentLevel <= 5 ? zombieKidSizes.length : Math.ceil(zombieKidSizes.length * 0.8); for (var i = 0; i < adjustedLength; i++) { var newZombieKid = new ZombieKid(zombieKidSizes[i]); newZombieKid.speed = game.zombieKidSpeed; newZombieKid.x = Math.random() * (2448 - newZombieKid.width); -200; newZombieKid.y = Math.random() * 2000 - 500; if (newZombieKid.y > 0) { newZombieKid.x = Math.random() < 0.5 ? -200 : 2448; } zombieKids.push(newZombieKid); game.addChild(newZombieKid); } }; game.startNextWave = function () { game.wallet.visible = true; if (currentLevel < levels.length) { var level = levels[currentLevel]; game.numZombieKids = level.zombieKidSizes.length; game.coinFrequency = level.coinFrequency; game.zombieKidSpeed = 2 + 0.2 * currentLevel; game.spawnZombieKids(); currentLevel++; var waveCounterTxt = new WaveCounterText(currentLevel); game.addChild(waveCounterTxt); game.waveInProgress = true; LK.setTimeout(function () { var coin = new Coin(); coin.init(game.coinLayer); }, Math.random() * 5000); } }; var background = game.attachAsset('background', {}); background.width = 2048; background.height = 2732; game.isThrowing = false; game.addChildAt(background, 0); game.coinLayer = new CoinLayer(); game.addChild(game.coinLayer); var santa = game.addChild(new Santa()); santa.x = 2048 / 2; santa.y = 2732 - santa.height / 2 - 170; var placedGifts = 0; var tries = 0; game.placeGift = function () { var gift = new ChristmasGift(); pulsate(gift, 1.03, 0.002); var intersects = false; for (var j = 0; j < christmasGifts.length; j++) { if (gift === christmasGifts[j]) { continue; } if (Math.abs(gift.x - christmasGifts[j].x) < 150 && Math.abs(gift.y - christmasGifts[j].y) < 150) { intersects = true; } } if (!intersects) { christmasGifts.push(gift); game.addChild(gift); placedGifts++; } }; while (placedGifts < 10) { tries++; if (tries > 1000) { break; } game.placeGift(); } var scoreTxt = new Text2('0', { size: 150, weight: 700, fill: "#000000" }); game.wallet = new Wallet(); game.wallet.init(); game.wallet.visible = false; game.coinLayer = new CoinLayer(); game.addChild(game.coinLayer); scoreTxt.anchor.set(0.5, 0.5); scoreTxt.x = 0; scoreTxt.y = 100; LK.gui.top.addChild(scoreTxt); game.updateScoreDisplay = function () { scoreTxt.setText(LK.getScore().toString()); }; game.updateScoreDisplay(); game.snowballs = []; var touchStartTime = 0; game.removeSnowball = function (snowball) { var a = game.snowballs.indexOf(snowball); if (game.snowballs[a].aim) { game.snowballs[a].aim.destroy(); } if (game.snowballs[a].shadow) { game.snowballs[a].shadow.destroy(); } game.snowballs.splice(a, 1); snowball.destroy(); }; game.showGameOverScreen = function () { var gameOverScreen = new GameOverScreen(LK.getScore()); LK.gui.topLeft.addChild(gameOverScreen); LK.setTimeout(function () { LK.showGameOver(); }, 3000); }; game.spawnAim = function (pos) { var aim = new Aim(); game.currentAim = aim; aim.x = pos.x; aim.y = pos.y; var progress = 0; aim.scale.x = aim.scale.y = 0.5 + progress * 0.5; game.addChild(aim); game.lastAim = aim; aim.tweenToAlpha = function (targetAlpha, duration) { var step = (1 - targetAlpha) / (duration * 60); var fadeInterval = LK.setInterval(function () { aim.alpha -= step; if (aim.alpha <= targetAlpha) { LK.clearInterval(fadeInterval); aim.destroy(); } }, 1000 / 60); }; aim.tweenToAlpha(0, 3); }; game.removeDeadZombieKids = function () { for (var i = zombieKids.length - 1; i >= 0; i--) { if (zombieKids[i].shouldBeDestroyed) { if (zombieKids[i].pickedUpGift) { zombieKids[i].pickedUpGift.hasBeenPickedUp = false; } zombieKids[i].destroy(); zombieKids.splice(i, 1); } } }; game.on('down', function (x, y, obj) { touchStartTime = LK.ticks; isThrowing = true; var event = obj; var pos = game.toLocal(event.global); game.downPos = pos; santa.baseRotation = Math.atan2(pos.y - santa.y, pos.x - santa.x) + Math.PI * 0.6; game.aimPosition = pos; if (game.snowballs.length < upgrades.snowballs + 2) { game.spawnAim(pos); } }); game.on('up', function (x, y, obj) { if (game.aim) { game.aim.destroy(); game.aim = null; } game.progressBar.updateProgress(0); santa.rotation = santa.baseRotation; isThrowing = false; if (game.snowballs.length < upgrades.snowballs + 2 && game.aimPosition) { var newSnowball = new Snowball(game.currentAim); newSnowball.x = santa.x + 230; ; newSnowball.y = santa.y; newSnowball.startX = santa.x + 120; newSnowball.startY = santa.y; newSnowball.aim = game.currentAim; var endPos = game.toLocal(obj.global); newSnowball.spinX = game.downPos.x - endPos.x; newSnowball.spinY = game.downPos.y - endPos.y; var aim = 0.5; var missDistance = 300; var missX = Math.random() * missDistance - missDistance / 2; var missY = Math.random() * missDistance - missDistance / 2; newSnowball.targetX = game.aimPosition.x + +missX * aim; newSnowball.targetY = game.aimPosition.y + missY * aim; ; newSnowball.init(); var dx = newSnowball.targetX - newSnowball.x + newSnowball.spinX * 0.5; var dy = newSnowball.targetY - newSnowball.y; var distance = Math.sqrt(dx * dx + dy * dy); var throwSpeed = 1.5 + upgrades.strength * 0.3; var touchDuration = LK.ticks - touchStartTime; touchDuration = Math.min(touchDuration, 30); var speedMultiplier = Math.max(touchDuration / 10, 1) * throwSpeed; newSnowball.isMaxPower = touchDuration >= 29; newSnowball.speedMultiplier = speedMultiplier; var aim = 0.5; var missDistance = 20; var missX = Math.random() * missDistance - missDistance / 2; var missY = Math.random() * missDistance - missDistance / 2; newSnowball.speedX = -dx / distance * newSnowball.speed * speedMultiplier; newSnowball.speedY = -Math.abs(dy / distance * newSnowball.speed) * speedMultiplier; game.snowballs.push(newSnowball); game.aimPosition = null; } game.currentAim = null; }); var christmasGifts = []; LK.on('tick', function () { if (!Array.isArray(game.christmasGifts)) { game.christmasGifts = []; } if (!Array.isArray(game.christmasGifts)) { game.christmasGifts = []; } if (Math.random() < 0.01) { console.log("kids"); console.log(zombieKids); console.log("gifts"); } game.removeDeadZombieKids(); if (touchStartTime > 0 && isThrowing) { var progress = Math.min((LK.ticks - touchStartTime) / 30, 1); game.progressBar.updateProgress(progress); santa.rotation = santa.baseRotation + progress * Math.PI * 2 / 10; if (game.aim) { game.aim.scale.x = game.aim.scale.y = 0.5 + progressBarGraphics.scale.x * 0.5; } if (game.currentAim) { game.currentAim.scale.x = 0.2 + progress; game.currentAim.scale.y = 0.2 + progress; } } for (var a = game.snowballs.length - 1; a >= 0; a--) { if (game.snowballs[a]) { game.snowballs[a]._move_migrated(); for (var b = zombieKids.length - 1; b >= 0; b--) { if (zombieKids[b] && game.snowballs[a] && game.snowballs[a].intersects(zombieKids[b]) && game.snowballs[a].mayHit) { LK.setScore(LK.getScore() + currentLevel); coinAmount += 1; game.wallet._update_migrated(); game.updateScoreDisplay(); game.spawnSnowParticles(game.snowballs[a], true); var damage = 20 + (game.snowballs[a].speedMultiplier - 1) * 10; if (game.snowballs[a].isMaxPower) { var hardHitText = new HardHitText(game.snowballs[a].x, game.snowballs[a].y - 50); game.addChild(hardHitText); } var damageText = new DamageText(damage); game.addChild(damageText); damageText.init(game.snowballs[a].x, game.snowballs[a].y); if (zombieKids[b].hasGift) { var droppedGift = zombieKids[b].pickedUpGift; droppedGift.x = zombieKids[b].x; droppedGift.y = zombieKids[b].y; droppedGift.hasBeenPickedUp = false; } zombieKids[b].healthBar.updateHealth(zombieKids[b].healthBar.currentHealth - damage); if (zombieKids[b].healthBar.currentHealth <= 0) { zombieKids[b].startFadeOut(); zombieKids[b].isDying = true; } game.removeSnowball(game.snowballs[a]); break; } } if (game.snowballs[a] && (game.snowballs[a].y < -50 || game.snowballs[a].shouldBeDestroyed)) { game.removeSnowball(game.snowballs[a]); } } } if (zombieKids.length === 0 && game.waveInProgress && currentLevel > 0) { game.waveInProgress = false; var victoryTexts = ['Jingle All The Way!', 'Ho-ho-holy Win!', 'Frosty Finish!', 'Sleighed It!', 'Yule Rock!', 'Elf-tastic!', 'Merry Victory!', 'Santa-tastic!', 'Chimney Champion!', 'Ornament Overlord!', 'Sleigh Bell Boss!', 'Mistletoe Master!', 'Holiday Hero!', 'Winter Wizard!', 'Eggnog Emperor!']; var randomVictoryText = victoryTexts[Math.floor(Math.random() * victoryTexts.length)]; var victoryText = new Text2(randomVictoryText, { size: 100, fill: '#da1c13', weight: 'bold', align: 'center' }); victoryText.anchor.set(0.5, 0.5); victoryText.x = LK.gui.width / 2; victoryText.y = LK.gui.height / 2; LK.gui.topLeft.addChild(victoryText); var fadeStep = 0.005; var moveStep = 1; var fadeInterval = LK.setInterval(function () { victoryText.y -= moveStep; victoryText.alpha -= fadeStep; if (victoryText.alpha <= 0) { LK.clearInterval(fadeInterval); victoryText.destroy(); } }, 1000 / 60); LK.setTimeout(function () { game.showUpgradeContainer(); }, 2000); } for (var b = zombieKids.length - 1; b >= 0; b--) { if (zombieKids[b]) { zombieKids[b]._move_migrated(); } } for (var c = game.children.length - 1; c >= 0; c--) { if (game.children[c] instanceof ParticleSplash) { game.children[c].animate(); } } for (var j = 0; j < christmasGifts.length; j++) { christmasGifts[j].offScreenHandler(); if (christmasGifts && christmasGifts[j].flaggedForRemoval) { christmasGifts[j].owner.hasGift = false; christmasGifts[j].owner.targetGift = false; christmasGifts[j].destroy(); christmasGifts.splice(j, 1); if (christmasGifts.length === 0) { game.showGameOverScreen(); } } } });
===================================================================
--- original.js
+++ change.js
@@ -773,9 +773,9 @@
;
Container.prototype.getGameInstance = function () {
var currentParent = this.parent;
while (currentParent) {
- if (currentParent instanceof LK.Game) {
+ if (currentParent && currentParent instanceof LK.Game) {
return currentParent;
}
currentParent = currentParent.parent;
}
a christmas gift Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
red crosshair Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
snowball of soft snow Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Christmas gift with glowing green wrapping paper Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas gift in beautiful glowing wrapping paper Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Christmas gift beautifully wrapped in green glowing wrapping paper Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Snowy flat surface viewed from above at nighttime Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
an empty painting with a winter styled frame Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a kid thief in wearing a black hoodie. Also looking like a zombie Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A button with the text "play". Winter theme Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A winter themed button, with no text Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A buy upgrade button, winter theme, no text Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a wide white sheet of paper Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a snowball Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a snowball
A game over screen for the game "Snowball Santa". Santa is very sad because all the presents has been stolen from ninja kids. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A wooden sign with text "UPGRADES" in a winter theme. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A ninja kid thief, full body, with a dark purple hoodie. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A ninja kid thief, full body, with a dark colored hoodie. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A ninja kid thief, full body, with a dark colored hoodie. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a precious colorful glowing gem with snow and ice on it. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a logo for the game "Snowball santa" with the text "Snowball Santa". Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A beautiful winter snowy christmas landscape with ninja thieves kids lurking. Christmas gifts are hidden in the snow. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.