summaryrefslogtreecommitdiffstats
path: root/src/snake.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/snake.cpp')
-rw-r--r--src/snake.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/snake.cpp b/src/snake.cpp
index 9c7fefa..2ce1a0d 100644
--- a/src/snake.cpp
+++ b/src/snake.cpp
@@ -215,7 +215,7 @@ GameCore::GameCore(QWidget *widget)
snake->parts.append(QPoint(snake->x, snake->y));
}
// If no food was picked up within a minute, spawn more
- if (QDateTime::currentMSecsSinceEpoch() - _lastMeal > 60000) {
+ if (!_snakes.isEmpty() && QDateTime::currentMSecsSinceEpoch() - _lastMeal > 60000) {
_lastMeal = QDateTime::currentMSecsSinceEpoch();
addFood();
}
@@ -424,7 +424,7 @@ void GameCore::addSnake()
int x = qrand() % _width;
int y = qrand() % _height;
if (FIELD(x, y)->isFree()) {
- if (qrand() % 2 == 0) {
+ if (_snakes.count() <= _balls.count()) {
qDebug() << "Adding Snake at" << x << y;
_snakes.append(new Snake(x, y));
} else {