User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'addChild')' in this line: 'self.addChild(mainContainer);' Line Number: 57
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'x')' in this line: 'present.x = mainContainer.x + mainContainer.width / 2;' Line Number: 54
User prompt
add a bouncing ball. call it present. restrict its movement to within main container
User prompt
Do not remove snowflake code. For levels 1 to 2 create 2 new itemtypes. For levels 3 to 16 create addtional item type every 2 levels.
User prompt
For levels 1 to 2 create 2 itemtypes. For levels 3 to 16 create addtional item type every 2 levels. Keep snowflake code
User prompt
For levels 1 to 2 create 2 itemtypes. For levels 3 to 16 create addtional item type every 2 levels
Code edit (1 edits merged)
Please save this source code
User prompt
add snta sack to screen
User prompt
add santa toy sack image to bottom of screen
Code edit (1 edits merged)
Please save this source code
User prompt
add alpha to maincontainer background
Code edit (1 edits merged)
Please save this source code
User prompt
add main container to screen
User prompt
create main container that is equal to screen width 10% and screen height - 70%. Centralise on screen. Add white background image to container
User prompt
vary snowflake size by plus or minus 15%
User prompt
add a random speed to each snowflake drop rate
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
add level system for management of levels 1 to 16
User prompt
add alpha value to snowflakes
User prompt
add full screen background image
Code edit (1 edits merged)
Please save this source code
User prompt
correct code so snowflakes drop
User prompt
remove santa
User prompt
remove gift
===================================================================
--- original.js
+++ change.js
@@ -1,24 +1,14 @@
-var SpecialItem = Container.expand(function (level) {
- var self = Container.call(this);
- var specialItemGraphics = self.createAsset('specialItem' + level, 'Special Item Graphics', .5, .5);
- var sizeVariance = 0.5 + (level - 3) * 0.05;
- specialItemGraphics.scale.x = sizeVariance;
- specialItemGraphics.scale.y = sizeVariance;
- self.speed = 3 + (level - 3) * 0.2;
- self.move = function () {
- self.y += self.speed;
- };
-});
var Present = Container.expand(function () {
var self = Container.call(this);
- var presentGraphics = self.createAsset('present', 'Present Graphics', .5, .5);
- var sizeVariance = 0.5 + Math.random() * 0.5;
- presentGraphics.scale.x = sizeVariance;
- presentGraphics.scale.y = sizeVariance;
- self.speed = Math.random() * 2 + 1;
+ var presentGraphics = self.createAsset('present', 'Present Graphics', 0.5, 0.5);
+ self.vx = Math.random() * 4 - 2;
+ self.vy = Math.random() * 4 - 2;
self.move = function () {
- self.y += self.speed;
+ self.x += self.vx;
+ self.y += self.vy;
+ if (self.x < 50 || self.x > 1992) self.vx *= -1;
+ if (self.y < 300 || self.y > 2300) self.vy *= -1;
};
});
var LevelManager = Container.expand(function () {
var self = Container.call(this);
@@ -59,8 +49,16 @@
self.x = 2048 / 2;
self.y = 3200;
});
var Game = Container.expand(function () {
+ var present = new Present();
+ present.x = mainContainer.x + mainContainer.width / 2;
+ present.y = mainContainer.y + mainContainer.height / 2;
+ self.addChild(present);
+ LK.on('tick', function () {
+ present.move();
+ for (var i = 0; i < snowflakes.length; i++) {}
+ });
var self = Container.call(this);
var mainContainer = new MainContainer();
self.addChild(mainContainer);
var santaSack = new SantaSack();
@@ -86,25 +84,13 @@
}
}
}
if (LK.ticks % (60 - self.levelManager.currentLevel) == 0 && self.levelManager.currentLevel <= self.levelManager.maxLevel) {
- var newItem;
- if (self.levelManager.currentLevel <= 2) {
- var itemType = Math.floor(Math.random() * 2);
- if (itemType === 0) {
- newItem = new Snowflake();
- } else if (itemType === 1) {
- newItem = new Present();
- }
- } else if (self.levelManager.currentLevel % 2 === 1 && self.levelManager.currentLevel <= 16) {
- newItem = new SpecialItem(self.levelManager.currentLevel);
- } else {
- newItem = new Snowflake();
- }
- newItem.alpha = Math.random() * 0.5 + 0.5;
- newItem.x = Math.random() * 2048;
- newItem.y = 0;
- snowflakes.push(newItem);
- self.addChild(newItem);
+ var newSnowflake = new Snowflake();
+ newSnowflake.alpha = Math.random() * 0.5 + 0.5;
+ newSnowflake.x = Math.random() * 2048;
+ newSnowflake.y = 0;
+ snowflakes.push(newSnowflake);
+ self.addChild(newSnowflake);
}
});
});
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.