예제 #1
0
파일: form.c 프로젝트: jhallen/joes-sandbox
void outtext()
{
	int x;
	int flg = 0;
	for (x = 0; x != outx; ++x)
		if ((outbuf[x] & 255) == '~')
			flg = 1;
	if (flg) {
		int l = 0, r = outx;
		int b = maxabove(outbuf, outx);
		int h = maxheight(outbuf, outx);
		int ll;
		if ((outbuf[0] & 255) != '~') {
			for (l = 0; (outbuf[l] & 255) != '~'; ++l);
			tgen(0, b, 0, l);
		}
		if ((outbuf[outx - 1] & 255) != '~') {
			for (r = outx; (outbuf[r - 1] & 255) != '~'; --r);
			tgen(lwidth - width(outbuf + r, outx - r), b, r,
			     outx);
		}
		for (x = l, flg = 0; x != r; ++x)
			if ((outbuf[x] & 255) == '~')
				++flg;
		if (flg > 1) {
			ll = lwidth / flg;
			for (x = 0; x != flg - 1; ++x) {
				int zz;
				++l;
				for (zz = l; (outbuf[zz] & 255) != '~';
				     ++zz);
				cntrit(ll, l, zz, b);
				l = zz;
				ll += lwidth / flg;
			}
		}
		y += h;
	} else if (mode == 2);
	else {
		int start = 0;
		nad = 0;
		psu = 0;
		pad = 0;
		while (start != outx) {
			int lz, w, z = start, ow;
			if (start)
				w = width(outbuf, ind);
			else
				w = 0;
			do {
				lz = z;
				ow = w;
				while (z != outx
				       && (outbuf[z] & 0xFF) == 32)
					w += width(outbuf + z++, 1);
				while (z != outx
				       && (outbuf[z] & 0xFF) != 32)
					w += width(outbuf + z++, 1);
			} while (w <= lwidth && z != outx);
			if (w <= lwidth)
				lz = z;
			if (lz != start) {
				int b =
				    maxabove(outbuf + start, lz - start);
				int h =
				    maxheight(outbuf + start, lz - start);
				if (!fillmode)
					if (start)
						tgen(width(outbuf, ind), b,
						     start, lz);
					else
						tgen(0, b, start, lz);
				else if (start)
					fillt(width(outbuf, ind), b, start,
					      lz, lz == outx);
				else
					fillt(0, b, start, lz, lz == outx);
				y += h;
			}
			while (lz != outx && (outbuf[lz] & 0xFF) == 32)
				++lz;
			start = lz;
		}
	}
	outx = 0;
	ind = 2;
	mode = 0;
	fillmode = 0;
}
예제 #2
0
파일: main.cpp 프로젝트: eldesouky/Tetris
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();

   }
  }