User prompt
clean code
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'getChildByName')' in this line: 'var currentDisplayGraphic = gameInstance.presentTypeDisplay.getChildByName('displayGraphic');' Line Number: 203
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'children')' in this line: 'var currentDisplayGraphic = gameInstance.presentTypeDisplay.children[0];' Line Number: 203
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'presentTypeDisplay')' in this line: 'var currentDisplayGraphic = gameInstance.presentTypeDisplay.children[0];' Line Number: 204
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'presentTypeDisplay')' in this line: 'var currentDisplayGraphic = self.gameInstance.presentTypeDisplay.children[0];' Line Number: 203
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'presentTypeDisplay')' in this line: 'var currentDisplayGraphic = self.gameInstance.presentTypeDisplay.children[0];' Line Number: 202
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'presentDisplay')' in this line: 'var currentDisplayGraphic = self.gameInstance.presentDisplay.children[0];' Line Number: 202
User prompt
Fix Bug: 'TypeError: self.parent.getChildByName is not a function' in this line: 'var currentDisplayGraphic = self.parent.getChildByName('presentTypeDisplay').children[0];' Line Number: 202
User prompt
Fix Bug: 'TypeError: self.parent.parent.getChildByName is not a function' in this line: 'var currentDisplayGraphic = self.parent.parent.getChildByName('presentTypeDisplay').children[0];' Line Number: 202
User prompt
when a present is selected compare selection with displaygraphic. If both are the same type then log match else log missmatch
Code edit (3 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: self.parent.storePresentTypeDetails is not a function' in this line: 'self.parent.storePresentTypeDetails(self.type);' Line Number: 201
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'height')' in this line: 'if (self.y > mainContainer.height - self.height) {' Line Number: 229
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'width')' in this line: 'if (self.x > mainContainer.width - self.width) {' Line Number: 221
User prompt
when a present is clicked log present type in to a comparison array and remove present from screen
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'height')' in this line: 'if (self.y > mainContainer.height - self.height) {' Line Number: 230
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'width')' in this line: 'if (self.x > mainContainer.width - self.width) {' Line Number: 222
User prompt
when a present is clicked record present type and remove present from screen
User prompt
when a present is clicked record present type and remove present
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'removeLife')' in this line: 'self.parent.lifeCounter.removeLife();' Line Number: 266
User prompt
Fix Bug: 'Uncaught TypeError: Cannot set properties of null (setting 'currentPresentType')' in this line: 'self.parent.currentPresentType = presentTypes[presentTypeIndex];' Line Number: 183
User prompt
when present is clicked compare present type selected with present type dislayed. If they do not match then reduce live by 1
Code edit (8 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -83,8 +83,66 @@
presentSpeedFactor: 3.5,
bounceFactor: 0.8,
gravity: 0.2
}];
+var Present = Container.expand(function (type) {
+ var self = Container.call(this);
+ self.type = type;
+ self.vx = (Math.random() - 0.5) * 10;
+ self.vy = (Math.random() - 0.5) * 10;
+ self.rotationSpeed = (Math.random() - 0.5) * 0.2;
+ var presentGraphics = self.createAsset(type, type + ' Graphics', .5, .5);
+ self.interactive = true;
+ self.applyGravity = function () {
+ var level = LevelManager.getCurrentLevel() - 1;
+ var gravity = levelParameters[level].gravity;
+ self.vy += gravity;
+ };
+ 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 (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 (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 LifeCounter = Container.expand(function (initialLives) {
var self = Container.call(this);
self.refreshLifeDisplay = function () {
while (self.lifeIcons.length > self.lives) {
@@ -183,66 +241,8 @@
};
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.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 (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 (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;
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.