Code edit (1 edits merged)
Please save this source code
User prompt
don't throw a snowball if a coin was tapped
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: snowballs is not defined' in this line: 'particleSplash.x = snowballs[a].x;' Line Number: 656
User prompt
Fix Bug: 'ReferenceError: snowballs is not defined' in this line: 'if (snowballs[a] && (snowballs[a].y < -50 || snowballs[a].shouldBeDestroyed)) {' Line Number: 679
User prompt
Fix Bug: 'ReferenceError: snowballs is not defined' in this line: 'if (zombieKids[b] && snowballs[a] && snowballs[a].intersects(zombieKids[b]) && snowballs[a].mayHit) {' Line Number: 651
User prompt
Fix Bug: 'ReferenceError: snowballs is not defined' in this line: 'snowballs[a].move();' Line Number: 649
User prompt
Fix Bug: 'ReferenceError: snowballs is not defined' in this line: 'if (snowballs[a]) {' Line Number: 648
User prompt
Fix Bug: 'ReferenceError: a is not defined' in this line: 'if (gameInstance.snowballs[a].aim) gameInstance.snowballs[a].aim.destroy();' Line Number: 244
Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: snowballs is not defined' in this line: 'if (snowballs[a].aim) snowballs[a].aim.destroy();' Line Number: 244
User prompt
Fix Bug: 'ReferenceError: snowballs is not defined' in this line: 'if (snowballs.length < 3 && self.aimPosition) {' Line Number: 613
User prompt
Fix Bug: 'ReferenceError: snowballs is not defined' in this line: 'if (snowballs[a].aim) snowballs[a].aim.destroy();' Line Number: 244
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'coins')' in this line: 'gameInstance.coinLayer.removeCoin(self.coinLayer.coins[k]);' Line Number: 242
Code edit (6 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught ReferenceError: sekf is not defined' in this line: 'sekf.addChild(self.coinLayer);' Line Number: 547
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught ReferenceError: coinLayer is not defined' in this line: 'self.addChild(coinLayer);' Line Number: 500
Code edit (7 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: allCoins is not defined' in this line: 'for (var k = 0; k < allCoins.length; k++) {' Line Number: 666
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'toString')' in this line: 'coinCounterTxt.setText('' + coinCount.toString());' Line Number: 548
User prompt
add coins to a separate layer
Code edit (4 edits merged)
Please save this source code
User prompt
coins should be drawn under zombie kids
var UpgradeItemContainer = Container.expand(function (upgradeType, labelText, onClickCallback) { var self = Container.call(this); var bg = self.createAsset('upgradeItemBg', 'Upgrade Item Background', 0.5, 0.5); bg.width = LK.gui.width * 0.6; bg.height = 245; bg.x = LK.gui.width / 2; bg.y = 75; self.addChild(bg); var text = new Text2(labelText, { size: 50, fill: '#006600', weight: 'bold' }); text.anchor.set(0, 0.5); text.x = LK.gui.width / 2 - bg.width / 2 + 50; text.y = 10; var priceText = new Text2('0', { size: 50, fill: '#000000', weight: 'bold', align: 'center' }); priceText.anchor.set(0, 0.5); self.addChild(text); self.addChild(priceText); var button = self.createAsset('upgradeButton', 'Upgrade Button', 0.5, 0.5); button.x = LK.gui.width / 2 + bg.width / 2 - 50; button.y = bg.height / 2 - 47; 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.createAsset('dot', 'Dot Image', 0.5, 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 - 80; self.addChild(dotContainer); var coinSprite = self.createAsset('coinSprite', 'Coin Sprite', 0, 0.5); coinSprite.x = text.x - 2; coinSprite.y = text.y + 82; 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 = 1; self.update = function () { priceText.setText(Math.ceil(price)); for (var i = 0; i < dots.length; i++) { var d = dots[i]; console.log(upgradeType, upgrades[upgradeType]); upgrades[upgradeType] > i ? d.tint = 0x00ee00 : d.tint = 0x555555; } }; self.buy = function () { price *= 1.5; upgrades[upgradeType]++; self.update(); }; self.update(); }); var UpgradeContainer = Container.expand(function () { var self = Container.call(this); var upgradeBg = self.createAsset('upgradeBg', 'Upgrade Background', 0, 0); var h = LK.gui.height; var w = LK.gui.width; upgradeBg.width = w; upgradeBg.height = h; self.addChild(upgradeBg); var upgradeTitleText = new Text2('Upgrades', { size: 100, fill: '#000000', weight: 'bold' }); upgradeTitleText.anchor.set(0.5, 0.5); upgradeTitleText.x = w / 2; upgradeTitleText.y = 150; self.addChild(upgradeTitleText); var u1 = new UpgradeItemContainer('snowballs', 'Extra snowball', function () {}); self.addChild(u1); var u2 = new UpgradeItemContainer('strength', 'Strength', function () {}); self.addChild(u2); var u3 = new UpgradeItemContainer('gifts', 'Gift', function () { self.getGameInstance().placeGift(); }); self.addChild(u3); u1.y = 350; u2.y = u1.y + 320; u3.y = u2.y + 320; var playButton = self.createAsset('playButton', 'Play Button', 0.5, 0.5); pulsate(playButton, 1.05); playButton.x = w / 2; playButton.y = h - 350; self.addChild(playButton); playButton.on('down', function () { self.getGameInstance().startNextWave(); self.destroy(); }); }); var IntroScreen = Container.expand(function () { var self = Container.call(this); var upgradeBg = self.createAsset('introBg', 'Intro Screen Background', 0, 0); var h = LK.gui.height; var w = LK.gui.width; upgradeBg.width = w; upgradeBg.height = h; self.addChild(upgradeBg); var infoText = new Text2('Throw snowballs at kids to save Christmas!', { size: 60, fill: '#ffffff', weight: 700, align: 'center' }); infoText.anchor.set(0.5, 0.5); infoText.x = w / 2; infoText.y = 120; self.addChild(infoText); var playButton = self.createAsset('playButton', 'Play Button', 0.5, 0.5); playButton.x = w / 2; playButton.y = h - 250; var playButton2 = self.createAsset('playButton', 'Play Button', 0.5, 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.removeChild(self); self.destroy(); self.getGameInstance().startNextWave(); }); pulsate(playButton2, 1.1); pulsate(playButton, 1.05); }); var WaveCounterText = Container.expand(function (level) { var self = Container.call(this); var text = new Text2('Wave ' + level, { size: 150, weight: 700, fill: "#005500" }); text.anchor.set(.5, .5); text.x = 2048 / 2; 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 Wallet = Container.expand(function () { var self = Container.call(this); self.setCoinText = function (coinCount) { self.coinText.setText(coinCount.toString()); }; var walletBackground = self.createAsset('walletBg', 'Wallet Background', .5, .5); var walletForeground = self.createAsset('walletFg', 'Wallet Foreground', 1, .5); walletForeground.scale.x = walletForeground.scale.y = .7; self.init = function () { self.x = 1418 - walletBackground.width / 2; self.y = 110; self.coinText = new Text2('0', { size: 70, 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.addChildAt(self, LK.gui.children.length); }; }); var Coin = Container.expand(function () { var self = Container.call(this); var coinGraphics = self.createAsset('coin', 'Coin Graphics', .5, .5); self.init = function () { self.x = Math.random() * (2048 - self.width) + self.width / 2; self.y = Math.random() * (2732 - self.height) + self.height / 2; self.init = function (addBelow) { self.x = Math.random() * (2048 - self.width) + self.width / 2; self.y = Math.random() * (2732 - self.height) + self.height / 2; if (addBelow) { LK.stage.addChildAt(self, 0); } else { LK.stage.addChild(self); } allCoins.push(self); var gameInstance = self.getGameInstance(); if (gameInstance && gameInstance.wallet) { gameInstance.wallet.setCoinText(allCoins.length); } }; allCoins.push(self); var gameInstance = self.getGameInstance(); if (gameInstance && gameInstance.wallet) { gameInstance.wallet.setCoinText(allCoins.length); } var gameInstance = self.getGameInstance(); if (gameInstance) { gameInstance.updateCoinDisplay(); } }; }); var Shadow = Container.expand(function () { var self = Container.call(this); var shadowGraphics = self.createAsset('shadow', 'Shadow Graphics', .5, .5); self.follow = function (target) { self.x = target.x; self.y = target.y + 50; 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 / scale; }; }); var Aim = Container.expand(function () { var self = Container.call(this); var aimGraphics = self.createAsset('aim', 'Aim Graphics', .5, .5); }); var ParticleSplash = Container.expand(function () { var self = Container.call(this); var particleSplashGraphics = self.createAsset('particleSplash', 'Particle Splash Graphics', .5, .5); var randomScale = 0.5 + Math.random() * 0.5; self.scale.x = randomScale; self.scale.y = randomScale; self.directionX = Math.random() * 2 - 1; self.directionY = Math.random() * 2 - 1; self.animate = function () { self.alpha -= 0.01; self.x += self.directionX; self.y += self.directionY; if (self.alpha <= 0) { self.destroy(); } }; }); var Snowball = Container.expand(function () { var self = Container.call(this); var snowballGraphics = self.createAsset('snowball', 'Snowball Graphics', .5, .5); self.speed = -5; self.speedX = 0; self.speedY = 0; self.totalDistance = 0; self.rotationAjd = (Math.random() - 1) * 0.05; self.move = function () { 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; if (percentFromHalf > 1.1) { self.shouldBeDestroyed = true; } else { var scaleAdj = 2 - percentFromHalf * 2; self.scale.x = 1 + scaleAdj; self.scale.y = 1 + scaleAdj; self.rotation += self.rotationAjd; self.mayHit = scaleAdj < 0.8; self.x += self.speedX; self.y += self.speedY; 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); LK.stage.addChild(self.shadow); LK.stage.addChild(self); }; }); var ZombieKid = Container.expand(function () { var self = Container.call(this); var zombieKidGraphics = self.createAsset('zombieKid', 'Zombie Kid Graphics', .5, 0.8); self.speed = Math.random() * 2 + 1; self.hasGift = false; self.pickedUpGift = null; self.findNewTarget = function () { var availableGifts = []; if (this.parent) { availableGifts = this.parent.children.filter(function (child) { return child instanceof ChristmasGift && !child.isDestroyed && !child.hasBeenPickedUp; }); } if (availableGifts.length > 0) { var randomIndex = Math.floor(Math.random() * availableGifts.length); this.targetGift = availableGifts[randomIndex]; } }; self.move = function () { if (!self.hasGift) { if (self.targetGift) { var dx = self.targetGift.x - self.x; var dy = self.targetGift.y - self.y; } var angle = Math.atan2(dy, dx); self.x += Math.cos(angle) * self.speed; self.y += Math.sin(angle) * self.speed; 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.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; } self.y -= self.speed; if (self.pickedUpGift) { self.pickedUpGift.x = self.x; self.pickedUpGift.y = self.y + 30; self.pickedUpGift.hasBeenPickedUp = true; } } }; }); var Santa = Container.expand(function () { var self = Container.call(this); var santaGraphics = self.createAsset('santa', 'Santa Graphics', .5, .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, 'Christmas Gifts Graphics', 0.5, 1); self.x = Math.random() * 1536 + 256; self.y = Math.random() * 1532 + 500; }); var ProgressBar = Container.expand(function () { var self = Container.call(this); var progressBarGraphics = self.createAsset('progressBar2', 'Progress Bar Graphics', 0.5, 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.addChild(self); }; self.alpha = 0.45; self.maxScale = LK.gui.width / 100; self.scale.x = self.maxScale; self.height = 45; self.init(); }); var snowballUpgrades = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; var baseStrength = 1; var upgrades = { snowballs: 0, strength: 0, gifts: 0 }; function upgrade(type) { console.log("upgrade", type); } 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; } }); } ; var allCoins = []; Container.prototype.getGameInstance = function () { var currentParent = this.parent; while (currentParent) { if (currentParent instanceof Game) { return currentParent; } currentParent = currentParent.parent; } if (currentParent === LK.stage) { return LK.stage.children.find(function (child) { return child instanceof Game; }); } return LK.stage.children.find(function (child) { return child instanceof Game; }); }; var currentLevel = 0; var levels = [{ numZombieKids: 10, coinFrequency: 0.1, zombieKidSpeed: 2 }, { numZombieKids: 15, coinFrequency: 0.15, zombieKidSpeed: 2.5 }, { numZombieKids: 20, coinFrequency: 0.2, zombieKidSpeed: 3 }]; var Game = Container.expand(function () { var self = Container.call(this); LK.setInterval(function () { if (Math.random() < 0.98) return; var coin = new Coin(); coin.init(true); }, 100); self.showUpgradeContainer = function () { var upgradeContainer = new UpgradeContainer(); LK.gui.addChild(upgradeContainer); }; var introScreen = new IntroScreen(); LK.gui.addChild(introScreen); self.progressBar = new ProgressBar(); self.zombieKids = []; self.spawnZombieKids = function () { self.christmasGifts = self.christmasGifts || []; for (var i = 0; i < self.numZombieKids; i++) { var newZombieKid = new ZombieKid(); newZombieKid.speed = self.zombieKidSpeed; newZombieKid.x = Math.random() * (2048 - newZombieKid.width); newZombieKid.y = 0; self.zombieKids.push(newZombieKid); self.addChild(newZombieKid); } }; self.startNextWave = function () { console.log("Start level", currentLevel); self.wallet.visible = true; if (currentLevel < levels.length) { var level = levels[currentLevel]; self.numZombieKids = level.numZombieKids; self.coinFrequency = level.coinFrequency; self.zombieKidSpeed = level.zombieKidSpeed; self.spawnZombieKids(); currentLevel++; var waveCounterTxt = new WaveCounterText(currentLevel); self.addChild(waveCounterTxt); self.waveInProgress = true; } else { LK.showGameOver(); } }; var background = self.createAsset('background', 'Full Screen Background', 0, 0); background.width = 2048; background.height = 2732; self.isThrowing = false; self.addChildAt(background, 0); var santa = self.addChild(new Santa()); santa.x = 2048 / 2; santa.y = 2732 - santa.height - 2732 / 20; self.christmasGifts = self.christmasGifts || []; var placedGifts = 0; var tries = 0; self.placeGift = function () { var gift = new ChristmasGift(); pulsate(gift, 1.03, 0.002); var intersects = false; for (var j = 0; j < self.christmasGifts.length; j++) { if (gift === self.christmasGifts[j]) continue; if (Math.abs(gift.x - self.christmasGifts[j].x) < 150 && Math.abs(gift.y - self.christmasGifts[j].y) < 150) intersects = true; } if (!intersects) { self.christmasGifts.push(gift); self.addChild(gift); placedGifts++; this.giftCounterTxt.setText('Gifts: ' + self.christmasGifts.length); } }; self.giftCounterTxt = new Text2('Gifts: 10', { size: 100, fill: "#000000" }); while (placedGifts < 10) { tries++; if (tries > 1000) break; self.placeGift(); } var scoreTxt = new Text2('0', { size: 150, fill: "#000000" }); var coinCounterTxt = new Text2('0', { size: 100, fill: "#000000" }); self.wallet = new Wallet(); self.wallet.init(); self.wallet.visible = false; coinCounterTxt.x = 2048 - coinCounterTxt.width / 2; coinCounterTxt.y = 100; coinCounterTxt.anchor.set(0.5, 0); LK.gui.addChild(coinCounterTxt); self.updateCoinDisplay = function () { coinCounterTxt.setText('' + allCoins.length.toString()); }; self.updateCoinDisplay(); self.giftCounterTxt.anchor.set(.5, 0); self.giftCounterTxt.y = 1710; LK.gui.topCenter.addChild(self.giftCounterTxt); self.giftCounterTxt.setText('Gifts left: ' + self.christmasGifts.length); scoreTxt.anchor.set(.5, 0); LK.gui.topCenter.addChild(scoreTxt); self.updateScoreDisplay = function () { scoreTxt.setText(LK.getScore().toString()); }; self.updateScoreDisplay(); var snowballs = []; var touchStartTime = 0; stage.on('down', function (obj) { touchStartTime = LK.ticks; isThrowing = true; var event = obj.event; var pos = event.getLocalPosition(self); santa.baseRotation = Math.atan2(pos.y - santa.y, pos.x - santa.x) + Math.PI * 0.6; self.aimPosition = pos; var aim = new Aim(); self.currentAim = aim; aim.x = pos.x; aim.y = pos.y; var progress = 0; aim.scale.x = aim.scale.y = 0.5 + progress * 0.5; self.addChild(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); }); stage.on('up', function (obj) { if (self.aim) { self.aim.destroy(); self.aim = null; } self.progressBar.updateProgress(0); santa.rotation = santa.baseRotation; isThrowing = false; if (snowballs.length < 3 && self.aimPosition) { var newSnowball = new Snowball(self.currentAim); newSnowball.x = santa.x + 120; ; newSnowball.y = santa.y; newSnowball.startX = santa.x + 120; newSnowball.startY = santa.y; newSnowball.targetX = self.aimPosition.x; newSnowball.targetY = self.aimPosition.y; newSnowball.init(); var dx = newSnowball.targetX - newSnowball.x; var dy = newSnowball.targetY - newSnowball.y; var distance = Math.sqrt(dx * dx + dy * dy); var throwSpeed = 10; var touchDuration = LK.ticks - touchStartTime; var speedMultiplier = Math.min(touchDuration / 30, 10) * throwSpeed; newSnowball.speedMultiplier = speedMultiplier; newSnowball.speedX = -dx / distance * newSnowball.speed * speedMultiplier; newSnowball.speedY = -Math.abs(dy / distance * newSnowball.speed) * speedMultiplier; snowballs.push(newSnowball); self.aimPosition = null; } self.currentAim = null; }); LK.on('tick', function () { var zombieKids = self.zombieKids; if (touchStartTime > 0 && isThrowing) { var progress = Math.min((LK.ticks - touchStartTime) / 30, 1); self.progressBar.updateProgress(progress); santa.rotation = santa.baseRotation + progress * Math.PI * 2 / 10; if (self.aim) { self.aim.scale.x = self.aim.scale.y = 0.5 + progressBarGraphics.scale.x * 0.5; } if (self.currentAim) { self.currentAim.scale.x = 0.2 + progress; self.currentAim.scale.y = 0.2 + progress; } } for (var a = snowballs.length - 1; a >= 0; a--) { if (snowballs[a]) { snowballs[a].move(); for (var b = self.zombieKids.length - 1; b >= 0; b--) { if (zombieKids[b] && snowballs[a] && snowballs[a].intersects(zombieKids[b]) && snowballs[a].mayHit) { LK.setScore(LK.getScore() + 1); self.updateScoreDisplay(); for (var i = 0; i < 10; i++) { var particleSplash = new ParticleSplash(); particleSplash.x = snowballs[a].x; particleSplash.y = snowballs[a].y; particleSplash.directionX *= snowballs[a].speedY; particleSplash.directionY *= snowballs[a].speedY; self.addChild(particleSplash); } if (zombieKids[b].hasGift) { var droppedGift = zombieKids[b].pickedUpGift; droppedGift.x = zombieKids[b].x; droppedGift.y = zombieKids[b].y; droppedGift.hasBeenDropped = true; droppedGift.hasBeenPickedUp = false; } zombieKids[b].destroy(); zombieKids.splice(b, 1); if (snowballs[a].aim) snowballs[a].aim.destroy(); if (snowballs[a].shadow) snowballs[a].shadow.destroy(); snowballs[a].destroy(); snowballs[a].shadow.destroy(); snowballs.splice(a, 1); break; } for (var k = 0; k < allCoins.length; k++) { if (snowballs[a] && snowballs[a].intersects(allCoins[k])) { LK.setScore(LK.getScore() + 1); self.updateScoreDisplay(); allCoins[k].destroy(); self.updateCoinDisplay(); if (snowballs[a].aim) snowballs[a].aim.destroy(); if (snowballs[a].shadow) snowballs[a].shadow.destroy(); snowballs[a].destroy(); snowballs.splice(a, 1); } } } if (snowballs[a] && (snowballs[a].y < -50 || snowballs[a].shouldBeDestroyed)) { snowballs[a].destroy(); snowballs[a].shadow.destroy(); snowballs.splice(a, 1); } } } if (self.zombieKids.length === 0 && self.waveInProgress && currentLevel > 0) { self.waveInProgress = false; LK.setTimeout(function () { self.showUpgradeContainer(); }, 1000); } for (var b = self.zombieKids.length - 1; b >= 0; b--) { console.log(zombieKids.length); if (zombieKids[b]) { zombieKids[b].move(); } } for (var c = self.children.length - 1; c >= 0; c--) { if (self.children[c] instanceof ParticleSplash) { self.children[c].animate(); } } for (var j = 0; j < self.christmasGifts.length; j++) { self.christmasGifts[j].offScreenHandler(); if (self.christmasGifts[j].flaggedForRemoval) { self.christmasGifts[j].owner.hasGift = false; self.christmasGifts[j].owner.targetGift = false; self.christmasGifts[j].destroy(); self.christmasGifts.splice(j, 1); self.giftCounterTxt.setText('Gifts left: ' + self.christmasGifts.length); if (self.christmasGifts.length === 0) LK.showGameOver(); } } }); });
var UpgradeItemContainer = Container.expand(function (upgradeType, labelText, onClickCallback) {
var self = Container.call(this);
var bg = self.createAsset('upgradeItemBg', 'Upgrade Item Background', 0.5, 0.5);
bg.width = LK.gui.width * 0.6;
bg.height = 245;
bg.x = LK.gui.width / 2;
bg.y = 75;
self.addChild(bg);
var text = new Text2(labelText, {
size: 50,
fill: '#006600',
weight: 'bold'
});
text.anchor.set(0, 0.5);
text.x = LK.gui.width / 2 - bg.width / 2 + 50;
text.y = 10;
var priceText = new Text2('0', {
size: 50,
fill: '#000000',
weight: 'bold',
align: 'center'
});
priceText.anchor.set(0, 0.5);
self.addChild(text);
self.addChild(priceText);
var button = self.createAsset('upgradeButton', 'Upgrade Button', 0.5, 0.5);
button.x = LK.gui.width / 2 + bg.width / 2 - 50;
button.y = bg.height / 2 - 47;
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.createAsset('dot', 'Dot Image', 0.5, 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 - 80;
self.addChild(dotContainer);
var coinSprite = self.createAsset('coinSprite', 'Coin Sprite', 0, 0.5);
coinSprite.x = text.x - 2;
coinSprite.y = text.y + 82;
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 = 1;
self.update = function () {
priceText.setText(Math.ceil(price));
for (var i = 0; i < dots.length; i++) {
var d = dots[i];
console.log(upgradeType, upgrades[upgradeType]);
upgrades[upgradeType] > i ? d.tint = 0x00ee00 : d.tint = 0x555555;
}
};
self.buy = function () {
price *= 1.5;
upgrades[upgradeType]++;
self.update();
};
self.update();
});
var UpgradeContainer = Container.expand(function () {
var self = Container.call(this);
var upgradeBg = self.createAsset('upgradeBg', 'Upgrade Background', 0, 0);
var h = LK.gui.height;
var w = LK.gui.width;
upgradeBg.width = w;
upgradeBg.height = h;
self.addChild(upgradeBg);
var upgradeTitleText = new Text2('Upgrades', {
size: 100,
fill: '#000000',
weight: 'bold'
});
upgradeTitleText.anchor.set(0.5, 0.5);
upgradeTitleText.x = w / 2;
upgradeTitleText.y = 150;
self.addChild(upgradeTitleText);
var u1 = new UpgradeItemContainer('snowballs', 'Extra snowball', function () {});
self.addChild(u1);
var u2 = new UpgradeItemContainer('strength', 'Strength', function () {});
self.addChild(u2);
var u3 = new UpgradeItemContainer('gifts', 'Gift', function () {
self.getGameInstance().placeGift();
});
self.addChild(u3);
u1.y = 350;
u2.y = u1.y + 320;
u3.y = u2.y + 320;
var playButton = self.createAsset('playButton', 'Play Button', 0.5, 0.5);
pulsate(playButton, 1.05);
playButton.x = w / 2;
playButton.y = h - 350;
self.addChild(playButton);
playButton.on('down', function () {
self.getGameInstance().startNextWave();
self.destroy();
});
});
var IntroScreen = Container.expand(function () {
var self = Container.call(this);
var upgradeBg = self.createAsset('introBg', 'Intro Screen Background', 0, 0);
var h = LK.gui.height;
var w = LK.gui.width;
upgradeBg.width = w;
upgradeBg.height = h;
self.addChild(upgradeBg);
var infoText = new Text2('Throw snowballs at kids to save Christmas!', {
size: 60,
fill: '#ffffff',
weight: 700,
align: 'center'
});
infoText.anchor.set(0.5, 0.5);
infoText.x = w / 2;
infoText.y = 120;
self.addChild(infoText);
var playButton = self.createAsset('playButton', 'Play Button', 0.5, 0.5);
playButton.x = w / 2;
playButton.y = h - 250;
var playButton2 = self.createAsset('playButton', 'Play Button', 0.5, 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.removeChild(self);
self.destroy();
self.getGameInstance().startNextWave();
});
pulsate(playButton2, 1.1);
pulsate(playButton, 1.05);
});
var WaveCounterText = Container.expand(function (level) {
var self = Container.call(this);
var text = new Text2('Wave ' + level, {
size: 150,
weight: 700,
fill: "#005500"
});
text.anchor.set(.5, .5);
text.x = 2048 / 2;
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 Wallet = Container.expand(function () {
var self = Container.call(this);
self.setCoinText = function (coinCount) {
self.coinText.setText(coinCount.toString());
};
var walletBackground = self.createAsset('walletBg', 'Wallet Background', .5, .5);
var walletForeground = self.createAsset('walletFg', 'Wallet Foreground', 1, .5);
walletForeground.scale.x = walletForeground.scale.y = .7;
self.init = function () {
self.x = 1418 - walletBackground.width / 2;
self.y = 110;
self.coinText = new Text2('0', {
size: 70,
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.addChildAt(self, LK.gui.children.length);
};
});
var Coin = Container.expand(function () {
var self = Container.call(this);
var coinGraphics = self.createAsset('coin', 'Coin Graphics', .5, .5);
self.init = function () {
self.x = Math.random() * (2048 - self.width) + self.width / 2;
self.y = Math.random() * (2732 - self.height) + self.height / 2;
self.init = function (addBelow) {
self.x = Math.random() * (2048 - self.width) + self.width / 2;
self.y = Math.random() * (2732 - self.height) + self.height / 2;
if (addBelow) {
LK.stage.addChildAt(self, 0);
} else {
LK.stage.addChild(self);
}
allCoins.push(self);
var gameInstance = self.getGameInstance();
if (gameInstance && gameInstance.wallet) {
gameInstance.wallet.setCoinText(allCoins.length);
}
};
allCoins.push(self);
var gameInstance = self.getGameInstance();
if (gameInstance && gameInstance.wallet) {
gameInstance.wallet.setCoinText(allCoins.length);
}
var gameInstance = self.getGameInstance();
if (gameInstance) {
gameInstance.updateCoinDisplay();
}
};
});
var Shadow = Container.expand(function () {
var self = Container.call(this);
var shadowGraphics = self.createAsset('shadow', 'Shadow Graphics', .5, .5);
self.follow = function (target) {
self.x = target.x;
self.y = target.y + 50;
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 / scale;
};
});
var Aim = Container.expand(function () {
var self = Container.call(this);
var aimGraphics = self.createAsset('aim', 'Aim Graphics', .5, .5);
});
var ParticleSplash = Container.expand(function () {
var self = Container.call(this);
var particleSplashGraphics = self.createAsset('particleSplash', 'Particle Splash Graphics', .5, .5);
var randomScale = 0.5 + Math.random() * 0.5;
self.scale.x = randomScale;
self.scale.y = randomScale;
self.directionX = Math.random() * 2 - 1;
self.directionY = Math.random() * 2 - 1;
self.animate = function () {
self.alpha -= 0.01;
self.x += self.directionX;
self.y += self.directionY;
if (self.alpha <= 0) {
self.destroy();
}
};
});
var Snowball = Container.expand(function () {
var self = Container.call(this);
var snowballGraphics = self.createAsset('snowball', 'Snowball Graphics', .5, .5);
self.speed = -5;
self.speedX = 0;
self.speedY = 0;
self.totalDistance = 0;
self.rotationAjd = (Math.random() - 1) * 0.05;
self.move = function () {
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;
if (percentFromHalf > 1.1) {
self.shouldBeDestroyed = true;
} else {
var scaleAdj = 2 - percentFromHalf * 2;
self.scale.x = 1 + scaleAdj;
self.scale.y = 1 + scaleAdj;
self.rotation += self.rotationAjd;
self.mayHit = scaleAdj < 0.8;
self.x += self.speedX;
self.y += self.speedY;
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);
LK.stage.addChild(self.shadow);
LK.stage.addChild(self);
};
});
var ZombieKid = Container.expand(function () {
var self = Container.call(this);
var zombieKidGraphics = self.createAsset('zombieKid', 'Zombie Kid Graphics', .5, 0.8);
self.speed = Math.random() * 2 + 1;
self.hasGift = false;
self.pickedUpGift = null;
self.findNewTarget = function () {
var availableGifts = [];
if (this.parent) {
availableGifts = this.parent.children.filter(function (child) {
return child instanceof ChristmasGift && !child.isDestroyed && !child.hasBeenPickedUp;
});
}
if (availableGifts.length > 0) {
var randomIndex = Math.floor(Math.random() * availableGifts.length);
this.targetGift = availableGifts[randomIndex];
}
};
self.move = function () {
if (!self.hasGift) {
if (self.targetGift) {
var dx = self.targetGift.x - self.x;
var dy = self.targetGift.y - self.y;
}
var angle = Math.atan2(dy, dx);
self.x += Math.cos(angle) * self.speed;
self.y += Math.sin(angle) * self.speed;
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.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;
}
self.y -= self.speed;
if (self.pickedUpGift) {
self.pickedUpGift.x = self.x;
self.pickedUpGift.y = self.y + 30;
self.pickedUpGift.hasBeenPickedUp = true;
}
}
};
});
var Santa = Container.expand(function () {
var self = Container.call(this);
var santaGraphics = self.createAsset('santa', 'Santa Graphics', .5, .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, 'Christmas Gifts Graphics', 0.5, 1);
self.x = Math.random() * 1536 + 256;
self.y = Math.random() * 1532 + 500;
});
var ProgressBar = Container.expand(function () {
var self = Container.call(this);
var progressBarGraphics = self.createAsset('progressBar2', 'Progress Bar Graphics', 0.5, 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.addChild(self);
};
self.alpha = 0.45;
self.maxScale = LK.gui.width / 100;
self.scale.x = self.maxScale;
self.height = 45;
self.init();
});
var snowballUpgrades = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
var baseStrength = 1;
var upgrades = {
snowballs: 0,
strength: 0,
gifts: 0
};
function upgrade(type) {
console.log("upgrade", type);
}
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;
}
});
}
;
var allCoins = [];
Container.prototype.getGameInstance = function () {
var currentParent = this.parent;
while (currentParent) {
if (currentParent instanceof Game) {
return currentParent;
}
currentParent = currentParent.parent;
}
if (currentParent === LK.stage) {
return LK.stage.children.find(function (child) {
return child instanceof Game;
});
}
return LK.stage.children.find(function (child) {
return child instanceof Game;
});
};
var currentLevel = 0;
var levels = [{
numZombieKids: 10,
coinFrequency: 0.1,
zombieKidSpeed: 2
}, {
numZombieKids: 15,
coinFrequency: 0.15,
zombieKidSpeed: 2.5
}, {
numZombieKids: 20,
coinFrequency: 0.2,
zombieKidSpeed: 3
}];
var Game = Container.expand(function () {
var self = Container.call(this);
LK.setInterval(function () {
if (Math.random() < 0.98) return;
var coin = new Coin();
coin.init(true);
}, 100);
self.showUpgradeContainer = function () {
var upgradeContainer = new UpgradeContainer();
LK.gui.addChild(upgradeContainer);
};
var introScreen = new IntroScreen();
LK.gui.addChild(introScreen);
self.progressBar = new ProgressBar();
self.zombieKids = [];
self.spawnZombieKids = function () {
self.christmasGifts = self.christmasGifts || [];
for (var i = 0; i < self.numZombieKids; i++) {
var newZombieKid = new ZombieKid();
newZombieKid.speed = self.zombieKidSpeed;
newZombieKid.x = Math.random() * (2048 - newZombieKid.width);
newZombieKid.y = 0;
self.zombieKids.push(newZombieKid);
self.addChild(newZombieKid);
}
};
self.startNextWave = function () {
console.log("Start level", currentLevel);
self.wallet.visible = true;
if (currentLevel < levels.length) {
var level = levels[currentLevel];
self.numZombieKids = level.numZombieKids;
self.coinFrequency = level.coinFrequency;
self.zombieKidSpeed = level.zombieKidSpeed;
self.spawnZombieKids();
currentLevel++;
var waveCounterTxt = new WaveCounterText(currentLevel);
self.addChild(waveCounterTxt);
self.waveInProgress = true;
} else {
LK.showGameOver();
}
};
var background = self.createAsset('background', 'Full Screen Background', 0, 0);
background.width = 2048;
background.height = 2732;
self.isThrowing = false;
self.addChildAt(background, 0);
var santa = self.addChild(new Santa());
santa.x = 2048 / 2;
santa.y = 2732 - santa.height - 2732 / 20;
self.christmasGifts = self.christmasGifts || [];
var placedGifts = 0;
var tries = 0;
self.placeGift = function () {
var gift = new ChristmasGift();
pulsate(gift, 1.03, 0.002);
var intersects = false;
for (var j = 0; j < self.christmasGifts.length; j++) {
if (gift === self.christmasGifts[j]) continue;
if (Math.abs(gift.x - self.christmasGifts[j].x) < 150 && Math.abs(gift.y - self.christmasGifts[j].y) < 150) intersects = true;
}
if (!intersects) {
self.christmasGifts.push(gift);
self.addChild(gift);
placedGifts++;
this.giftCounterTxt.setText('Gifts: ' + self.christmasGifts.length);
}
};
self.giftCounterTxt = new Text2('Gifts: 10', {
size: 100,
fill: "#000000"
});
while (placedGifts < 10) {
tries++;
if (tries > 1000) break;
self.placeGift();
}
var scoreTxt = new Text2('0', {
size: 150,
fill: "#000000"
});
var coinCounterTxt = new Text2('0', {
size: 100,
fill: "#000000"
});
self.wallet = new Wallet();
self.wallet.init();
self.wallet.visible = false;
coinCounterTxt.x = 2048 - coinCounterTxt.width / 2;
coinCounterTxt.y = 100;
coinCounterTxt.anchor.set(0.5, 0);
LK.gui.addChild(coinCounterTxt);
self.updateCoinDisplay = function () {
coinCounterTxt.setText('' + allCoins.length.toString());
};
self.updateCoinDisplay();
self.giftCounterTxt.anchor.set(.5, 0);
self.giftCounterTxt.y = 1710;
LK.gui.topCenter.addChild(self.giftCounterTxt);
self.giftCounterTxt.setText('Gifts left: ' + self.christmasGifts.length);
scoreTxt.anchor.set(.5, 0);
LK.gui.topCenter.addChild(scoreTxt);
self.updateScoreDisplay = function () {
scoreTxt.setText(LK.getScore().toString());
};
self.updateScoreDisplay();
var snowballs = [];
var touchStartTime = 0;
stage.on('down', function (obj) {
touchStartTime = LK.ticks;
isThrowing = true;
var event = obj.event;
var pos = event.getLocalPosition(self);
santa.baseRotation = Math.atan2(pos.y - santa.y, pos.x - santa.x) + Math.PI * 0.6;
self.aimPosition = pos;
var aim = new Aim();
self.currentAim = aim;
aim.x = pos.x;
aim.y = pos.y;
var progress = 0;
aim.scale.x = aim.scale.y = 0.5 + progress * 0.5;
self.addChild(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);
});
stage.on('up', function (obj) {
if (self.aim) {
self.aim.destroy();
self.aim = null;
}
self.progressBar.updateProgress(0);
santa.rotation = santa.baseRotation;
isThrowing = false;
if (snowballs.length < 3 && self.aimPosition) {
var newSnowball = new Snowball(self.currentAim);
newSnowball.x = santa.x + 120;
;
newSnowball.y = santa.y;
newSnowball.startX = santa.x + 120;
newSnowball.startY = santa.y;
newSnowball.targetX = self.aimPosition.x;
newSnowball.targetY = self.aimPosition.y;
newSnowball.init();
var dx = newSnowball.targetX - newSnowball.x;
var dy = newSnowball.targetY - newSnowball.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var throwSpeed = 10;
var touchDuration = LK.ticks - touchStartTime;
var speedMultiplier = Math.min(touchDuration / 30, 10) * throwSpeed;
newSnowball.speedMultiplier = speedMultiplier;
newSnowball.speedX = -dx / distance * newSnowball.speed * speedMultiplier;
newSnowball.speedY = -Math.abs(dy / distance * newSnowball.speed) * speedMultiplier;
snowballs.push(newSnowball);
self.aimPosition = null;
}
self.currentAim = null;
});
LK.on('tick', function () {
var zombieKids = self.zombieKids;
if (touchStartTime > 0 && isThrowing) {
var progress = Math.min((LK.ticks - touchStartTime) / 30, 1);
self.progressBar.updateProgress(progress);
santa.rotation = santa.baseRotation + progress * Math.PI * 2 / 10;
if (self.aim) {
self.aim.scale.x = self.aim.scale.y = 0.5 + progressBarGraphics.scale.x * 0.5;
}
if (self.currentAim) {
self.currentAim.scale.x = 0.2 + progress;
self.currentAim.scale.y = 0.2 + progress;
}
}
for (var a = snowballs.length - 1; a >= 0; a--) {
if (snowballs[a]) {
snowballs[a].move();
for (var b = self.zombieKids.length - 1; b >= 0; b--) {
if (zombieKids[b] && snowballs[a] && snowballs[a].intersects(zombieKids[b]) && snowballs[a].mayHit) {
LK.setScore(LK.getScore() + 1);
self.updateScoreDisplay();
for (var i = 0; i < 10; i++) {
var particleSplash = new ParticleSplash();
particleSplash.x = snowballs[a].x;
particleSplash.y = snowballs[a].y;
particleSplash.directionX *= snowballs[a].speedY;
particleSplash.directionY *= snowballs[a].speedY;
self.addChild(particleSplash);
}
if (zombieKids[b].hasGift) {
var droppedGift = zombieKids[b].pickedUpGift;
droppedGift.x = zombieKids[b].x;
droppedGift.y = zombieKids[b].y;
droppedGift.hasBeenDropped = true;
droppedGift.hasBeenPickedUp = false;
}
zombieKids[b].destroy();
zombieKids.splice(b, 1);
if (snowballs[a].aim) snowballs[a].aim.destroy();
if (snowballs[a].shadow) snowballs[a].shadow.destroy();
snowballs[a].destroy();
snowballs[a].shadow.destroy();
snowballs.splice(a, 1);
break;
}
for (var k = 0; k < allCoins.length; k++) {
if (snowballs[a] && snowballs[a].intersects(allCoins[k])) {
LK.setScore(LK.getScore() + 1);
self.updateScoreDisplay();
allCoins[k].destroy();
self.updateCoinDisplay();
if (snowballs[a].aim) snowballs[a].aim.destroy();
if (snowballs[a].shadow) snowballs[a].shadow.destroy();
snowballs[a].destroy();
snowballs.splice(a, 1);
}
}
}
if (snowballs[a] && (snowballs[a].y < -50 || snowballs[a].shouldBeDestroyed)) {
snowballs[a].destroy();
snowballs[a].shadow.destroy();
snowballs.splice(a, 1);
}
}
}
if (self.zombieKids.length === 0 && self.waveInProgress && currentLevel > 0) {
self.waveInProgress = false;
LK.setTimeout(function () {
self.showUpgradeContainer();
}, 1000);
}
for (var b = self.zombieKids.length - 1; b >= 0; b--) {
console.log(zombieKids.length);
if (zombieKids[b]) {
zombieKids[b].move();
}
}
for (var c = self.children.length - 1; c >= 0; c--) {
if (self.children[c] instanceof ParticleSplash) {
self.children[c].animate();
}
}
for (var j = 0; j < self.christmasGifts.length; j++) {
self.christmasGifts[j].offScreenHandler();
if (self.christmasGifts[j].flaggedForRemoval) {
self.christmasGifts[j].owner.hasGift = false;
self.christmasGifts[j].owner.targetGift = false;
self.christmasGifts[j].destroy();
self.christmasGifts.splice(j, 1);
self.giftCounterTxt.setText('Gifts left: ' + self.christmasGifts.length);
if (self.christmasGifts.length === 0) LK.showGameOver();
}
}
});
});
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.