User prompt
Add 1 score every '10 y' that we travel up
User prompt
Please fix the bug: 'ReferenceError: tutorialText is not defined' in or related to this line: 'tutorialText.y += 5;' Line Number: 200
User prompt
Remove the tutorial text
User prompt
Add 1 score every 10 ticks instead of based on y position
User prompt
Add a simulated y position that increases by game.obstacleSpeed every tick. The score should be this divided by 10.
Code edit (2 edits merged)
Please save this source code
User prompt
Migrate to the latest version of LK
Code edit (17 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -98,8 +98,9 @@
****/
game.score = 0;
game.obstacleSpeed = 5;
game.obstacleSpeedIncrease = 0.005;
+game.simulatedY = 0;
game.checkObstacleCollision = function (obstacles) {
for (var i = 0; i < obstacles.length; i++) {
obstacles[i].move();
var dist = Math.sqrt(Math.pow(bird.x - obstacles[i].x, 2) + Math.pow(bird.y - obstacles[i].y, 2));
@@ -230,11 +231,12 @@
}
}
game.checkObstacleCollision(leftObstacles);
game.checkObstacleCollision(rightObstacles);
+ game.simulatedY += game.obstacleSpeed;
if (bird.y < 0 || bird.y > 2732) {
LK.setScore(game.score);
LK.showGameOver();
- } else if (LK.ticks % 10 == 0) {
- game.score += 1;
+ } else {
+ game.score = Math.floor(game.simulatedY / 10);
}
});
\ No newline at end of file