Example #1
0
car::car(map m){
    int x0, y0;
    bool placed = false;
    QRect c;
    while (!placed)
    {
        x0 = rand()%(m.getBorder().width() - this->width);
        y0 = rand()%(m.getBorder().height() - this->height);
        c = QRect(x0,y0, this->width, this->height);
        placed = !(c.intersects(m.getGoal()));

        for (int i = 0; i < m.getObstacles().size(); ++i)
        {
            placed = placed & (!c.intersects(m.getObstacles().at(i)));
        }
    }
    this->x = x0 + this->width/2;
    this->y = y0 + this->height/2;
    this->angle = 0;
    this->rad = 0;
}