All pastes #710542 Raw Edit

Stuff

public cpp v1 · immutable
#710542 ·published 2007-09-25 16:38 UTC
rendered paste body
/*** Detects a collision between the blocks and the player* @param int type, where? 0 left, 1 up, 2 right, 3 down* @param Player* player instance* @param Block* block instance* @return true if collision happend, false otherwise*/bool Player::detect_collision(int where, Block *bl){    // Check where to check    if(where == 0)    {        // left        if(x > bl->getx() && !detect_collision(3, bl)        && !detect_collision(2, bl) && !detect_collision(1, bl)) return true;        return false;    }    else if(where == 1)    {        // Check for up        if(y > bl->gety() - player_bmp[0]->h) return true;        return false;    }    else if(where == 2)    {        // Check for right        if(x < bl->getx() + bl->getw() && !detect_collision(0, bl)        && !detect_collision(3, bl) && !detect_collision(1, bl)) return true;        return false;    }    else if(where == 3)    {        // Check for down        if(y < bl->gety() + bl->geth()) return true;        return false;    }    return false;}