Basic Collision Detection help

Libraries, utilities, bootloaders...

Re: Basic Collision Detection help

Postby rodot » Mon Aug 18, 2014 3:58 pm

yodasvideoarcade wrote:It would be useful to have an additional collission-detection function for detecting pixel-perfect collission between bitmaps.


That would be useful and pretty quick to implement, I'll give it a try asap. Thanks for the suggestion :)
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: Basic Collision Detection help

Postby Matrix828 » Mon Aug 18, 2014 5:06 pm

rodot wrote:
yodasvideoarcade wrote:It would be useful to have an additional collission-detection function for detecting pixel-perfect collission between bitmaps.


That would be useful and pretty quick to implement, I'll give it a try asap. Thanks for the suggestion :)



Does what I posted work? (saves you a few minutes atleast :D )
Code: Select all
boolean collideBitmap(const uint8_t *bitmap1, int8_t x1, int8_t y1, const uint8_t *bitmap2, int8_t x2, int8_t y2) {
    int8_t w1 = pgm_read_byte(bitmap1);
    int8_t h1 = pgm_read_byte(bitmap1 + 1);

    int8_t w2 = pgm_read_byte(bitmap2);
    int8_t h2 = pgm_read_byte(bitmap2 + 1);

    return gb.collideRectRect(x1, y1, w1, h1, x2, y2, w2, h2);
}
Matrix828
 
Posts: 43
Joined: Tue Jul 22, 2014 7:44 pm

Re: Basic Collision Detection help

Postby rodot » Mon Aug 18, 2014 5:20 pm

Yoda was talking about a pixel-wise collision, what you suggest here is the collisions between the rectangles containing the bitmap, do you get the difference?
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: Basic Collision Detection help

Postby rodot » Fri Sep 05, 2014 9:05 pm

A wild pixel-wise collision detection appears! :o

You'll find it in the library's beta branch. If you catch any bug please tell me.
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: Basic Collision Detection help

Postby DFX2KX » Sat Sep 06, 2014 11:15 pm

rodot wrote:A wild pixel-wise collision detection appears! :o

You'll find it in the library's beta branch. If you catch any bug please tell me.


:o! YAYYY! It appears you don't have to draw said bitmaps either, this will be quite useful for all sorts of things! Thanks Rodot!
DFX2KX
 
Posts: 250
Joined: Mon Apr 14, 2014 3:48 am

Previous

Return to Software Development

Who is online

Users browsing this forum: No registered users and 40 guests

cron