Post

 Resources 

Console

Fart Sniffer


Part 2 - Declaring Variables



Now that we have all of our classes defined we can proceed to declare some variables. Open up the Code View for Form1 and copy and paste the fallowing code.

  1. Private Const NumberOfFlies As Integer = 25
  2. Private Const SpawnStinkyInterval As Integer = 1000 \ 30 ' 1000 ms div 30 fps
  3. Private Const UpdateFliesInterval As Integer = 1000 \ 60 ' 1000 ms div 60 fps
  4. Private mobjPlayer As Actor
  5. Private mobjFlies As Generic.List(Of Fly)
  6. Private mobjScents As Generic.List(Of Scent)
  7. Private WithEvents mobjTimer As Timers.Timer
  8. Private WithEvents mobjFlyUpdater As Timers.Timer
  9. Private WithEvents mobjStinkySpawner As Timers.Timer
  10. Private mobjGraphics As BufferedGraphics


The first 3 constants are as fallows..

  1. NumberOfFlies - Specifies how many flies our app will use.
  2. SpawnStinkyInterval - Specifies how many times per second the app will update the scent objects in the scene. The scent objects will be updated 30 times per second.
  3. UpdateFliesInterval - Specifies how many timer per second the app will update the flies in the scene. Flies will be updated 60 times per second.
After the constants is the player object, which is just defined as an actor. The next two variables are collections to store the flies and scent objects.
The next three variables after that are timers that will be used to update the flies and scent objects as well as draw them on screen at specified intervals.

The last variable is a BufferedGraphics object that is new in .NET 2.0 and we will use it to draw our graphics on screen. The BufferedGraphics object will help prevent any flickering on the screen when we draw our flies and scent objects.
 


Next: Part 3 - Draw Methods | 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 45 visitors within the last 20 minutes
RSS News Feed