Flappy Bird Clone > Week 2.2 Progress

April 16, 2020

Key Changes

  • Added two players… but will return to one player.
  • Infinite pipes and hit detection.

pipe.js Class

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
    show() {
        if (!this.highlight) {
            fill(255);
        } else {
            fill(255, 0, 0);
        }

        rect(this.x, 0, this.w, this.top); //top rectangle
        rect(this.x, this.bottom, this.w, height - this.bottom); //bottom rectangle
    }

    update() {
        this.x = this.x + this.speed;
    }

    hit(bird) {
        if ((bird.y < this.top || bird.y > this.top + this.spacing) && bird.x >= this.x && bird.x <= this.x + this.w) {
            this.highlight = true;
            return true;
        } else {
            return false;
        }
    }

Current State
Player 1 = Spacebar
Player 2 = Left Shift Key

Next Steps

  • Scoring
  • Pause Game on Game Over