Exemplo n.º 1
0
void MyKeyboard (unsigned char key, int x, int y)
{
    bool xl1=leftx(x1, yrange(y1));     bool xr1=rightx(x1, yrange(y1));
    bool xl2=leftx(x2, yrange(y2));     bool xr2=rightx(x2, yrange(y2));
    bool xl3=leftx(x3, yrange(y3));     bool xr3=rightx(x3, yrange(y3));
    bool xl4=leftx(x4, yrange(y4));     bool xr4=rightx(x4, yrange(y4));
    switch (key) {
        case 'z':
            if (x1 != 33 && x2 != 33 && x3 != 33 && x4 != 33 && xl1 && xl2 && xl3 && xl4){
            x1-=48;
            x2-=48;
            x3-=48;
            x4-=48;
            }
            break;
        case 'x':
            if (x1 != 465 && x2 != 465 && x3 != 465 && x4 != 465  && xr1 && xr2 && xr3 && xr4){
            x1+=48;
            x2+=48;
            x3+=48;
            x4+=48;
            }
            break;
        case 's':
            start=1;
            break;
        default:
      break;
    }
    
   }
Exemplo n.º 2
0
void MockSbigDetector::Capture(unsigned short start_x,
                               unsigned short start_y,
                               unsigned short width,
                               unsigned short height,
                               unsigned long exposure_time,
                               Mat* frame) {
  usleep(exposure_time * 1e4);

  Mat roi;
  Range xrange(start_x, start_x + width),
        yrange(start_y, start_y + height);
  image_(yrange, xrange).copyTo(*frame);
}
Exemplo n.º 3
0
void Display(){
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix();
    scoreC();
    glColor3f(01.0,0,0);
    char * stC[100];
    sprintf((char *)stC,"Score: %d",score );
    print(0,740,(char *)stC);
    glBegin(GL_LINES);
    glColor3f(1.0f,1.0f,1.0f);
    
    glVertex3f(10.0f, 10.0f, 0.0f);
    glVertex3f(10.0f, 740.0f, 0.0f);
    
    glVertex3f(490, 740.0f, 0.0f);
    glVertex3f(490, 10.0f, 0.0f);
    
    glVertex3f(490, 10.0f, 0.0f);
    glVertex3f(10.0f, 10.0f, 0.0f);
    glEnd( );
    
   if (start==1) {
    
    if (endgame) {
        glColor3f(01.0,0,0);
        char * stC[12];
        sprintf((char *)stC,"Game Over");
        print(200,450,(char *)stC);
        char * stC1[12];
        sprintf((char *)stC1,"Score: %d",score );
        print(210,430,(char *)stC1);
        glPopMatrix();
        glFlush();
        return;
    }
  if (!end) {
    if (count != 0) {
    for (int j=0; j < count;j++) {
        glBegin(GL_POINTS);
        r1=(double)points[j].r;
        g1=(double)points[j].g;
        b1=(double)points[j].b;
        xold=(double)points[j].x;
        yold=(double)points[j].y;
        glColor3f(r1,g1,b1);
        if (xold != NULL || yold!= NULL) {
               glVertex3f(xold, yold, 0);
        }
     
        glEnd();
    }
    }
    if (shoot== true) {
        
        // add the random shape intialization code
     //new_points = s4_int();
     new_points = shapes_intialization();
        shoot = false;
         x1 =new_points[0].x; x2=new_points[1].x;
         x3 =new_points[2].x; x4=new_points[3].x;
         y1=new_points[0].y;  y2=new_points[1].y;
         y3=new_points[2].y;  y4=new_points[3].y;
         r=new_points[0].r; g=new_points[0].g; b =new_points[0].b;
        
    }
  
    
    glBegin(GL_POINTS);
   
    glColor3d(r, g, b);
    glVertex3f(x1, y1, 0); //point a
    glVertex3f(x2, y2, 0); //point b
    glVertex3f(x3, y3, 0); //point c
    glVertex3f(x4, y4, 0); //point d
//  glVertex3f(33, y4, 0);
//  glVertex3f(81, y4, 0);
//  glVertex3f(129, y4, 0);
//  glVertex3f(369, y4, 0);
//  glVertex3f(417, y4, 0);
//  glVertex3f(465, y4, 0);
    glEnd();
    glPopMatrix();
    glFlush();
    x1_hy=maxheight(x1);
    x2_hy=maxheight(x2);
    x3_hy=maxheight(x3);
    x4_hy=maxheight(x4);
 
    if ((x1_hy == 36 || x2_hy == 36 || x3_hy == 36 || x4_hy == 36)&& begin ) {
            y1-=1 ;
            y2-=1 ;
            y3-=1 ;
            y4-=1 ;
            if ( y1==37 || y2==37  || y3==37  || y4==37 ) {
                begin = false;
            }
            glutPostRedisplay();
      

    }
    else if((y1)>(x1_hy+1) && y2>(x2_hy+1) && y3>(x3_hy+1) && y4>(x4_hy+1)){
        y1-=1 ;
        y2-=1 ;
        y3-=1 ;
        y4-=1 ;
        glutPostRedisplay();
    }
    else {
        square add_p1;
        add_p1.x=x1; add_p1.y=yrange(y1); add_p1.r=r; add_p1.g=g; add_p1.b=b;
        square add_p2;
        add_p2.x=x2; add_p2.y=yrange(y2); add_p2.r=r; add_p2.g=g; add_p2.b=b;
        square add_p3;
        add_p3.x=x3; add_p3.y=yrange(y3); add_p3.r=r; add_p3.g=g; add_p3.b=b;
        square add_p4;
        add_p4.x=x4; add_p4.y=yrange(y4); add_p4.r=r; add_p4.g=g; add_p4.b=b;
       
        points[count]=add_p1;
        count++;
        points[count]=add_p2;
        count++;
        points[count]=add_p3;
        count++;
        points[count]=add_p4;
        count++;
        end = isEnd();
        shoot=true;
        glutPostRedisplay();
    }
  }
  else {
   //   for (int i=0; i<count; i++) { // clearing the array
   //      points[i].x=0;
   //       points[i].y=0;
   //       points[i].r=0;
   //       points[i].g=0;
    //      points[i].b=0;
    //  }
      endgame=true;
     glutPostRedisplay();

  }}
 //   void animate(){
        
   // }
   else {
       glColor3f(01.0,0,0);
       char * stC[100];
       sprintf((char *)stC,"Please press S to start the game");
       print(100,450,(char *)stC);
       sprintf((char *)stC,"Press X to move the shape right");
       print(100,410,(char *)stC);
       sprintf((char *)stC,"Press Z to move the shape left");
       print(100,370,(char *)stC);
       glPopMatrix();
       glFlush();
       glutPostRedisplay();

   }
  }