# Unit 3 Lesson 22 debug game

**URL:** <https://forum.code.org/t/unit-3-lesson-22-debug-game/26983>\
**Category:** Coding and Debugging Help\
**Created:** [May 20, 2019, 1:55pm UTC](https://forum.code.org/t/unit-3-lesson-22-debug-game/26983 "2019-05-20T13:55:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lorikaye](https://avatars.discourse-cdn.com/v4/letter/l/dc4da7/32.png) [@lorikaye](https://forum.code.org/u/lorikaye)\
**Post date:** [May 20, 2019, 1:55pm UTC](https://forum.code.org/t/unit-3-lesson-22-debug-game/26983/1 "2019-05-20T13:55:30Z")

</div>

> **[Check out what I made](https://studio.code.org/projects/gamelab/JqMfivcQVP_4lFhgHSTvuOq1rCN4dVqrBQmfWl4i5ug)**
>
> I wrote the code myself with Code.org

Line 134 function zombie movement: Once the zombies x position is == 110, zombies should disappear and game over should show up.

Line 264 function speed: once shooter has so many kills If kills are \> 2 then the zombies should get progressively faster.

I’ve tried a few things a nothing seems to be working. Also, if you could give me any tips on how to use the debug console or watcher to help solve problems like this, I would appreciate it.

Thanks

---

<div class="post-metadata">

**Author:** ![jold](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/jold/32/5811_2.png) [@jold](https://forum.code.org/u/jold)\
**Post date:** [May 20, 2019, 6:55pm UTC](https://forum.code.org/t/unit-3-lesson-22-debug-game/26983/2 "2019-05-20T18:55:37Z")

</div>

One of the big issues with using the == is that it has to be equal.  
Depending on how the x position of the zombie is being updated, the x position may never be equal to 110.  
I tell the students to use \>= or a combination of \>= and \<= to get a range of values to trigger the if statement.

Looks like the zombies are speeding up with the increasing score.

In general, people assume they know the value of a variable at a certain time, the watchers help to verify that. Many times the assumption of the value and the actual value at a certain time are different.

I also like to add console.log statements into an if statement to see if that branch of code ever gets run.  
Like

```auto
if (zombie2.x == 110) {
  
   console.log("yay!. I made it to this branch!") ;
 
    gameOver.visible = 1;
    deadSoldier.visible = 1;
    soldier.visible = 0;
    soldier.y = 1000;
    block.visible = 1;
    zombie2.visible = 0;
  }

```

Hopefully that helps. Let us know how it goes!
