# Jumping and score in game code

**URL:** <https://discourse.processing.org/t/jumping-and-score-in-game-code/11137>\
**Category:** Coding Questions\
**Created:** [May 11, 2019, 4:43pm UTC](https://discourse.processing.org/t/jumping-and-score-in-game-code/11137 "2019-05-11T16:43:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![D33](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@D33](https://discourse.processing.org/u/D33)\
**Post date:** [May 11, 2019, 4:43pm UTC](https://discourse.processing.org/t/jumping-and-score-in-game-code/11137/1 "2019-05-11T16:43:00Z")

</div>

Hello, I am currently making a small Doodle Jump clone but I ran into a problem.  
I created a class that just takes care of the platforms(it extends another class) on the screen and their interaction with the character. Here is how my platform class update method looks like:

```auto
  void update() {
    for (int i = 0; i < m_Platforms.size(); i++) {
      Platform platform = m_Platforms.get(i);
      
//If the character reaches half of the screen and is falling
      if (platform.updatePosY(m_Doodler) && m_Doodler.velocity.y<0) {
        //PLATFORMS SCROLLING
//if the character reaches 3/4 of the screen the platforms double their velocity
        if (platform.doubleSpeed(m_Doodler)) {
         platform.getPos().y += m_Doodler.velocity.y*(-2);
          
        } else {
          platform.getPos().y += m_Doodler.velocity.y*(-1);
        }
        score++;
      }
//If the platforms reach the bottom they are removed
      if (platform.checkBottom()) {
        println("g");
        //UPDATING PLATFORMS ON SCREEN
        m_Platforms.remove(i);
      }
    }
  }

```

The issue is that the more the character jumps on the platform the more my velocity keeps increasing, the score increases way too fast as well, and the platforms are not even removed from the screen.

Any idea on how to fix this?

---

<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:** [May 11, 2019, 6:49pm UTC](https://discourse.processing.org/t/jumping-and-score-in-game-code/11137/2 "2019-05-11T18:49:08Z")

</div>

We have no idea. This small amount of code is not something we can even run to see your problem, let alone diagnose or fix it.

Please post a complete, runnable example that demonstrates the problem. Also format the code properly (use the magic format this like code button, which looks like this: \</\>) so we don’t have to fiddle with correcting problems in your code caused by formatting issues.

---

<div class="post-metadata">

**Author:** ![D33](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@D33](https://discourse.processing.org/u/D33)\
**Post date:** [May 11, 2019, 6:53pm UTC](https://discourse.processing.org/t/jumping-and-score-in-game-code/11137/3 "2019-05-11T18:53:15Z")

</div>

You’re right.  
I hope it is allowed to post download links:  
[http://www.mediafire.com/file/c0on8688dnvmlaz/Doodle\_Jump\_Alpha\_v9.rar/file](http://www.mediafire.com/file/c0on8688dnvmlaz/Doodle_Jump_Alpha_v9.rar/file)

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [May 11, 2019, 6:55pm UTC](https://discourse.processing.org/t/jumping-and-score-in-game-code/11137/4 "2019-05-11T18:55:43Z")

</div>

> [@Help with a short game code](https://discourse.processing.org/t/help-with-a-short-game-code/11108/2):
>
> We can’t use method remove() when using an “enhanced” for ( : ) {} style! no_entry_sign Use a vanilla for ( ; ; ) {} style instead. Preferably, w/ backwards iteration: back

---

<div class="post-metadata">

**Author:** ![D33](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@D33](https://discourse.processing.org/u/D33)\
**Post date:** [May 13, 2019, 7:43pm UTC](https://discourse.processing.org/t/jumping-and-score-in-game-code/11137/5 "2019-05-13T19:43:12Z")

</div>

I tried to use a backward iteration, but the result is pretty much the same (no result).

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [May 14, 2019, 11:34am UTC](https://discourse.processing.org/t/jumping-and-score-in-game-code/11137/6 "2019-05-14T11:34:24Z")

</div>

For removing please use a 2nd separate for loop

This for loop is backwards with `for(.........; i--) { ....`

Remember to show your code every time you ask

Chrisir
