User prompt
Fix Bug: 'TypeError: house.move is not a function' in this line: 'house.move();' Line Number: 161
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'createAsset')' in this line: 'var houseGraphics = self.createAsset('naughtyHouse', 'Naughty House Graphics', .5, 1);' Line Number: 36
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'createAsset')' in this line: 'var houseGraphics = self.createAsset('niceHouse', 'Nice House Graphics', .5, 1);' Line Number: 44
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'createAsset')' in this line: 'var houseGraphics = self.createAsset('naughtyHouse', 'Naughty House Graphics', .5, 1);' Line Number: 36
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'createAsset')' in this line: 'var houseGraphics = self.createAsset('naughtyHouse', 'Naughty House Graphics', .5, 1);' Line Number: 36
User prompt
Structure the code so that "house" is the main object, which controls movement. Houses can be happy, nice, naughty, or dark and they can change type when required but their movement remains the same.
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'addChild')' in this line: 'self.parent.addChild(happyHouse);' Line Number: 61
User prompt
If a nice house is hit by 3 presents, it turns into a happy house, but inherits the movement traits of its former self continuing to fall to the bottom of the screen before despawning
User prompt
When a nice house turns into a happy house, it should still continue to fall and then despawn exactly as it was when it was a nice house.
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'addChild')' in this line: 'self.parent.addChild(happyHouse);' Line Number: 56
User prompt
If a nice house it hit by 3 presents, the nice house turns into a happy house
User prompt
Although the nice house is disappearing, it's not actually despawning, leading to more happy houses being created. Each nice house can only turn into a single happy house.
User prompt
The interaction between presents, nice houses, and happy houses are not working as intended. The nice house should be hit by 3 presents, and then turn into a happy house. The happy house should continue to descend and should not interact with presents.
User prompt
Why are happy houses stopping? They should continue to descend
User prompt
Why are happy houses still interacting with presents?
User prompt
Presents pass through happy or dark houses without interacting with them in any way
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'createAsset')' in this line: 'var houseGraphics = self.createAsset('naughtyHouse', 'Naughty House Graphics', .5, 1);' Line Number: 35
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'createAsset')' in this line: 'var houseGraphics = self.createAsset('niceHouse', 'Nice House Graphics', .5, 1);' Line Number: 43
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'createAsset')' in this line: 'var houseGraphics = self.createAsset('niceHouse', 'Nice House Graphics', .5, 1);' Line Number: 43
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'createAsset')' in this line: 'var houseGraphics = self.createAsset('naughtyHouse', 'Naughty House Graphics', .5, 1);' Line Number: 35
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'createAsset')' in this line: 'var houseGraphics = self.createAsset('naughtyHouse', 'Naughty House Graphics', .5, 1);' Line Number: 35
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'createAsset')' in this line: 'var houseGraphics = self.createAsset('niceHouse', 'Nice House Graphics', .5, 1);' Line Number: 43
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'createAsset')' in this line: 'var houseGraphics = self.createAsset('naughtyHouse', 'Naughty House Graphics', .5, 1);' Line Number: 35
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'createAsset')' in this line: 'var houseGraphics = self.createAsset('naughtyHouse', 'Naughty House Graphics', .5, 1);' Line Number: 35
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'createAsset')' in this line: 'var houseGraphics = self.createAsset('niceHouse', 'Nice House Graphics', .5, 1);' Line Number: 44
var JoyMeter = Container.expand(function () { var self = Container.call(this); self.joy = 0; self.maxJoy = 8; var joyMeterGraphics = self.createAsset('joyMeter', 'Joy Meter Graphics', 0.5, 0); joyMeterGraphics.y = 50; self.addJoy = function (amount) { self.joy = Math.max(0, self.joy + amount); if (self.joy > self.maxJoy) { self.joy = self.maxJoy; } joyMeterGraphics.width = 2048 / self.maxJoy * self.joy; }; self.getJoy = function () { return self.joy; }; }); var Present = Container.expand(function () { var self = Container.call(this); var presentGraphics = self.createAsset('present', 'Present Graphics', .5, .5); self.speed = -10; self.move = function () { self.y += self.speed; }; }); var House = Container.expand(function () { var self = Container.call(this); self.speed = 2; self.move = function () { self.y += self.speed; }; }); var NaughtyHouse = House.expand(function () { var self = House.call(this); var houseGraphics = self.createAsset('naughtyHouse', 'Naughty House Graphics', .5, 1); houseGraphics.tint = 0xff0000; self.getNaughty = function () { return true; }; }); var NiceHouse = House.expand(function () { var self = House.call(this); var houseGraphics = self.createAsset('niceHouse', 'Nice House Graphics', .5, 1); var houseGraphics = self.createAsset('niceHouse', 'Nice House Graphics', .5, 1); houseGraphics.tint = 0x00ff00; self.hitCount = 0; self.getNaughty = function () { return false; }; self.incrementHits = function () { self.hitCount++; if (self.hitCount >= 3) { self.transformToHappy(); } }; self.transformToHappy = function () { var happyHouse = new HappyHouse(); happyHouse.x = self.x; happyHouse.y = self.y; LK.stage.addChild(happyHouse); self.destroy(); }; }); var DarkHouse = House.expand(function () { var self = House.call(this); var houseGraphics = self.createAsset('darkHouse', 'Dark House Graphics', .5, 1); houseGraphics.tint = 0x808080; self.getNaughty = function () { return false; }; }); var HappyHouse = House.expand(function () { var self = House.call(this); var houseGraphics = self.createAsset('happyHouse', 'Happy House Graphics', .5, 1); houseGraphics.tint = 0xffff00; self.getNaughty = function () { return false; }; }); var Santa = Container.expand(function () { var self = Container.call(this); var santaGraphics = self.createAsset('santa', 'Santa Graphics', .5, .5); self.targetPosition = null; self.moveSpeed = 5; self.move = function (position) { if (position) { self.targetPosition = position; } if (self.targetPosition) { var dx = self.targetPosition.x - self.x; var dy = self.targetPosition.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 1) { var angle = Math.atan2(dy, dx); var tentativeX = self.x + Math.cos(angle) * self.moveSpeed; var tentativeY = self.y + Math.sin(angle) * self.moveSpeed; self.x = tentativeX; if (tentativeY > 2732 - 2732 / 3) { self.y = tentativeY; } } else { if (self.targetPosition.y > 2732 - 2732 / 3) { self.x = self.targetPosition.x; self.y = self.targetPosition.y; } self.targetPosition = null; } } }; }); var Game = Container.expand(function () { var self = Container.call(this); var houses = []; var presents = []; var joyMeter = self.addChild(new JoyMeter()); LK.gui.topCenter.addChild(joyMeter); var santa = self.addChild(new Santa()); santa.x = 2048 / 2; santa.y = 2732 - 2732 * 0.1; var presentFireRate = 60; var presentFireCounter = 0; stage.on('down', function (obj) { var pos = obj.event.getLocalPosition(self); santa.move(pos); }); LK.on('tick', function () { santa.move(); if (presentFireCounter++ >= presentFireRate) { var present = new Present(); present.x = santa.x; present.y = santa.y; presents.push(present); self.addChild(present); presentFireCounter = 0; } if (Math.random() < 0.02) { var houseTypes = [NaughtyHouse, NiceHouse]; var randomHouseType = houseTypes[Math.floor(Math.random() * houseTypes.length)]; var house = new randomHouseType(); house.x = Math.random() * 2048; house.y = -house.height; houses.push(house); self.addChild(house); } for (var i = presents.length - 1; i >= 0; i--) { var present = presents[i]; present.move(); if (present.y < -present.height) { present.destroy(); presents.splice(i, 1); } else { for (var j = 0; j < houses.length; j++) { var house = houses[j]; if (present.intersects(house)) { if (house.getNaughty()) { joyMeter.addJoy(-3); var darkHouse = new DarkHouse(); darkHouse.x = house.x; darkHouse.y = house.y; self.addChild(darkHouse); house.destroy(); houses.splice(j, 1); houses.push(darkHouse); } else { joyMeter.addJoy(1); if (house instanceof NiceHouse) { house.incrementHits(); } } present.destroy(); presents.splice(i, 1); break; } } } for (var h = houses.length - 1; h >= 0; h--) { var house = houses[h]; house.move(); if (house.y > 2732 + house.height) { house.destroy(); houses.splice(h, 1); } } } }); });
===================================================================
--- original.js
+++ change.js
@@ -33,10 +33,8 @@
var NaughtyHouse = House.expand(function () {
var self = House.call(this);
var houseGraphics = self.createAsset('naughtyHouse', 'Naughty House Graphics', .5, 1);
houseGraphics.tint = 0xff0000;
- var houseGraphics = self.createAsset('naughtyHouse', 'Naughty House Graphics', .5, 1);
- houseGraphics.tint = 0xff0000;
self.getNaughty = function () {
return true;
};
});
overhead view of simple box house christmas decorations giant christmas tree out front video game asset 2d blank background Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
overhead view of drab house with giant prohibition symbol snowy lawn video game asset 2d blank background Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
overhead view of charred remains of a completely burned down box house snowy lawn video game asset 2d blank background Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Santa on sleigh pulled by reindeer blank background no shadows flying forward away straight top down Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
simple red christmas ornament 2d blank background high contrast no shadows in game asset Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
simple snowflake In-Game asset. 2d. Blank background. High contrast. No shadows. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
old white scroll unfurled blank no shadows Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
top down simple wrapped red present with gold bow. 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.
top down plate of cookies glass of milk. In-Game asset. Blank background. No shadows. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.