Post

 Resources 

Console

Fart Sniffer


Part 6 - Keeping things in view


The KeepInBounds method checks to see if the player is within the bounds of the forms client area and if not prevents it from moving outside that area. It then perform the same checking for each fly in the flies collection.

Copy and paste the fallowing code into Form1

  1. Private Sub KeepInBounds()
  2.    ' keep the player within the visible area of the form
  3.    mobjPlayer.Position.X = RestrictValue(mobjPlayer.Position.X, 0, Me.ClientSize.Width - 1)
  4.    mobjPlayer.Position.Y = RestrictValue(mobjPlayer.Position.Y, 0, Me.ClientSize.Height - 1)
  5.    ' keep all flies within the visible area of the form
  6.    For Each F As Fly In mobjFlies
  7.       F.Position.X = RestrictValue(F.Position.X, 0, Me.ClientSize.Width - 1)
  8.       F.Position.Y = RestrictValue(F.Position.Y, 0, Me.ClientSize.Height - 1)
  9.    Next
  10. End Sub




Next: Part 7 - Fart Decay | 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