Post

 Resources 

Console

Fart Sniffer


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

  1. Public Sub DrawFlies()
  2.    For Each F As Fly In mobjFlies
  3.       DrawActor(F)
  4.    Next
  5. End Sub
  6. Public Sub DrawReceptors()
  7.    For Each F As Fly In mobjFlies
  8.       For Each R As Receptor In F.Receptors
  9.             Dim NX, NY As Single
  10.            Displacement(F.Position.X, F.Position.Y, R.Distance, R.Direction +F.Direction, NX, NY)
  11.             Dim Half As Single
  12.             Half = R.Size / 2.0F
  13.            mobjGraphics.Graphics.DrawLine(Pens.Yellow, F.Position.X, F.Position.Y,NX, NY)
  14.            mobjGraphics.Graphics.DrawEllipse(Pens.Yellow, NX - Half, NY - Half,R.Size, R.Size)
  15.       Next
  16.    Next
  17. End Sub
  18. Public Sub DrawScents()
  19.    For Each s As Scent In mobjScents
  20.       Dim Half As Single
  21.       Half = s.Strength / 2.0F
  22.       mobjGraphics.Graphics.DrawEllipse(Pens.Green, _
  23.                  s.Position.X - Half, s.Position.Y - Half, s.Strength, s.Strength)
  24.    Next
  25. End Sub
  26. Public Sub DrawActor(ByVal A As Actor)
  27.    Dim Half As Single
  28.    Half = A.Size / 2.0F
  29.    mobjGraphics.Graphics.DrawEllipse(Pens.Red, _
  30.               A.Position.X - Half, A.Position.Y - Half, A.Size, A.Size)
  31. 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.
 


Next: Part 4 - Form Events | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11

Post a Comment


Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.
There have been 46 visitors within the last 20 minutes
RSS News Feed