Part 3 - Draw Methods
In
order to see what the flies and scent objects are doing we will need to
draw them. Copy and paste the fallowing code into Form1
- Public Sub DrawFlies()
- For Each F As Fly In mobjFlies
- DrawActor(F)
- Next
- End Sub
- Public Sub DrawReceptors()
- For Each F As Fly In mobjFlies
- For Each R As Receptor In F.Receptors
- Dim NX, NY As Single
- Displacement(F.Position.X, F.Position.Y, R.Distance, R.Direction +F.Direction, NX, NY)
- Dim Half As Single
- Half = R.Size / 2.0F
- mobjGraphics.Graphics.DrawLine(Pens.Yellow, F.Position.X, F.Position.Y,NX, NY)
- mobjGraphics.Graphics.DrawEllipse(Pens.Yellow, NX - Half, NY - Half,R.Size, R.Size)
- Next
- Next
- End Sub
- Public Sub DrawScents()
- For Each s As Scent In mobjScents
- Dim Half As Single
- Half = s.Strength / 2.0F
- mobjGraphics.Graphics.DrawEllipse(Pens.Green, _
- s.Position.X - Half, s.Position.Y - Half, s.Strength, s.Strength)
- Next
- End Sub
- Public Sub DrawActor(ByVal A As Actor)
- Dim Half As Single
- Half = A.Size / 2.0F
- mobjGraphics.Graphics.DrawEllipse(Pens.Red, _
- A.Position.X - Half, A.Position.Y - Half, A.Size, A.Size)
- End Sub
The
methods for drawing our flies and scent objects are pretty straight
forward, and should be easy enough to understand by looking at the code.