Part 7 - Fart Decay
The
DecayFarts method process each scent in the scene and call’s it’s Decay
method. It then checks to see if the strength of the scent is less or
equal to zero if it is then it removes it from the collection,
otherwise it moves on to check the next scent in the collection.
The Decay method checks to see if it is time for the scent to decay and if so reduces the scent strength by the DecayRate.
Copy and paste the fallowing code into Form1
- Public Sub DecayFarts()
- Dim idx As Integer
- While idx <= mobjScents.Count - 1
- mobjScents(idx).Decay()
- If mobjScents(idx).Strength <= 0 Then
- mobjScents.RemoveAt(idx)
- Else
- idx += 1
- End If
- End While
- End Sub