Просмотр исходного кода

reverse the for loop for power up status check

SimplyMinimal 2 лет назад
Родитель
Сommit
48188ec9d5
1 измененных файлов с 3 добавлено и 3 удалено
  1. 3 3
      app.c

+ 3 - 3
app.c

@@ -928,7 +928,7 @@ void update_powerUps_position(AsteroidsApp* app) {
 // @todo update_powerUp_status
 /* This updates the state of each power up collected and removes them if they have expired. */
 void update_powerUp_status(AsteroidsApp* app) {
-    for(int j = app->powerUps_num; j >= 0; j--) {
+    for(int j = 0; j < app->powerUps_num; j++) {
         if(app->powerUps[j].ttl > 0 && app->powerUps[j].isPowerUpActive) {
             // Only decrement ttl if we actually picked up power up
             app->powerUps[j].ttl--;
@@ -945,8 +945,8 @@ void update_powerUp_status(AsteroidsApp* app) {
             // Time to remove it
             app->powerUps[j].isPowerUpActive = false;
             remove_powerUp(app, j);
-            // j--; /* Process this power up index again: the removal will
-            //         fill it with the top power up to take the array dense. */
+            j--; /* Process this power up index again: the removal will
+                    fill it with the top power up to take the array dense. */
         } else {
             FURI_LOG_E(
                 TAG,