Commit 49f9d6ff authored by Thomas Kolb's avatar Thomas Kolb
Browse files

Accumulate boost drops until config::FOOD_SIZE_MEAN

This should result in larger food particles to be generated.
parent c384c788
......@@ -204,7 +204,12 @@ void Snake::dropFood(float_t value)
Vector2D dropOffset = (m_segments.end() - 1)->pos() - (m_segments.end() - 2)->pos();
Vector2D dropPos = (m_segments.end() - 1)->pos() + dropOffset.normalized() * 5;
m_field->createDynamicFood(value * config::SNAKE_CONVERSION_FACTOR, dropPos, m_segmentRadius, nullptr);
m_foodToDrop += value * config::SNAKE_CONVERSION_FACTOR;
if(m_foodToDrop >= config::FOOD_SIZE_MEAN) {
m_field->createDynamicFood(m_foodToDrop, dropPos, m_segmentRadius, nullptr);
m_foodToDrop = 0;
}
m_mass -= value;
if(m_mass < 1e-6) {
......
......@@ -48,6 +48,8 @@ class Snake
real_t m_boostedLastMove = false; //!< Track if the snake boosted during the last move
real_t m_foodToDrop = 0;
/*!
* Updates the length of m_segments and calculates the current m_segmentRadius
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment