# Don't know what is missing for to code to work (flappy bird)

**URL:** <https://discourse.processing.org/t/dont-know-what-is-missing-for-to-code-to-work-flappy-bird/29711>\
**Category:** Libraries\
**Tags:** homework\
**Created:** [April 28, 2021, 7:36pm UTC](https://discourse.processing.org/t/dont-know-what-is-missing-for-to-code-to-work-flappy-bird/29711 "2021-04-28T19:36:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JustinChan613](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@JustinChan613](https://discourse.processing.org/u/JustinChan613)\
**Post date:** [April 28, 2021, 7:36pm UTC](https://discourse.processing.org/t/dont-know-what-is-missing-for-to-code-to-work-flappy-bird/29711/1 "2021-04-28T19:36:19Z")

</div>

Hi it’s me again. Right now I am dealing with another game - flappy bird. I am making the function of counting is player losing. I use if-else statement to determine whether the player’s losing. The coding flow seems to be right but it does not work at all. Would like to ask is there something missing for it to work? Thanks!

> **[p5.js Web Editor](https://editor.p5js.org/JustinChan/sketches/tdVFtoxIB)**
>
> A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.

---

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [April 28, 2021, 10:33pm UTC](https://discourse.processing.org/t/dont-know-what-is-missing-for-to-code-to-work-flappy-bird/29711/2 "2021-04-28T22:33:43Z")

</div>

I assume this is the code you have added:

```auto
  if (this.x < 50) {
  if (y < this.top) {
    gameOver = true;
  } else if (y > this.bottom) {
    gameOver = true;
  } else {
    gameOver = false;
  }
  }

```

What is the value of `this.x`?  
Try to debug your code - print this value out to console.log!

Is that value ever less than 50?  
Try printing `this.x < 50` to console.log!

Given that result, is the above block of code ever executed?!?

* * *

Also:

```auto
  for (let i = 0; i < pipes.length; i++) {
    pipes[i].show();
    pipes[i].update();
    
    if(gameOver == true) {
    background(0);
  }
  } 

```

Does that look right to you?  
Why are you doing a game over check inside a for loop?  
Will the value of `gameOver` change becaause a pipe is updated?

---

<div class="post-metadata">

**Author:** ![JustinChan613](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@JustinChan613](https://discourse.processing.org/u/JustinChan613)\
**Post date:** [April 28, 2021, 11:03pm UTC](https://discourse.processing.org/t/dont-know-what-is-missing-for-to-code-to-work-flappy-bird/29711/3 "2021-04-28T23:03:17Z")

</div>

Ahhh I get it. Thank you for the remind! Will check everything after asking in the future! Thanks!
