void nMaze::replanishFood(){ // the "forth" bit in m_plan corresponds to a consumed food // make it available again for (unsigned int xPos = 0; xPos < m_x; xPos++) for (unsigned int yPos = 1; yPos < m_y - 1; yPos++) if (m_plan[xPos][yPos] != 1) applyBit(m_plan[xPos][yPos], 3, 0); }
/*** void WS2812::applyColor(uint8_t color) * * Parameters: * color: a value between 0 - 255, it is the * intensity of a single color * * Return Values: * None * * Description: * * A private method to convert 1 color into the pattern buffer * * ------------------------------------------------------------ */ void WS2812::applyColor(uint8_t color) { int i = 0; for(i=7; i>=0; i--) { applyBit(((color & (1 << i)) != 0)); } }
void nMaze::sprinkleFood(){ // move all over the maze for (unsigned int xPos = 0; xPos < m_x; xPos++) for (unsigned int yPos = 1; yPos < m_y - 1; yPos++) // if there is no wall at xPos, yPos create a food bag if (m_plan[xPos][yPos] != 1) // adjust the "third" bit of m_plan to have food item // either a healthy (1) or poisonous food (0) // randomly if (genUniRand(0, 1) > 0.5) applyBit(m_plan[xPos][yPos], 2, 1); }