User prompt
make the hearts text smaller
User prompt
Fix Bug: 'TypeError: parseInt is not a function' in this line: 'var highscore = Math.max(currentScore, parseInt(window.localStorage && localStorage.getItem('highscore') || '0'));' Line Number: 59
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'getItem')' in this line: 'var highscore = Math.max(currentScore, parseInt(localStorage.getItem('highscore') || '0'));' Line Number: 59
User prompt
Fix Bug: 'TypeError: parseInt is not a function' in this line: 'var highscore = Math.max(currentScore, parseInt((typeof localStorage !== 'undefined' ? localStorage.getItem('highscore') : '0') || '0', 10));' Line Number: 59
User prompt
Fix Bug: 'TypeError: parseInt is not a function' in this line: 'var highscore = Math.max(currentScore, parseInt((typeof localStorage !== 'undefined' ? localStorage.getItem('highscore') : '0') || '0', 10));' Line Number: 59
User prompt
Fix Bug: 'TypeError: parseInt is not a function' in this line: 'var highscore = Math.max(currentScore, parseInt((typeof localStorage !== 'undefined' ? localStorage.getItem('highscore') : '0') || '0', 10));' Line Number: 59
User prompt
Fix Bug: 'TypeError: parseInt is not a function' in this line: 'var highscore = Math.max(currentScore, parseInt((typeof localStorage !== 'undefined' ? localStorage.getItem('highscore') : '0') || '0', 10));' Line Number: 59
User prompt
Fix Bug: 'TypeError: window.parseInt is not a function' in this line: 'var highscore = Math.max(currentScore, window.parseInt((typeof localStorage !== 'undefined' ? localStorage.getItem('highscore') : '0') || '0', 10));' Line Number: 59
User prompt
Fix Bug: 'TypeError: parseInt is not a function' in this line: 'var highscore = Math.max(currentScore, parseInt((typeof localStorage !== 'undefined' ? localStorage.getItem('highscore') : '0') || '0', 10));' Line Number: 59
User prompt
Fix Bug: 'TypeError: parseInt is not a function' in this line: 'var highscore = Math.max(currentScore, parseInt((typeof localStorage !== 'undefined' ? localStorage.getItem('highscore') : '0') || '0', 10));' Line Number: 59
User prompt
Fix Bug: 'TypeError: parseInt is not a function' in this line: 'var highscore = Math.max(currentScore, parseInt((typeof localStorage !== 'undefined' ? localStorage.getItem('highscore') : '0') || '0', 10));' Line Number: 59
User prompt
Fix Bug: 'TypeError: parseInt is not a function' in this line: 'var highscore = Math.max(currentScore, parseInt((typeof localStorage !== 'undefined' ? localStorage.getItem('highscore') : '0') || '0'));' Line Number: 59
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'getItem')' in this line: 'var highscore = Math.max(currentScore, parseInt(localStorage.getItem('highscore') || '0'));' Line Number: 59
User prompt
Add a highscore meter to the game and make the hearts text smaller
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'height')' in this line: 'highScoreTxt.y = scoreTxt.height + 20;' Line Number: 42
User prompt
Fix Bug: 'Uncaught TypeError: LK.getHighScore is not a function' in this line: 'var highScore = Math.max(LK.getHighScore(), LK.getScore());' Line Number: 36
User prompt
add a high score meter
User prompt
remove the hearts sprite and instead add a hearts counter next to the score
User prompt
to the score, not to the player
User prompt
move the hearts right next to the score
User prompt
move the hearts sprite up in the right corner
User prompt
add a hearts asset
User prompt
add a hearts asset
===================================================================
--- original.js
+++ change.js
@@ -18,12 +18,8 @@
var self = Container.call(this);
var playerGraphics = self.createAsset('player', 'Player Graphics', .5, .5);
self.speed = 10;
self.hearts = 3;
- self.heartsAsset = self.createAsset('hearts', 'Hearts Graphics', 0.5, 0.5);
- self.heartsAsset.x = LK.gui.topCenter.width - self.heartsAsset.width - 10;
- self.heartsAsset.y = 10;
- self.addChild(self.heartsAsset);
self.move = function (x, y) {
self.x = x;
self.y = y;
};
@@ -40,12 +36,19 @@
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
+ var heartsTxt = new Text2('Hearts: 3', {
+ size: 150,
+ fill: "#ffffff"
+ });
LK.setScore(0);
scoreTxt.setText(0);
scoreTxt.anchor.set(.5, 0);
+ heartsTxt.anchor.set(0, 0);
+ heartsTxt.x = scoreTxt.width + 20;
LK.gui.topCenter.addChild(scoreTxt);
+ LK.gui.topCenter.addChild(heartsTxt);
var dragNode = null;
player.on('down', function (obj) {
dragNode = player;
});
@@ -65,9 +68,9 @@
gifts[a].move();
if (gifts[a].y > 2732) {
gifts[a].destroy();
gifts.splice(a, 1);
- } else if (scoreTxt.intersects(gifts[a])) {
+ } else if (player.intersects(gifts[a])) {
LK.setScore(LK.getScore() + 10);
scoreTxt.setText(LK.getScore());
gifts[a].destroy();
gifts.splice(a, 1);
@@ -81,8 +84,9 @@
asteroid.destroy();
asteroids.splice(a, 1);
} else if (player.intersects(asteroid)) {
player.hearts = Math.max(player.hearts - 1, 0);
+ heartsTxt.setText('Hearts: ' + player.hearts);
if (player.hearts <= 0) {
LK.showGameOver();
}
asteroid.destroy();
Asteroid, falling Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Red gift Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Santas sled, with santa in it Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. Top down view
festive background Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.