VS 2008 Help with returning values in another class-VBForums
Results 1 to 6 of 6

Thread: Help with returning values in another class

  1. #1

    Thread Starter
    Member Giver's Avatar
    Join Date
    Aug 2008
    Posts
    39

    Help with returning values in another class

    Hi, I'm making this game where there is an enemy that goes to the center of the form and grabs an object and brings it back to the side. I made a new class called enemy that makes the enemy. in the class there is a sub called start which the enemy goes to the center and brings the object back. when the enemy comes back with the object i want the integer lives to subtract 1 from it. so i put the code:

    Code:
    If Not Rect.IntersectsWith(Form1.ClientRectangle) Then
    Form1.Lives -= 1
    End If
    where Rect is the enemy's bounds. when ever rect is not intersecting with the forms bounds (which means when its off screen) lives should subtract 1, but it doesnt.
    Please help

  2. #2
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,955

    Re: Help with returning values in another class

    I think that never happens how do you draw something outside a form?

    The best way i think that is checking if the rect in the left side the left property is equal to zero or in the right the left property it's equal to the width minus the rect width.

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  3. #3

    Thread Starter
    Member Giver's Avatar
    Join Date
    Aug 2008
    Posts
    39

    Re: Help with returning values in another class

    I'll try it when I get on a computer, but it's weird because when I set other Boolean values from true to false they change but this one just doesn't change. Thanks for your help I'll reply once I try it.

  4. #4
    Hyperactive Member Darkened Linux's Avatar
    Join Date
    Jun 2009
    Location
    Canada
    Posts
    296

    Re: Help with returning values in another class

    I would like to see your program when you are done working on it, I am interested in what you are doing.
    [COLOR="Black"]

  5. #5

    Thread Starter
    Member Giver's Avatar
    Join Date
    Aug 2008
    Posts
    39

    Re: Help with returning values in another class

    OK, Here is the original code:

    Code:
      If Not Rect.IntersectsWith(Form1.ClientRectangle) Then
                        Form1.Lives -= 1
                        _HasEnergy = False
                        _IsMoving = False
                        _EnergyIndex = -1
                        Exit Do
                        Exit Sub
                    End If
    Here is the changed code:

    Code:
     If Rect.Right <= 0 Or Rect.Left > Form1.ClientSize.Width Or Rect.Bottom <= 0 Or Rect.Top >= Form1.ClientSize.Height Then
                        Form1.Lives -= 1
                        _HasEnergy = False
                        _IsMoving = False
                        _EnergyIndex = -1
                        Exit Do
                        Exit Sub
                    End If
    I tried it out and it didn't work.

    I will post my project when i change the file locations it uses.
    Last edited by Giver; Aug 1st, 2009 at 02:42 PM.

  6. #6

    Thread Starter
    Member Giver's Avatar
    Join Date
    Aug 2008
    Posts
    39

    Re: Help with returning values in another class

    Does anyone have an idea of how i could resolve my problem?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.