Program: 19966
Project: 19966
Buggy source:
/** 
 * K�y l�pi piirtolistat ja piirt�� tarvittavat tekstuurit ruudulle. Android kutsuu t�t� automaattisesti (maks. 60 kertaa sekunnissa).
 * @param _gl OpenGL-konteksti
 */
public void onDrawFrame(GL10 _gl){
  _gl.glEnable(GL10.GL_TEXTURE_2D);
  _gl.glClearColor(0,0,0,0);
  _gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
  if (showLoadingScreen) {
    try {
      Thread.sleep(0);
    }
 catch (    InterruptedException e) {
      e.printStackTrace();
    }
    showLoadingScreen=false;
  }
  if (allLoaded && gameThread.allLoaded) {
    long currentTime=android.os.SystemClock.uptimeMillis();
    if (currentTime - lastAnimationUpdate >= 40) {
      lastAnimationUpdate=currentTime;
    }
    for (int i=wrapper.backgroundStars.size() - 1; i >= 0; --i) {
      wrapper.backgroundStars.get(i).draw(_gl);
    }
    if (wrapper.mothership != null) {
      if (wrapper.mothership.usedAnimation != -1 && updateBeat % wrapper.mothership.animationSpeed == 0) {
        wrapper.mothership.update();
      }
      wrapper.mothership.draw(_gl);
    }
    for (int i=wrapper.obstacles.size() - 1; i >= 0; --i) {
      if (wrapper.obstacleStates.get(i) != Wrapper.INACTIVE) {
        if (wrapper.obstacles.get(i).usedAnimation != -1 && updateBeat % wrapper.obstacles.get(i).animationSpeed == 0) {
          wrapper.obstacles.get(i).update();
        }
        wrapper.obstacles.get(i).draw(_gl);
      }
    }
    for (int i=wrapper.enemies.size() - 1; i >= 0; --i) {
      if (wrapper.enemyStates.get(i) != Wrapper.INACTIVE) {
        if (wrapper.enemies.get(i).usedAnimation != -1 && updateBeat % wrapper.enemies.get(i).animationSpeed == 0) {
          wrapper.enemies.get(i).update();
        }
        wrapper.enemies.get(i).draw(_gl);
      }
    }
    for (int i=wrapper.projectiles.size() - 1; i >= 0; --i) {
      if (wrapper.projectileStates.get(i) != Wrapper.INACTIVE) {
        if (wrapper.projectiles.get(i).usedAnimation != -1 && updateBeat % wrapper.projectiles.get(i).animationSpeed == 0) {
          wrapper.projectiles.get(i).update();
        }
        wrapper.projectiles.get(i).draw(_gl);
      }
    }
    for (int i=wrapper.collectables.size() - 1; i >= 0; --i) {
      if (wrapper.collectableStates.get(i) != Wrapper.INACTIVE) {
        if (wrapper.collectables.get(i).usedAnimation != -1 && updateBeat % wrapper.collectables.get(i).animationSpeed == 0) {
          wrapper.collectables.get(i).update();
        }
        wrapper.collectables.get(i).draw(_gl);
      }
    }
    if (wrapper.player != null && wrapper.playerState != Wrapper.INACTIVE) {
      if (wrapper.player.usedAnimation != -1 && updateBeat % wrapper.player.animationSpeed == 0) {
        wrapper.player.update();
      }
      wrapper.player.draw(_gl);
    }
    for (int i=wrapper.effects.size() - 1; i >= 0; --i) {
      if (wrapper.effectStates.get(i) != Wrapper.INACTIVE) {
        if (wrapper.effects.get(i).usedAnimation != -1 && updateBeat % wrapper.effects.get(i).animationSpeed == 0) {
          wrapper.effects.get(i).update();
        }
        wrapper.effects.get(i).draw(_gl);
      }
    }
    for (int i=wrapper.guiObjects.size() - 1; i >= 0; --i) {
      if (wrapper.guiObjectStates.get(i) != Wrapper.INACTIVE) {
        if (wrapper.guiObjects.get(i).usedAnimation != -1 && updateBeat % wrapper.guiObjects.get(i).animationSpeed == 0) {
          wrapper.guiObjects.get(i).update();
        }
        wrapper.guiObjects.get(i).draw(_gl);
      }
    }
    for (int i=gameThread.hud.buttons.size() - 1; i >= 0; --i) {
      gameThread.hud.buttons.get(i).update();
    }
    if (currentTime - lastMessageUpdate >= 50) {
      lastMessageUpdate=currentTime;
      for (int i=wrapper.messages.size() - 1; i >= 0; --i) {
        if (wrapper.messageStates.get(i) != Wrapper.INACTIVE) {
          wrapper.messages.get(i).updateAngle();
        }
      }
    }
    ++updateBeat;
    if (updateBeat > 8) {
      updateBeat=1;
    }
  }
 else   if (!allLoaded && gameThread != null) {
    loadingTexture.draw(_gl,0,0,90,0);
    showLoadingScreen=true;
    if (loadTextures(_gl)) {
      startThread();
    }
 else {
      System.exit(0);
    }
  }
}

