Results 1 to 3 of 3

Thread: Code for collision of top of shape...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Location
    Where you live
    Posts
    104

    Question Code for collision of top of shape...

    Hey..

    Im trying to write my fishing program and im getting stuck on the coding for a collision which only occurs if the y2 part of the line pierces the top of a shape. The shape must be hit by the y2 part of the line not at the middle of the line or ne thing. The shape is 495 x 255 (a rectangle) and is hidden underneath a fish that scrolls across the screen. I need it so when the fisher casts his line and the line hits any part of the top of the shape then the collision even occurs. Any help?

    Thanks,

    edit: Ok I found out a way to work it, though it is limiting. The line before didnt completely become equal to the top of the shape :

    If Line1.Y2 = Shape1.Top And Line1.X2 >= Shape1.Left Then fish4.Visible = False

    so I adjusted the shape and fishes position so now it does become equal so it works...but that is limiting because now i have to make the fish in set positions if the line is to become equal. Any way around this?
    Last edited by Inno; May 19th, 2002 at 10:23 PM.

  2. #2
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    I didn't understand the question...

  3. #3
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Of the top of my head...

    VB Code:
    1. If Line1.Y2 >= Shape1.Top And Line1.Y2 <= Shape1.Top + Shape1.Height And Line1.X2 >= Shape1.Left And Line1.X2 <= Shape1.Left + Shape1.Width Then
    2.     Fish4.Visible = False
    3. End If

    If the line's X2,Y2 point is within the shape this will hide the fish, which is what you want i think.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


Posting Permissions

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



Click Here to Expand Forum to Full Width