int main(void){
    pa0();
    vezerlo_valtozo=1;
    korabbi_dontesek_szama=0;
    while(vezerlo_valtozo)
        switch(vezerlo_valtozo){
            case 1: if (ft1()){
                        pa8();
                        vezerlo_valtozo=0;
                      }
                      else if (ft2()) if ((valasztasi_lehetosegek_szama=fa1())){
                                          pa2();
                                          aktualis_lehetoseg_sorszama=0;
                                          vezerlo_valtozo=3;
                                         }
                                         else vezerlo_valtozo=2;
                              else vezerlo_valtozo=2;
                    break;
            case 2: if (korabbi_dontesek_szama){
                        korabbi_dontesek_szama--;
                        pa4();
                        if (aktualis_lehetoseg_sorszama<valasztasi_lehetosegek_szama-1){
                            aktualis_lehetoseg_sorszama++;
                            vezerlo_valtozo=3;
                           }
                           else vezerlo_valtozo=2;
                       }
                       else {
                           printf("A graf nem szinezheto %d szinnel!\n",MAX_color);
                           vezerlo_valtozo=0;
                       }
                    break;
            case 3: pa6();
                    pa7();
                    korabbi_dontesek_szama++;
                    vezerlo_valtozo=1;
        }
		getchar();
    return 0;

}
예제 #2
0
void DependentSource::drawOutline(QPainter &p) {
	const int _x = (int)x() - 16;
	const int _y = (int)y() - 32;

	// Top rectangle
	p.drawRect(_x, _y + 19, width(), 11);

#if 0
	p.save();
	bool canSetCol = (p.pen().color() != Qt::color0) && (p.pen().color() != Qt::color1);

	// Bottom lines

	if (canSetCol)
		p.setPen(m_pNNode[1]->isSelected() ? m_selectedCol : Qt::black);

	p.drawLine(_x, _y + 40, _x + 8, _y + 40); // Left inny

	if (canSetCol)
		p.setPen(m_pPNode[1]->isSelected() ? m_selectedCol : Qt::black);

	p.drawLine(_x + width(), _y + 40, _x + 24, _y + 40); // Right inny

	p.restore();
#endif

	// Bottom diamond
	QPointArray pa4(4);

	pa4[0] = QPoint(_x + 6, _y + 40);
	pa4[1] = QPoint(_x + 16, _y + 32);
	pa4[2] = QPoint(_x + 26, _y + 40);
	pa4[3] = QPoint(_x + 16, _y + 48);

	p.drawPolygon(pa4);
}
예제 #3
0
bool hitboxCollision(int a_x,int a_y,int a_width,int a_height,float a_angle,
              int b_x,int b_y,int b_width,int b_height,float b_angle)
{
    Point pa1(a_x,
              a_y);

    Point pa2(a_x + cos (a_angle*PI/180) * a_width
             ,a_y - sin (a_angle*PI/180) * a_width);

    Point pa3(a_x + cos (a_angle*PI/180) * a_width + sin (a_angle*PI/180) * a_height,
              a_y - sin (a_angle*PI/180) * a_width + cos (a_angle*PI/180) * a_height);

    Point pa4(a_x + sin (a_angle*PI/180) * a_height,
              a_y + cos (a_angle*PI/180) * a_height);


    Point pb1(b_x,
              b_y);

    Point pb2(b_x + cos (b_angle*PI/180) * b_width
             ,b_y - sin (b_angle*PI/180) * b_width);

    Point pb3(b_x + cos (b_angle*PI/180) * b_width + sin (b_angle*PI/180) * b_height,
              b_y - sin (b_angle*PI/180) * b_width + cos (b_angle*PI/180) * b_height);

    Point pb4(b_x + sin (b_angle*PI/180) * b_height,
              b_y + cos (b_angle*PI/180) * b_height);

    Line la1(pa1,pa2);
    Line la2(pa2,pa3);
    Line la3(pa3,pa4);
    Line la4(pa4,pa1);

    Line lb1(pb1,pb2);
    Line lb2(pb2,pb3);
    Line lb3(pb3,pb4);
    Line lb4(pb4,pb1);

    if(segmentIntersection(la1,lb1))
        return true;
    if(segmentIntersection(la1,lb2))
        return true;
    if(segmentIntersection(la1,lb3))
        return true;
    if(segmentIntersection(la1,lb4))
        return true;

    if(segmentIntersection(la2,lb1))
        return true;
    if(segmentIntersection(la2,lb2))
        return true;
    if(segmentIntersection(la2,lb3))
        return true;
    if(segmentIntersection(la2,lb4))
        return true;

    if(segmentIntersection(la3,lb1))
        return true;
    if(segmentIntersection(la3,lb2))
        return true;
    if(segmentIntersection(la3,lb3))
        return true;
    if(segmentIntersection(la3,lb4))
        return true;

    if(segmentIntersection(la4,lb1))
        return true;
    if(segmentIntersection(la4,lb2))
        return true;
    if(segmentIntersection(la4,lb3))
        return true;
    if(segmentIntersection(la4,lb4))
        return true;

    return false;


/*

    vector<Point*>intersections;
    intersections.push_back(lineIntersection(la1,lb1));
    intersections.push_back(lineIntersection(la1,lb2));
    intersections.push_back(lineIntersection(la1,lb3));
    intersections.push_back(lineIntersection(la1,lb4));

    intersections.push_back(lineIntersection(la2,lb1));
    intersections.push_back(lineIntersection(la2,lb2));
    intersections.push_back(lineIntersection(la2,lb3));
    intersections.push_back(lineIntersection(la2,lb4));

    intersections.push_back(lineIntersection(la3,lb1));
    intersections.push_back(lineIntersection(la3,lb2));
    intersections.push_back(lineIntersection(la3,lb3));
    intersections.push_back(lineIntersection(la3,lb4));

    intersections.push_back(lineIntersection(la4,lb1));
    intersections.push_back(lineIntersection(la4,lb2));
    intersections.push_back(lineIntersection(la4,lb3));
    intersections.push_back(lineIntersection(la4,lb4));


    int x_min=0;int x_max=0;
    int y_max=0;int y_min=0;

    if(a_width*a_height>b_width*b_height)
    {
        x_min = pa1.x;
        x_min=min(x_min,pa2.x);
        x_min=min(x_min,pa3.x);
        x_min=min(x_min,pa4.x);
        x_max = pa1.x;
        x_max=max(x_max,pa2.x);
        x_max=max(x_max,pa3.x);
        x_max=max(x_max,pa4.x);

        y_min = pa1.y;
        y_min=min(y_min,pa2.y);
        y_min=min(y_min,pa3.y);
        y_min=min(y_min,pa4.y);
        y_max = pa1.y;
        y_max=max(y_max,pa2.y);
        y_max=max(y_max,pa3.y);
        y_max=max(y_max,pa4.y);
    }else
    {
        x_min = pb1.x;
        x_min=min(x_min,pb2.x);
        x_min=min(x_min,pb3.x);
        x_min=min(x_min,pb4.x);
        x_max = pb1.x;
        x_max=max(x_max,pb2.x);
        x_max=max(x_max,pb3.x);
        x_max=max(x_max,pb4.x);

        y_min = pb1.y;
        y_min=min(y_min,pb2.y);
        y_min=min(y_min,pb3.y);
        y_min=min(y_min,pb4.y);
        y_max = pb1.y;
        y_max=max(y_max,pb2.y);
        y_max=max(y_max,pb3.y);
        y_max=max(y_max,pb4.y);
    }

    int cont=0;

    for(int i=0;i<(int)intersections.size();i++)
    {
        Point* point=intersections[i];
        if(point!=NULL)
        {
            if(point->x > x_min
               && point->x < x_max
               && point->y > y_min
               && point->y < y_max)
            {
                cont++;
            }
        }
    }

    vector<Point*>::iterator i;
    for ( i = intersections.begin() ; i < intersections.end(); i++ )
    {
        delete * i;
    }


    if(cont>=8)
        return true;
*/
    return false;
}