private void InitStartingWorms() { // create a starting number of worms randomized over the dome for (int i = 0; i < m_startingWorms; i++) { SexWorm newWorm = new SexWorm(m_maxWormLength, m_globalRandom.Next(), m_globalRefractoryFrames); m_wormList.Add(newWorm); } }
public override void GenerateNewFrame(float dt) { Reduce(.9f); List<SexWorm> newBabies = new List<SexWorm>(); // go through all the worms, update them and then render them foreach (SexWorm worm in m_wormList) { worm.UpdateFrame(); // and now that we have updated the worm, let's render it on the dome int positionIndex = 0; foreach (DomePosition pos in worm.m_positionList) { if (worm.m_refractoryFrames > 0) { // getting closer to reproducing again! worm.m_refractoryFrames--; } // let's see if this is the head if (m_CurrentFrame.GetDomeLEDColor(pos.m_ribPos, pos.m_rowPos) != Color.Black && worm.m_refractoryFrames <= 0 && positionIndex == 0) { // we intersected another worm! // so let's totally make a baby! if (m_wormList.Count + newBabies.Count < m_maxWorms) { SexWorm newWorm = new SexWorm(pos.m_ribPos, pos.m_rowPos, m_maxWormLength, m_globalRandom.Next(), m_globalRefractoryFrames); newBabies.Add(newWorm); worm.m_refractoryFrames = m_globalRefractoryFrames; } } // right now we draw all of the worm at 100% m_CurrentFrame.SetDomeLEDColor(pos.m_ribPos, pos.m_rowPos, worm.m_Color); positionIndex++; } } foreach (SexWorm babyWorm in newBabies) { m_wormList.Add(babyWorm); } if (m_wormList.Count > m_maxWorms) { m_wormList.Clear(); InitStartingWorms(); } //m_CurrentFrame = output; }
public override void GenerateNewFrame(float dt) { Reduce(.9f); List <SexWorm> newBabies = new List <SexWorm>(); // go through all the worms, update them and then render them foreach (SexWorm worm in m_wormList) { worm.UpdateFrame(); // and now that we have updated the worm, let's render it on the dome int positionIndex = 0; foreach (DomePosition pos in worm.m_positionList) { if (worm.m_refractoryFrames > 0) { // getting closer to reproducing again! worm.m_refractoryFrames--; } // let's see if this is the head if (m_CurrentFrame.GetLedColor(pos.m_ribPos, pos.m_rowPos) != Color.Black && worm.m_refractoryFrames <= 0 && positionIndex == 0) { // we intersected another worm! // so let's totally make a baby! if (m_wormList.Count + newBabies.Count < m_maxWorms) { SexWorm newWorm = new SexWorm(pos.m_ribPos, pos.m_rowPos, m_maxWormLength, m_globalRandom.Next(), m_globalRefractoryFrames); newBabies.Add(newWorm); worm.m_refractoryFrames = m_globalRefractoryFrames; } } // right now we draw all of the worm at 100% m_CurrentFrame.SetLedColor(pos.m_ribPos, pos.m_rowPos, worm.m_Color); positionIndex++; } } foreach (SexWorm babyWorm in newBabies) { m_wormList.Add(babyWorm); } if (m_wormList.Count > m_maxWorms) { m_wormList.Clear(); InitStartingWorms(); } //m_CurrentFrame = output; }