Fixed version (ground truth):
/** 
 * K�y l�pi piirtolistat ja piirt�� tarvittavat tekstuurit ruudulle. Android kutsuu t�t� automaattisesti (maks. 60 kertaa sekunnissa).
 * @param _gl OpenGL-konteksti
 */
public void onDrawFrame(GL10 _gl){
  _gl.glEnable(GL10.GL_TEXTURE_2D);
  _gl.glClearColor(0,0,0,0);
  _gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
  if (showLoadingScreen) {
    try {
      Thread.sleep(0);
    }
 catch (    InterruptedException e) {
      e.printStackTrace();
    }
    showLoadingScreen=false;
  }
  if (allLoaded && gameThread.allLoaded) {
    long currentTime=android.os.SystemClock.uptimeMillis();
    if (currentTime - lastAnimationUpdate >= 40) {
      lastAnimationUpdate=currentTime;
    }
    for (int i=wrapper.backgroundStars.size() - 1; i >= 0; --i) {
      wrapper.backgroundStars.get(i).draw(_gl);
    }
    if (wrapper.mothership != null) {
      wrapper.mothership.draw(_gl);
      if (wrapper.mothership.usedAnimation != -1 && updateBeat % wrapper.mothership.animationSpeed == 0) {
        wrapper.mothership.update();
      }
    }
    for (int i=wrapper.obstacles.size() - 1; i >= 0; --i) {
      if (wrapper.obstacleStates.get(i) != Wrapper.INACTIVE) {
        wrapper.obstacles.get(i).draw(_gl);
        if (wrapper.obstacles.get(i).usedAnimation != -1 && updateBeat % wrapper.obstacles.get(i).animationSpeed == 0) {
          wrapper.obstacles.get(i).update();
        }
      }
    }
    for (int i=wrapper.enemies.size() - 1; i >= 0; --i) {
      if (wrapper.enemyStates.get(i) != Wrapper.INACTIVE) {
        wrapper.enemies.get(i).draw(_gl);
        if (wrapper.enemies.get(i).usedAnimation != -1 && updateBeat % wrapper.enemies.get(i).animationSpeed == 0) {
          wrapper.enemies.get(i).update();
        }
      }
    }
    for (int i=wrapper.projectiles.size() - 1; i >= 0; --i) {
      if (wrapper.projectileStates.get(i) != Wrapper.INACTIVE) {
        wrapper.projectiles.get(i).draw(_gl);
        if (wrapper.projectiles.get(i).usedAnimation != -1 && updateBeat % wrapper.projectiles.get(i).animationSpeed == 0) {
          wrapper.projectiles.get(i).update();
        }
      }
    }
    for (int i=wrapper.collectables.size() - 1; i >= 0; --i) {
      if (wrapper.collectableStates.get(i) != Wrapper.INACTIVE) {
        wrapper.collectables.get(i).draw(_gl);
        if (wrapper.collectables.get(i).usedAnimation != -1 && updateBeat % wrapper.collectables.get(i).animationSpeed == 0) {
          wrapper.collectables.get(i).update();
        }
      }
    }
    if (wrapper.player != null && wrapper.playerState != Wrapper.INACTIVE) {
      wrapper.player.draw(_gl);
      if (wrapper.player.usedAnimation != -1 && updateBeat % wrapper.player.animationSpeed == 0) {
        wrapper.player.update();
      }
    }
    for (int i=wrapper.effects.size() - 1; i >= 0; --i) {
      if (wrapper.effectStates.get(i) != Wrapper.INACTIVE) {
        wrapper.effects.get(i).draw(_gl);
        if (wrapper.effects.get(i).usedAnimation != -1 && updateBeat % wrapper.effects.get(i).animationSpeed == 0) {
          wrapper.effects.get(i).update();
        }
      }
    }
    for (int i=wrapper.guiObjects.size() - 1; i >= 0; --i) {
      if (wrapper.guiObjectStates.get(i) != Wrapper.INACTIVE) {
        wrapper.guiObjects.get(i).draw(_gl);
        if (wrapper.guiObjects.get(i).usedAnimation != -1 && updateBeat % wrapper.guiObjects.get(i).animationSpeed == 0) {
          wrapper.guiObjects.get(i).update();
        }
      }
    }
    for (int i=gameThread.hud.buttons.size() - 1; i >= 0; --i) {
      gameThread.hud.buttons.get(i).update();
    }
    if (currentTime - lastMessageUpdate >= 50) {
      lastMessageUpdate=currentTime;
      for (int i=wrapper.messages.size() - 1; i >= 0; --i) {
        if (wrapper.messageStates.get(i) != Wrapper.INACTIVE) {
          wrapper.messages.get(i).updateAngle();
        }
      }
    }
    ++updateBeat;
    if (updateBeat > 8) {
      updateBeat=1;
    }
  }
 else   if (!allLoaded && gameThread != null) {
    loadingTexture.draw(_gl,0,0,90,0);
    showLoadingScreen=true;
    if (loadTextures(_gl)) {
      startThread();
    }
 else {
      System.exit(0);
    }
  }
}