Thread: Bitmap Collision

  1. #1
    Registered User
    Join Date
    Jan 2004
    Posts
    68

    Bitmap Collision

    http://www.ti-x.net/images/collision%20prob.jpg


    hey guys, i've got htis problem i've been workin on for the whole of today without success

    basically the bitmap is not colliding where it is, its colliding at its origin (the point where its created) and its really getting annoying.

    Is there anything I can do to get the bitmap to actually be the actual size of the bitmap itself rather than just 1 pixel which is the size of the origin where the bitmap is being created.

    I am using wxWidgets btw.
    -Ti22-

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Create bounding box using the origin, with and height of the bitmap. Then use this for your collision tests.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  3. #3
    Registered User
    Join Date
    Jan 2004
    Posts
    68
    how do i create the bounding box using the origin? just draw a rectangle?

    the origin is just a point in space.
    -Ti22-

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    If you wont be rotating the box:

    Code:
    RECT BoundingVolume;
    
    
    BoundingVolume.left=x;
    BoundingVolume.top=y;
    BoundingVolume.right=x+BitmapWidth;
    BoundingVolume.bottom=y+BitmapHeight;
    Or if you are then use a Direct3D quad.

  5. #5
    Registered User
    Join Date
    Jan 2004
    Posts
    68
    I've draw a rectangle behind for the sprite

    however it still uses the origin (one point) of the rectangle to test the collision detection.
    -Ti22-

  6. #6
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    You dont need to draw the rectangle.. you need to use it to test for collisions. Dont't test the sprite for collisions, test the rectangle.

  7. #7
    Call me AirBronto
    Join Date
    Sep 2004
    Location
    Indianapolis, Indiana
    Posts
    195
    Like Perspective said you dont draw the bounding rectangle, it is just there. just make the bounding rectangle the size of your sprite or a little less than your sprites size and calculate this size based on your sprite position parameters, so it will follow the sprite. dose this help any? and it sounds like your code is only for testing for a single point of collision so you will have to change that to.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Collision Detection Problems
    By Dark_Phoenix in forum Game Programming
    Replies: 1
    Last Post: 12-17-2006, 03:25 PM
  2. OpenGL -- Bitmaps
    By HQSneaker in forum Game Programming
    Replies: 14
    Last Post: 09-06-2004, 04:04 PM
  3. bitmap not going onto screen
    By stallion in forum Windows Programming
    Replies: 4
    Last Post: 02-22-2003, 10:07 AM
  4. Allegro bitmap collision? how?
    By elfjuice in forum Game Programming
    Replies: 5
    Last Post: 07-06-2002, 11:45 AM
  5. collision detection
    By DavidP in forum Game Programming
    Replies: 2
    Last Post: 05-11-2002, 01:31 PM