Make the bird jump with force & falling with rotation
Let’s add force to the bird
Add the below command in the file [File: create-game.js] bird.body.velocity.y = -350;
Working Together
In the Replit window below, we started the code with the line bird.body.velocity.y = -350;
.
In your console you should see a JSappy bird jumping with force after you press run:
Bonus Activity
Let’s make the bird jump up and forwards:
Add below command in the file [File: create-game.js] bird.body.velocity.x = 100;
Bird falling with rotation
Let’s add rotation to the bird:
Add below command in the file [File: update-game.js] if (bird.angle < 50) { bird.angle += 1; }
Comments:
If
is a conditional block where we are checking the angle of the bird and if it’s less than 50 we are executing the condition.
-bird.angle+=1;
Working Together
In the Replit window below, we started the code with the line bird.angle +=1;
.
In your console you should see a Jsappy bird rotating with an angle after you press run: