Code edit (1 edits merged)
Please save this source code
User prompt
Check the operation of the startdestruction timer to ensure it is functioning correctly so that bonus items are produced
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught TypeError: LK.getHighScore is not a function' in this line: 'var highScore = LK.getHighScore();' Line Number: 422
Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught TypeError: LK.getHighScore is not a function' in this line: 'var highScore = LK.getHighScore();' Line Number: 422
User prompt
add in to top left high score with text in same format as score text
Code edit (2 edits merged)
Please save this source code
User prompt
change level adjustment so that if level is above 15 the number of presents to create is set to 3
User prompt
change level adjustment so that if level is above 15 the number of presents to create remains at the level 15 number
Code edit (1 edits merged)
Please save this source code
User prompt
change level adjustment so that if level is above 15 stop reducing the number to create
Code edit (8 edits merged)
Please save this source code
User prompt
change level adjustment so for levels above 15 the quantity of presents does not reduce
Code edit (1 edits merged)
Please save this source code
Code edit (8 edits merged)
Please save this source code
User prompt
for levels above 10 reduce number of presents to create by 1 for every 2 levels
Code edit (1 edits merged)
Please save this source code
User prompt
When level changes also add in update to presentDisplay
User prompt
when level changes update presentDisplay to include new types based upon layer settings
Code edit (3 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught ReferenceError: Self is not defined' in this line: 'Self.addChild(self.nameText);' Line Number: 182
Code edit (3 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'height')' in this line: 'snowflake.y = Math.random() * mainContainer.height + mainContainer.y;' Line Number: 391
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'width')' in this line: 'snowflake.x = Math.random() * mainContainer.width + mainContainer.x;' Line Number: 390
var nameStorage = ['James', 'Mary', 'John', 'Patricia', 'Robert', 'Jennifer', 'Michael', 'Linda', 'William', 'Elizabeth', 'David', 'Barbara', 'Richard', 'Susan', 'Joseph', 'Jessica', 'Thomas', 'Sarah', 'Charles', 'Karen', 'Christopher', 'Nancy', 'Daniel', 'Lisa', 'Matthew', 'Margaret', 'Anthony', 'Betty', 'Mark', 'Sandra', 'Donald', 'Ashley', 'Steven', 'Kimberly', 'Paul', 'Emily', 'Andrew', 'Donna', 'Joshua', 'Michelle', 'Kenneth', 'Dorothy', 'Kevin', 'Carol', 'Brian', 'Amanda', 'George', 'Melissa', 'Edward', 'Stephanie']; var LevelManager = (function () { var currentLevel = 1; var maxLevel = 16; function getNextLevel() { currentLevel++; return currentLevel; } function resetLevels() { currentLevel = 1; } return { getNextLevel: getNextLevel, resetLevels: resetLevels, getCurrentLevel: function () { return currentLevel; } }; })(); var levelParameters = [{ presentSpeedFactor: 2, bounceFactor: 0.6, gravity: 0.1 }, { presentSpeedFactor: 2.2, bounceFactor: 0.65, gravity: 0.12 }, { presentSpeedFactor: 3, bounceFactor: 0.8, gravity: 0.2 }, { presentSpeedFactor: 4, bounceFactor: 0.8, gravity: 0.3 }, { presentSpeedFactor: 3.5, bounceFactor: 0.8, gravity: 0.2 }, { presentSpeedFactor: 3.5, bounceFactor: 0.8, gravity: 0.2 }, { presentSpeedFactor: 3.5, bounceFactor: 0.8, gravity: 0.2 }, { presentSpeedFactor: 3.5, bounceFactor: 0.8, gravity: 0.2 }, { presentSpeedFactor: 3.5, bounceFactor: 0.8, gravity: 0.2 }, { presentSpeedFactor: 3.5, bounceFactor: 0.8, gravity: 0.2 }, { presentSpeedFactor: 3.5, bounceFactor: 0.8, gravity: 0.2 }, { presentSpeedFactor: 3.5, bounceFactor: 0.8, gravity: 0.2 }, { presentSpeedFactor: 3.5, bounceFactor: 0.8, gravity: 0.2 }, { presentSpeedFactor: 3.5, bounceFactor: 0.8, gravity: 0.2 }, { presentSpeedFactor: 3.5, bounceFactor: 0.8, gravity: 0.2 }, { presentSpeedFactor: 3.5, bounceFactor: 0.8, gravity: 0.2 }]; var BonusItem = Container.expand(function () { var self = Container.call(this); self.speed = Math.random() * 7 + 1; self.rotationSpeed = (Math.random() - 0.5) * 0.1; self.bounce = Math.random() * 0.5 + 0.5; self.gravity = Math.random() * 0.1 + 0.05; self.vx = (Math.random() > 0.5 ? 1 : -1) * self.speed; self.vy = (Math.random() > 0.5 ? 1 : -1) * self.speed; BonusItem.prototype.startDestructionTimer = function (resetBonusTimerCallback) { var self = this; LK.setTimeout(function () { self.destroy(); resetBonusTimerCallback(); }, 15000); }; self.interactive = true; self.bonusAmount = Math.floor(Math.random() * (10 - 4 + 1)) + 4; var bonusGraphics = self.createAsset('bonusItem', 'Bonus Item Graphics', 0.5, 0.5); self.vx = (Math.random() > 0.5 ? 1 : -1) * (Math.random() * 2 + 1); self.on('down', function () { var gameInstance = this.parent.parent; gameInstance.score += self.bonusAmount; var scoreTxt = LK.gui.topCenter.children[0]; scoreTxt.setText(gameInstance.score); self.destroy(); gameInstance.resetBonusTimer(); }); self.move = function () { self.x += self.vx; self.y += self.vy; self.rotation += self.rotationSpeed; if (self.x < 0 || self.x > 2048) { self.vx = -self.vx * self.bounce; } if (self.y < 0 || self.y > 2732) { self.vy = -self.vy * self.bounce; } }; }); var LifeCounter = Container.expand(function (initialLives) { var self = Container.call(this); var lifeCounterBg = self.createAsset('lifeCounterBg', 'Life Counter Background', 0.5, 0.5); lifeCounterBg.x = 1710; lifeCounterBg.y = 190; lifeCounterBg.alpha = 0.2; self.addChild(lifeCounterBg); self.refreshLifeDisplay = function () { while (self.lifeIcons.length > self.lives) { var lifeToRemove = self.lifeIcons.pop(); lifeToRemove.destroy(); } for (var i = 0; i < self.lifeIcons.length; i++) { self.lifeIcons[i].x = 1948 - i * (self.lifeIcons[i].width + 10); } }; self.lives = initialLives; self.lifeIcons = []; for (var i = 0; i < self.lives; i++) { var lifeIcon = self.createAsset('lifeIcon', 'Life Icon', 0.5, 0.5); lifeIcon.x = 1948 - i * (lifeIcon.width + 10); lifeIcon.y = 250; self.lifeIcons.push(lifeIcon); self.addChild(lifeIcon); } self.removeLife = function () { if (self.lives > 0) { self.lives--; self.refreshLifeDisplay(); if (self.lives <= 0) { LK.showGameOver(); } } }; self.resetLives = function () { while (self.lifeIcons.length < initialLives) { var lifeIcon = self.createAsset('lifeIcon', 'Life Icon', 0.5, 0.5); lifeIcon.x = 1948 - (initialLives - self.lifeIcons.length - 1) * (lifeIcon.width + 10); lifeIcon.y = 250; self.lifeIcons.push(lifeIcon); self.addChild(lifeIcon); } self.lives = initialLives; }; }); var NameDisplay = Container.expand(function () { var self = Container.call(this); self.nameText = new Text2('', { size: 70, fill: "#000000", font: "Brush Script MT", anchor: { x: 0.0, y: 0.0 } }); self.nameText.x = 580; self.nameText.y = 120; LK.gui.addChild(self.nameText); self.updateName = function (name) { self.nameText.setText(name); }; }); var Background = Container.expand(function () { var self = Container.call(this); var background = self.createAsset('background', 'Background Image', 0, 0); background.width = 2048; background.height = 2732; self.addChild(background); }); var RotatingBackground = Container.expand(function () { var self = Container.call(this); var rotatingImage = self.createAsset('rotatingBackground', 'Rotating Background Image', 0.5, 0.5); rotatingImage.x = 2048 / 2; rotatingImage.y = 2732 / 2; self.addChild(rotatingImage); self.rotationSpeed = 0.0003; }); var presentTypeDisplay = Container.expand(function (nameDisplay) { var self = Container.call(this); var level = LevelManager.getCurrentLevel(); var presentTypesCount = 2; if (level >= 5 && level <= 8) { presentTypesCount = 4; } else if (level >= 9 && level <= 12) { presentTypesCount = 6; } else if (level >= 13) { presentTypesCount = 8; } var presentTypes = []; for (var i = 0; i < presentTypesCount; i++) { presentTypes.push('presentType' + (i + 1)); } self.currentPresentType = ''; self.getCurrentPresentType = function () { return self.currentPresentType; }; self.setRandomPresentTypeIndex = function () { var presentTypeIndex = Math.floor(Math.random() * presentTypesCount); self.currentPresentType = presentTypes[presentTypeIndex]; var displayGraphic = self.createAsset(self.currentPresentType, self.currentPresentType + ' Graphics', -0.2, -0.2); displayGraphic.scale.x = 1.5; displayGraphic.scale.y = 1.5; if (self.children.length > 0) { self.removeChildAt(0); } self.addChild(displayGraphic); var randomName = nameStorage[Math.floor(Math.random() * nameStorage.length)]; nameDisplay.updateName(randomName); }; self.setRandomPresentTypeIndex(); LK.setInterval(self.setRandomPresentTypeIndex, (Math.random() * (9 - 3) + 3) * 1000); }); var Present = Container.expand(function (type) { var self = Container.call(this); self.type = type; self.applyGravity = function () { var level = LevelManager.getCurrentLevel() - 1; var gravity = levelParameters[level].gravity; self.vy += gravity; }; var presentGraphics = self.createAsset(type, type + ' Graphics', .5, .5); self.vx = (Math.random() - 0.5) * 10; self.vy = (Math.random() - 0.5) * 10; self.rotationSpeed = (Math.random() - 0.5) * 0.2; self.interactive = true; self.on('down', function () { var gameInstance = this.parent.parent; var currentDisplayType = gameInstance.getCurrentPresentType(); if (self.type === currentDisplayType) { gameInstance.score++; var scoreTxt = LK.gui.topCenter.children[0]; scoreTxt.setText(gameInstance.score); var gameInstance = this.parent.parent; gameInstance.presents.splice(gameInstance.presents.indexOf(self), 1); self.destroy(); } else { gameInstance.lifeCounter.removeLife(); } }); self.move = function () { self.applyMovement(); }; self.applyMovement = function () { var levelIndex = LevelManager.getCurrentLevel() - 1; var level = levelParameters[Math.max(0, Math.min(levelIndex, levelParameters.length - 1))]; var presentSpeedFactor = level.presentSpeedFactor; self.x += self.vx * presentSpeedFactor; self.y += self.vy * presentSpeedFactor; self.rotation += self.rotationSpeed; self.applyBounds(); }; self.applyBounds = function () { var mainContainer = self.parent; if (self.x < 0) { self.x = 0; self.vx = -self.vx; } if (mainContainer && self.x > mainContainer.width - self.width) { self.x = mainContainer.width - self.width; self.vx = -self.vx; } if (self.y < 0) { self.y = 0; self.vy = -self.vy; } if (mainContainer && self.y > mainContainer.height - self.height) { self.y = mainContainer.height - self.height; self.vy = -self.vy; } }; self.bounce = function (collisionNormal) { self.applyBounce(collisionNormal); }; self.applyBounce = function (collisionNormal) { var level = LevelManager.getCurrentLevel() - 1; var bounceFactor = levelParameters[level].bounceFactor; if (collisionNormal.x !== 0) { self.vx = -self.vx * bounceFactor; } if (collisionNormal.y !== 0) { self.vy = -self.vy * bounceFactor; } }; }); var MainContainer = Container.expand(function () { var self = Container.call(this); self.width = 1942; self.height = 1900; self.x = 50; self.y = 400; var background = self.createAsset('whiteBackground', 'White Background', 0, 0); background.width = self.width; background.height = self.height; background.alpha = 0.01; self.addChild(background); }); var SantaSack = Container.expand(function () { var self = Container.call(this); var sackGraphics = self.createAsset('santaSack', 'Santa Toy Sack', 0.5, 1); self.x = 2048 / 2; self.y = 3200; }); var Game = Container.expand(function () { var self = Container.call(this); self.createBonusItem = function (mainContainer) { var bonusItem = new BonusItem(); bonusItem.x = Math.random() * (mainContainer.width - bonusItem.width) + mainContainer.x; bonusItem.y = Math.random() * (mainContainer.height - bonusItem.height) + mainContainer.y; mainContainer.addChild(bonusItem); bonusItem.startDestructionTimer(self.resetBonusTimer); self.bonusItem = bonusItem; }; self.resetBonusTimer = function () { LK.clearTimeout(bonusItemTimeout); bonusItemTimeout = LK.setTimeout(function () { self.createBonusItem(mainContainer); }, (Math.random() * (120 - 60) + 60) * 1000); }; var bonusItemTimeout = LK.setTimeout(function () { self.createBonusItem(mainContainer); }, (Math.random() * (120 - 60) + 60) * 1000); LK.on('tick', function () { if (self.bonusItem) { self.bonusItem.move(); } }); var self = Container.call(this); self.presents = []; self.levelManager = LevelManager; var rotatingBackground = new RotatingBackground(); self.addChild(rotatingBackground, 0); LK.on('tick', function () { rotatingBackground.children[0].rotation += rotatingBackground.rotationSpeed; }); var background = new Background(); self.addChildAt(background, 1); var santaSack = new SantaSack(); self.addChild(santaSack); var mainContainer = new MainContainer(); self.addChild(mainContainer); var scroll = self.createAsset('newImageAsset', 'Scroll', 0.5, 0.5); scroll.x = 950; scroll.y = 220; self.addChild(scroll); var nameDisplay = new NameDisplay(); var presentDisplay = self.addChild(new presentTypeDisplay(nameDisplay)); self.presentDisplay = presentDisplay; self.getCurrentPresentType = function () { return self.presentDisplay.getCurrentPresentType(); }; self.presentDisplayXAdjust = 450; self.presentDisplayYAdjust = 0; self.presentDisplay.x = self.presentDisplayXAdjust; self.presentDisplay.y = self.presentDisplayYAdjust; self.lifeCounter = new LifeCounter(5); self.addChild(self.lifeCounter); self.score = 0; var score = self.score; var scoreTxtXAdjust = 335; var scoreTxtYAdjust = 20; var scoreTxt = new Text2(score, { size: 80, fill: "#ffffff", weight: 800, dropShadow: true, dropShadowColor: '#ff0000', dropShadowAngle: Math.PI / 6, dropShadowDistance: 5 }); scoreTxt.x += scoreTxtXAdjust; scoreTxt.y += scoreTxtYAdjust; self.currentLevelTxt = new Text2('LV' + self.levelManager.getCurrentLevel(), { size: 80, fill: "#ffffff", weight: 800, dropShadow: true, dropShadowColor: '#ff0000', dropShadowAngle: Math.PI / 6, dropShadowDistance: 3 }); self.currentLevelTxt.anchor.set(0.5, 0); self.currentLevelTxt.x = 1315; self.currentLevelTxt.y = 30; LK.gui.addChild(self.currentLevelTxt); scoreTxt.anchor.set(.5, 0); LK.gui.topCenter.addChild(scoreTxt); var level = self.levelManager.getCurrentLevel(); var presentTypesCount = 2; if (level >= 5 && level <= 8) { presentTypesCount = 4; } else if (level >= 9 && level <= 12) { presentTypesCount = 6; } else if (level >= 13) { presentTypesCount = 8; } self.createPresents = function (presentTypesCount, mainContainer) { for (var i = 0; i < presentTypesCount; i++) { var numPresentsToCreate = 6; for (var j = 0; j < numPresentsToCreate; j++) { var presentType = new Present('presentType' + (i + 1)); presentType.x = Math.random() * (mainContainer.width - presentType.width); presentType.y = Math.random() * (mainContainer.height - presentType.height); mainContainer.addChild(presentType); self.presents.push(presentType); } } }; self.createPresents(presentTypesCount, mainContainer); LK.on('tick', function () { for (var i = self.presents.length - 1; i >= 0; i--) { var present = self.presents[i]; present.move(); if (present.y >= LK.stageContainer.height - present.height) { present.y = LK.stageContainer.height - present.height; present.vy = 0; present.destroy(); self.presents.splice(i, 1); } } if (self.presents.length === 0) { var newLevel = self.levelManager.getNextLevel(); self.currentLevelTxt.setText('LV ' + newLevel); self.presentDisplay.setRandomPresentTypeIndex(); var level = self.levelManager.getCurrentLevel(); var presentTypesCount = 2; if (level >= 5 && level <= 8) { presentTypesCount = 4; } else if (level >= 9 && level <= 12) { presentTypesCount = 6; } else if (level >= 13) { presentTypesCount = 8; } self.createPresents(presentTypesCount, mainContainer); } }); });
===================================================================
--- original.js
+++ change.js
@@ -444,8 +444,17 @@
if (self.presents.length === 0) {
var newLevel = self.levelManager.getNextLevel();
self.currentLevelTxt.setText('LV ' + newLevel);
self.presentDisplay.setRandomPresentTypeIndex();
- self.createPresents(self.presentDisplay.presentTypesCount, mainContainer);
+ var level = self.levelManager.getCurrentLevel();
+ var presentTypesCount = 2;
+ if (level >= 5 && level <= 8) {
+ presentTypesCount = 4;
+ } else if (level >= 9 && level <= 12) {
+ presentTypesCount = 6;
+ } else if (level >= 13) {
+ presentTypesCount = 8;
+ }
+ self.createPresents(presentTypesCount, mainContainer);
}
});
});
basic snowflake. white Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
open top of Santa's sack. wrapped presents with ribbons and box, vivid colours, candy canes Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
close up of a Snow covered roof, Winter scene, star lit night sky, brick chimbly on right hand side, Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
gift wrapped box, vivid colours. with bow on top Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
gift wrapped box, vivid colours. with bow on top 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.
stary night sky.dark blue. no land. only sky 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.
gift wrapped box, vivid colours. with bow on top 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. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
gift wrapped box, vivid colours. with bow on top 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.
gift wrapped box, vivid colours. with bow on top 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.
Candy cane, vivid colours. with bow on top 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.
gift wrapped box, vivid colours. with bow on top 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.
gift wrapped box, vivid colours. with bow on top 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.
old paper scroll, blank with no writing, Single Game Texture. In-Game asset. 2d. transparent Blank background. High contrast. No shadows. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
rudolf the red nose raindeer Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
gift wrapped box, bright colours. with bow on top Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. Single Game Texture.
gift wrapped box, bright light colours. with bow on top Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. Single Game Texture.
Santa's sleigh with a team of reindeer moving across a star light sky. 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.