Collisions help(PLEASE!!! IT'S NOT HARD!!!)

This is a discussion on Collisions help(PLEASE!!! IT'S NOT HARD!!!) within the Windows Programming forums, part of the Platform Specific Boards category; I am starting on Windows game programming and I am making a simple Pong game. I have it to detect ...

  1. #1
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Post Collisions help(PLEASE!!! IT'S NOT HARD!!!)

    I am starting on Windows game programming and I am making a simple Pong game. I have it to detect collisions with the window. My problem is, how would I detect a collision with a child window(I am using buttons [CreateWindow("button"), etc]). How would I detect the ball BMP colliding with a button?
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: trifaze_mattu@lycos.com

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  2. #2
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    You can get the window coords with GetWindowRect(), and then check if the ball's bmp coords enters them. If you just want a paddle, why don't you just draw a rectangle?
    zen

  3. #3
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question How do I do that?

    How do I create a rectangle?
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: trifaze_mattu@lycos.com

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  4. #4
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    With the function Rectangle(hdc,left,top,right,bottom), or FillRect(hdc,&rect,hbrush);
    zen

  5. #5
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,855
    Also use PtInRect() to find the collision.
    Make sure all your cood's are in the same scale, screen cood's or the child window's client cood's.

    For the rectangle you can use a bmp or create a 'static' control rather than the button.

    MAKEPOINTS() macro may also help. Watch as POINT is int[2], POINTS is short int[2]. May need a type cast.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  6. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    75
    Hey syntax bubble


    I dont know how far u are with this thing, but I was wondering


    Is it ok if I ask if I can help u out with this?


    I mean I am no good with this C++ programming although I did start learning a while ago but got a little too busy, but I am very interested in making a pong clone and I see this as my chance to learn a whole lot more


    So if this is ok with u would u liek to email me and let me know


    Stealth2kone@hotmail.com




    Cheers



    Stealth
    If I knew what You know I wouldnt be here.............. Stealth

    Ecliptic Entertainment
    http://www.ecliptic-entertainment.com/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extracting data from a laptop hard drive
    By DavidP in forum Tech Board
    Replies: 6
    Last Post: 06-13-2009, 07:02 AM
  2. Detect SCSI Hard Drive Serial Number
    By mercury529 in forum Windows Programming
    Replies: 3
    Last Post: 10-17-2006, 06:23 PM
  3. Replies: 2
    Last Post: 07-06-2005, 07:11 PM
  4. Trinary Hard Drive
    By nickname_changed in forum Tech Board
    Replies: 14
    Last Post: 05-13-2005, 10:01 AM
  5. hard drive problems continually increasing
    By DavidP in forum Tech Board
    Replies: 5
    Last Post: 11-21-2002, 09:48 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21