diff options
-rw-r--r-- | src/snake.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/snake.cpp b/src/snake.cpp index 9c3c4d0..5246a3c 100644 --- a/src/snake.cpp +++ b/src/snake.cpp @@ -187,10 +187,10 @@ GameCore::GameCore(QWidget *widget) // Remove tail from field if snake reached desired length if (snake->parts.size() >= snake->len) { const QPoint &p = snake->parts.front(); + snake->parts.pop_front(); if (FIELD(p.x(), p.y()) == snake->cell) { setField(p.x(), p.y(), &empty); } - snake->parts.pop_front(); } // Eat if (FIELD(snake->x, snake->y)->isFood()) { @@ -200,10 +200,10 @@ GameCore::GameCore(QWidget *widget) snake->len = 10; while (snake->parts.size() > snake->len) { const QPoint &p = snake->parts.front(); - if (FIELD(p.x(), p.y())->isFood()) - continue; - setField(p.x(), p.y(), &snakebrick); snake->parts.pop_front(); + if (!FIELD(p.x(), p.y())->isFood()) { + setField(p.x(), p.y(), &snakebrick); + } } addFood(); } else { |