Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Allegro collision detection

Name: Anonymous 2010-05-11 12:59

bool Player::collide(int x, int y, BITMAP* object)
{
    for (int px = 0; px < 20; px++)
    {
        for (int py = 0; py < 20; px++)
        {
            if (getpixel(image,px+x,py=y)!=bitmap_mask_color(image))
            {
                if (getpixel(object,xPos+px+x,yPos+py+y)!=bitmap_mask_color(object))
                {
                    return true;
                    break;
                }
            }
        }
    }
    return false;
}

xPos and yPos speak for themselves
x and y are the potential changes to the xPos and yPos, if this method returns false, they will be made.
image is a 20x20px player image.
object is my arena made from a tileset, pieced together by a vector of strings, each character in the vector representing a tile.

However, my player resolutely refuses to fall when gravity tells him to, or the program crashes. Either he's colliding with something (He shouldn't be, he's surrounded by masked squares) or some crazy voodoo is eating my datas.

any ideas?

Name: Anonymous 2010-07-23 11:37

>>8
Looks better.

>>1
Now you have four problems.

Name: Anonymous 2010-07-23 16:18

DON'T HELP HIM

Name: Anonymous 2010-11-14 22:32

Name: Anonymous 2010-11-26 1:27

Name: Anonymous 2010-12-25 3:43

Name: Anonymous 2011-02-03 3:35

Name: Anonymous 2013-01-19 23:21

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

Name: Anonymous 2013-08-31 20:24





    isent it great how we get to live in this country, that they use chemicals and medical procedure to enhance us for war?  Its cool that we get to be more enhanced then anywhere else in the world.

Name: Anonymous 2013-08-31 21:55



身体能力もなし向上心もなし
おまけに指9本失くしたカタワ
こんな奴に何期待してんの?バカですか?

Name: Anonymous 2014-01-21 20:59

>>46
>le pedophile sage

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List