From ce857ea46ea291010599de7c27987d16cd30952d Mon Sep 17 00:00:00 2001 From: Damian Roszczyk <34535631+buensons@users.noreply.github.com> Date: Sat, 31 Mar 2018 23:39:39 -0700 Subject: [PATCH 1/3] Update bird.js Implement gravity --- bird.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bird.js b/bird.js index f6e1098..ad86923 100644 --- a/bird.js +++ b/bird.js @@ -12,7 +12,7 @@ class Bird { this.x = 64; this.gravity = 0.6; - this.lift = -15; + this.delay = 0; this.velocity = 0; this.icon = birdSprite; @@ -26,12 +26,17 @@ class Bird { } up() { - this.velocity += this.lift; + if (this.delay > 0) + this.delay--; + + if (this.delay <= 0) { + this.velocity = -7; + this.delay = 1; + } } update() { this.velocity += this.gravity; - this.velocity *= 0.9; this.y += this.velocity; if (this.y >= height - this.height / 2) { From acef9abffc36f5f91bd48a80ffa9cf9a7eecc889 Mon Sep 17 00:00:00 2001 From: Damian Roszczyk <34535631+buensons@users.noreply.github.com> Date: Mon, 2 Apr 2018 14:22:38 -0700 Subject: [PATCH 2/3] make delay a boolean --- bird.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bird.js b/bird.js index ad86923..0a2e377 100644 --- a/bird.js +++ b/bird.js @@ -12,7 +12,7 @@ class Bird { this.x = 64; this.gravity = 0.6; - this.delay = 0; + this.delay = false; this.velocity = 0; this.icon = birdSprite; @@ -26,12 +26,12 @@ class Bird { } up() { - if (this.delay > 0) - this.delay--; + if (this.delay) + this.delay = false; - if (this.delay <= 0) { + if (!this.delay) { this.velocity = -7; - this.delay = 1; + this.delay = true; } } From 58d149fa95dc357435bccbd1b983e3c70910d068 Mon Sep 17 00:00:00 2001 From: Damian Roszczyk <34535631+buensons@users.noreply.github.com> Date: Tue, 3 Apr 2018 11:16:54 -0700 Subject: [PATCH 3/3] Update bird.js --- bird.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/bird.js b/bird.js index 0a2e377..ee6f071 100644 --- a/bird.js +++ b/bird.js @@ -12,7 +12,7 @@ class Bird { this.x = 64; this.gravity = 0.6; - this.delay = false; + this.lift = -7; this.velocity = 0; this.icon = birdSprite; @@ -26,13 +26,7 @@ class Bird { } up() { - if (this.delay) - this.delay = false; - - if (!this.delay) { - this.velocity = -7; - this.delay = true; - } + this.velocity = this.lift; } update() {