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
@@ -13,15 +13,17 @@
self.gravity = 1;
self.lift = -15;
self.isInAir = false;
self.flap = function () {
- if (self.isInAir < 2) {
+ if (self.isInAir < 1 || self.isInAir === 1 && canDoubleJump) {
self.ySpeed = self.lift * 1.5;
self.isInAir += 1;
- var shadow = game.addChild(new Shadow()); // Add a shadow particle
- shadow.x = self.x; // Position the shadow at the bird's current position
- shadow.y = self.y;
- shadow.scale.x = self.scale.x; // Ensure the shadow graphics scale x matches the cats at the time it's spawned
+ if (showShadow) {
+ var shadow = game.addChild(new Shadow()); // Add a shadow particle
+ shadow.x = self.x; // Position the shadow at the bird's current position
+ shadow.y = self.y;
+ shadow.scale.x = self.scale.x; // Ensure the shadow graphics scale x matches the cats at the time it's spawned
+ }
}
if (bird.intersects(leftWall)) {
bird.xSpeed = 30; // Add positive x speed when bird jumps from the left wall
} else if (bird.intersects(rightWall)) {
@@ -95,8 +97,11 @@
/****
* Game Code
****/
+var canDoubleJump = true;
+var framesPerShadow = 4;
+var showShadow = true;
game.score = 0;
game.obstacleSpeed = 5;
game.obstacleSpeedIncrease = 0.005;
game.simulatedY = 0;
@@ -118,9 +123,8 @@
}));
var scoreText = new Text2('0', {
size: 150,
fill: '#ffffff',
- font: 'Impact',
dropShadow: true,
dropShadowColor: '#222a9a',
dropShadowBlur: 5,
dropShadowDistance: 7,
@@ -129,10 +133,9 @@
scoreText.anchor.set(.5, 0);
LK.gui.top.addChild(scoreText);
var scoreText2 = new Text2('0', {
size: 150,
- fill: '#ffffff',
- font: 'Impact'
+ fill: '#ffffff'
});
scoreText2.anchor.set(.5, 0);
scoreText2.x = -4;
scoreText2.y = -5;
@@ -182,9 +185,9 @@
game.children[i].destroy();
}
}
// Spawn the shadows every few frames, while the cat is in the air
- if (bird.isInAir && LK.ticks % 4 == 0) {
+ if (bird.isInAir && showShadow && LK.ticks % framesPerShadow == 0) {
var shadow = game.addChildAt(new Shadow(), game.getChildIndex(bird)); // Add a shadow particle behind the bird
shadow.x = bird.x; // Position the shadow at the bird's current position
shadow.y = bird.y;
shadow.graphics.scale.x = bird.graphics.scale.x; // Ensure the shadow graphics scale x matches the bird at the time it's spawned