User prompt
Score can never go below 0
User prompt
Players earn 1 XP every time their score increases by 1. They do not XP if their score goes down. Every 5 XP earned increases the rank by 1.
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'split')' in this line: 'var rank = parseInt(rankTxt.text.split(': ')[1]) + rankIncrease;' Line Number: 191
User prompt
Fix Bug: 'TypeError: parseInt is not a function' in this line: 'var rank = parseInt(rankTextParts.length > 1 ? rankTextParts[1] : '0') + rankIncrease;' Line Number: 192
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'toString')' in this line: 'var rankTextParts = rankTxt.text.toString().split(': ');' Line Number: 191
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'split')' in this line: 'var rank = parseInt(rankTxt.text.split(': ')[1]) + rankIncrease;' Line Number: 191
User prompt
Players earn 1 XP every time their score increases by 1. They do not XP if their score goes down. Every 5 XP earned increases the rank by 1.
User prompt
Move the Score UI 20 pixels to the right
User prompt
Move the Rank UI 200 pixels to the right
User prompt
Move the Rank UI 300 pixels to the right
User prompt
Align the right edge of the rank UI with the right edge of the screen
User prompt
Align the top of the Rank UI with the top of the Score UI and move it to the right of the countdown timer
User prompt
Move the Rank UI 200 pixels down
User prompt
Align the Rank UI with the right edge of the screen
User prompt
Show "Rank: 1" instead of just 1
User prompt
Add a Rank UI underneath the countdown clock that starts at 1
User prompt
Move the rank UI to the left significantly
User prompt
Why can't I see the Rank UI?
User prompt
Why can't I see the Rank UI?
User prompt
In the top right corner, add "Rank:" which starts at 1
User prompt
Hide the UI
User prompt
Make the Rank font blue
User prompt
Instead of 20% use 35% to increase the XP needed after rank increase
User prompt
Every time a rank increases, reset XP to 0 and increase XP needed to rank up by 20% rounded down
User prompt
After rank, show (Current XP / XP to Next Rank)
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.hitCount = 0; 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 countdown = 60; var score = 0; var scoreTxt = new Text2('Score: ' + score, { size: 75, fill: "#ffffff" }); scoreTxt.anchor.set(0, 0); scoreTxt.x += 50; scoreTxt.y += 30; LK.gui.topLeft.addChild(scoreTxt); var timerTxt = new Text2(countdown.toString(), { size: 150, fill: "#ffffff" }); timerTxt.anchor.set(.5, 0); LK.gui.topCenter.addChild(timerTxt); var xp = 0; var rank = 1; var rankTxt = new Text2('Rank: ' + rank, { size: 75, fill: "#ffffff" }); rankTxt.anchor.set(0, 0); rankTxt.x = timerTxt.x + timerTxt.width + 230; rankTxt.y = scoreTxt.y; LK.gui.topCenter.addChild(rankTxt); function updateRank() { rank = 1 + Math.floor(xp / 5); rankTxt.setText('Rank: ' + rank); } function addXP(amount) { if (amount > 0) { xp += amount; updateRank(); } } var timer = LK.setInterval(function () { countdown--; timerTxt.setText(countdown.toString()); if (countdown <= 0) { LK.clearInterval(timer); LK.showGameOver(); } }, 1000); 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(); score = Math.max(0, score - 2); scoreTxt.setText('Score: ' + score); presents.splice(i, 1); break; } else if (house instanceof NiceHouse && present.intersects(house)) { house.hitCount++; score++; addXP(1); scoreTxt.setText('Score: ' + score); present.destroy(); presents.splice(i, 1); if (house.hitCount >= 3) { var happyHouse = new HappyHouse(); happyHouse.x = house.x; happyHouse.y = house.y; houses[j] = happyHouse; self.addChild(happyHouse); house.destroy(); } 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
@@ -190,9 +190,9 @@
houses[j] = darkHouse;
self.addChild(darkHouse);
house.destroy();
present.destroy();
- score -= 2;
+ score = Math.max(0, score - 2);
scoreTxt.setText('Score: ' + score);
presents.splice(i, 1);
break;
} else if (house instanceof NiceHouse && present.intersects(house)) {
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.