User prompt
The Score UI element should have some blank space padding above it (equal to 1.5% of the screen height) and on its left (equal to 5% of the screen height)
User prompt
The Score UI element should have some blank space padding above it (equal to 3% of the screen height) and on its left (equal to 5% of the screen height)
User prompt
Align the center height of the score text to the center height of the timer text
User prompt
Between the timer and the left edge of the screen is "Score: XX" in a font that is half as big as the timer. The "XX" starts at 0 and changes as the player's score changes.
User prompt
At the top center of the screen there is a timer that counts down from 60 seconds to 0. When the timer reaches 0, the game ends.
User prompt
Require that a nice house be hit by 3 presents before it becomes a happy house
User prompt
Change NiceHouse hit by a present to HappyHouse
User prompt
When a naught house is hit by a present its attribute changes from naughty to dark. But it otherwise continues moving down the screen.
User prompt
When a naughty house is hit by a present, it's type attribute changes to dark but it otherwise continues falling down the screen before despawning.
User prompt
When a naughty house is hit by a present, it's type attribute changes to dark but it otherwise continues falling down the screen before despawning.
User prompt
Try that again, it didn't work. The dark house has stopped but it needs to continue moving.
User prompt
When a house changes type, it should continue moving uninterrupted
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'addChild')' in this line: 'this.parent.addChild(darkHouse);' Line Number: 15
User prompt
If a naughty house is hit by a present, it switches to dark. Dark houses cannot interact with presents.
User prompt
Initially, 34% of houses spawn as naughty and 66% as nice
User prompt
Fix Bug: 'Uncaught ReferenceError: FallingHouse is not defined' in this line: 'var house = new FallingHouse();' Line Number: 104
User prompt
Houses can have attributes. One attribute is type, and there are four initial types (naughty, nice, happy, dark). When a house is naughty it is red, nice it is green, happy it is yellow, and dark it is grey.
User prompt
Houses have a type which can be naughty, nice, happy, or dark. Changing type does not modify movement in any way.
User prompt
Do not spawn houses that overlap or are close to overlapping
User prompt
Change the house spawn interval to be between 1.0 and 2.0 seconds
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'push')' in this line: 'houses.push(house);' Line Number: 57
User prompt
Houses spawn one at a time. Wait a random amount of time between 0.5 and 1.5 seconds to spawn the next house.
User prompt
Houses spawn above the top of the screen and then slowly fall to below the bottom of the screen where they despawn
User prompt
Houses spawn at a slow rate above the top of the screen and move straight down until they exit the bottom of the screen
User prompt
There is only one type of house
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 NaughtyHouse = Container.expand(function () { var self = Container.call(this); var houseGraphics = self.createAsset('naughtyHouse', 'Naughty House Graphics', .5, .5); houseGraphics.tint = 0xFF0000; self.speed = 2; self.move = function () { self.y += self.speed; if (self.y > 2732 + self.height) { self.destroy(); } }; }); var NiceHouse = Container.expand(function () { var self = Container.call(this); var houseGraphics = self.createAsset('niceHouse', 'Nice House Graphics', .5, .5); houseGraphics.tint = 0x00FF00; self.speed = 2; self.move = function () { self.y += self.speed; if (self.y > 2732 + self.height) { self.destroy(); } }; }); var HappyHouse = Container.expand(function () { var self = Container.call(this); var houseGraphics = self.createAsset('happyHouse', 'Happy House Graphics', .5, .5); houseGraphics.tint = 0xFFFF00; self.speed = 2; self.move = function () { self.y += self.speed; if (self.y > 2732 + self.height) { self.destroy(); } }; }); var DarkHouse = Container.expand(function () { var self = Container.call(this); var houseGraphics = self.createAsset('darkHouse', 'Dark House Graphics', .5, .5); houseGraphics.tint = 0x808080; self.speed = 2; self.move = function () { self.y += self.speed; if (self.y > 2732 + self.height) { self.destroy(); } }; }); 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 = []; self.spawnHouse = function () { var nextSpawnTime = Math.random() * 1000 + 1000; var newHouseX = Math.random() * 2048; var newHouseY = -Math.random() * 500; var canSpawn = true; for (var i = 0; i < houses.length; i++) { var house = houses[i]; if (Math.abs(newHouseX - house.x) < house.width && Math.abs(newHouseY - house.y) < house.height) { canSpawn = false; break; } } if (canSpawn) { var houseTypes = [NaughtyHouse, NiceHouse]; var randomIndex = Math.random() < 0.34 ? 0 : 1; var house = new houseTypes[randomIndex](); house.x = newHouseX; house.y = newHouseY; houses.push(house); self.addChild(house); } LK.setTimeout(self.spawnHouse, nextSpawnTime); }; self.spawnHouse(); var houses = []; var presents = []; 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; } for (var i = presents.length - 1; i >= 0; i--) { var present = presents[i]; present.move(); for (var j = houses.length - 1; j >= 0; j--) { var house = houses[j]; if (house instanceof NaughtyHouse && present.intersects(house)) { var darkHouse = new DarkHouse(); darkHouse.x = house.x; darkHouse.y = house.y; houses[j] = darkHouse; self.addChild(darkHouse); house.destroy(); present.destroy(); presents.splice(i, 1); break; } } if (present.y < -present.height) { present.destroy(); presents.splice(i, 1); } } for (var i = houses.length - 1; i >= 0; i--) { var house = houses[i]; house.move(); if (house.y > 2732 + house.height) { houses.splice(i, 1); } } }); });
===================================================================
--- original.js
+++ change.js
@@ -7,15 +7,8 @@
};
});
var NaughtyHouse = Container.expand(function () {
var self = Container.call(this);
- self.hitByPresent = function () {
- var darkHouse = new DarkHouse();
- darkHouse.x = self.x;
- darkHouse.y = self.y;
- self.parent.addChild(darkHouse);
- self.destroy();
- };
var houseGraphics = self.createAsset('naughtyHouse', 'Naughty House Graphics', .5, .5);
houseGraphics.tint = 0xFF0000;
self.speed = 2;
self.move = function () {
@@ -142,26 +135,30 @@
}
for (var i = presents.length - 1; i >= 0; i--) {
var present = presents[i];
present.move();
+ for (var j = houses.length - 1; j >= 0; j--) {
+ var house = houses[j];
+ if (house instanceof NaughtyHouse && present.intersects(house)) {
+ var darkHouse = new DarkHouse();
+ darkHouse.x = house.x;
+ darkHouse.y = house.y;
+ houses[j] = darkHouse;
+ self.addChild(darkHouse);
+ house.destroy();
+ present.destroy();
+ presents.splice(i, 1);
+ break;
+ }
+ }
if (present.y < -present.height) {
present.destroy();
presents.splice(i, 1);
}
}
for (var i = houses.length - 1; i >= 0; i--) {
var house = houses[i];
house.move();
- for (var j = presents.length - 1; j >= 0; j--) {
- var present = presents[j];
- if (house instanceof NaughtyHouse && present.intersects(house)) {
- house.hitByPresent();
- houses.splice(i, 1);
- present.destroy();
- presents.splice(j, 1);
- break;
- }
- }
if (house.y > 2732 + house.height) {
houses.splice(i, 1);
}
}
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.