Help with game code


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:

  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) {
//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);
//If the platforms reach the bottom they are removed
      if (platform.checkBottom()) {

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?

1 Like

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.


You’re right.
I hope it is allowed to post download links:

1 Like

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


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