Exemplo n.º 1
0
int drawturtle(int x, int row, int wseg, int hseg, int boardw, int boardh, int col, int board[][col])
{
    int xb,yc=boardh*row+4*hseg,hr=10,tr=5,i,it; //define parameters

    xb=x/boardw;
    if(xb<col && xb>=0)
        board[row][xb]=1; //update position of turtle on board
    if(xb+1<col && xb+1>=0)
        board[row][xb+1]=0; //reset previous position of turtle on board

    gfx_color(50,25,0); //dark brown color
    for(i=0; i<wseg; i++) //draws shell
        gfx_ellipse(x,yc,i,i);

    gfx_color(20,150,0); //green color
    for(i=0; i<hr; i++) //draws head
        gfx_ellipse(x-wseg,yc,i,i);

    for(i=tr; i>0; i--) //draws tail
        gfx_triangle(x+wseg,yc+i,x+wseg,yc-i,x+wseg+i,yc);

    if(x<0) //if turtle goes off board
        x=width; //reset position of turtle
    else
        x--; //decrement x to move left

    return x; //return new position of turtle

} //end drawturtle
Exemplo n.º 2
0
void drawPacman(int x,int y,int orientation,int mouthOpen){
  static int pacLoop=0;
  int i;
  gfx_color(255,255,0);
  gfx_fill_circle(x,y,radius/2-1);

  gfx_color(0,0,0);
  int r=radius/2-1;
  if(mouthOpen || pacLoop%2){
    switch(orientation){
        case up:
                gfx_fill_triangle(x-r,y-r,x+r,y-r,orientation);
                break;
        case down:
                gfx_fill_triangle(x-r,y+r,x+r,y+r,orientation);
                break;
        case right:
                gfx_fill_triangle(x+r,y-r,x+r,y+r,orientation);
                break;
        case left:
                gfx_fill_triangle(x-r,y-r,x-r,y+r,orientation);
                break;
    }
  }
  if(!mouthOpen)  pacLoop++;
}
Exemplo n.º 3
0
void move_asteroids(double astr[][5], double shots[][5], int x1ship, int y1ship, int x2ship, int y2ship, double *x, double *y, double *speed, double *theta, int score[])
{
 int i;
 double j;
 asteroids(astr);
 for(i=0; i<32; i++){
	if(astr[i][3]!=0){
		astr[i][0]=astr[i][0]+astr[i][4]*cos(astr[i][2]); 	//iterates asteroid coordinates
		astr[i][1]=astr[i][1]-astr[i][4]*sin(astr[i][2]);
		for(j=0; j<2*PI; j=j+PI/50){
			//the line below checks whether ship has collided with an asteroid
			if((astr[i][0]+astr[i][3]*cos(j))<=x1ship && (astr[i][1]-astr[i][3]*sin(j))<=y1ship && (astr[i][0]+astr[i][3]*cos(j+PI))>=x2ship && (astr[i][1]-astr[i][3]*sin(j+PI))>=y2ship){
				*speed=0;
				*theta=0;	//resets theta and speed
				
				death(astr, shots, x, y, score);
			}
		}
		if(astr[i][0]>=740){
                        astr[i][0]=1;
                } else if(astr[i][0]<=-40){
                        astr[i][0]=699;
                } else if(astr[i][1]>=740){      //this keeps the ship from flying off the screen
                        astr[i][1]=1;
                } else if(astr[i][1]<=-40){
                        astr[i][1]=699;
                }
		gfx_color(0, 170, 255);
		gfx_circle(astr[i][0], astr[i][1], astr[i][3]);
	 	gfx_color(255, 255, 255);
	}
 }
}
Exemplo n.º 4
0
int drawtruck(int x, int row, int wseg, int hseg, int boardw, int boardh, int num, int len, int col, int board[][col])
{
    int xb,xp=x,yp=boardh*row+hseg,h=5*hseg,w=len*boardw,i,ib;

    for(i=0; i<num; i++) {
        xb=xp/boardw;
        for(ib=xb; ib<col; ib++) { //update board
            if(ib<=xb+len && ib>=0)
                board[row][ib]=0;
            else if(board[row][ib]==0)
                board[row][ib]=1;
        } //end for(ib=xb;ib<col;ib++)

        gfx_color(120,120,120); //gray color
        gfx_fill_rectangle(xp,yp+hseg,w,h);

        gfx_color(255,255,0); //yellow color
        gfx_fill_rectangle(xp+wseg/2,yp,wseg/2,hseg);
        gfx_fill_rectangle(xp+wseg/2,yp+h+hseg,wseg/2,hseg);
        gfx_fill_rectangle(xp+w-wseg,yp,wseg/2,hseg);
        gfx_fill_rectangle(xp+w-wseg,yp+h+hseg,wseg/2,hseg);

        xp+=2*w;
    } //end for(i=0;i<num;i++)

    if(x+num*2*w<0) //if truck goes off board
        x=width; //reset position of truck
    else
        x--; //decrement position to move left

    return x; //return new position

} //end drawtruck
Exemplo n.º 5
0
int main()
{
  int xsize = 500;
  int ysize = 300;

  char c;

  // Open a new window for drawing.
  gfx_open(xsize, ysize, "Example Graphics Program");

  // Clear the background.
  gfx_clear();

  // Set the current drawing color 
  gfx_color(0,200,100);

  // Draw a triangle on the screen.
  gfx_line(100,100,200,100);
  gfx_line(200,100,150,150);
  gfx_line(150,150,100,100);

  // change color, and draw a circle
  gfx_color(200,100,50);
  gfx_circle(300,150,40);

  while(1) {
    // Wait for the user to press a character.
    c = gfx_wait();

    // Quit if it is the letter q.
    if(c=='q') break;
  }

  return 0;
}
Exemplo n.º 6
0
int drawcar(int x, int row, int wseg, int hseg, int boardw, int boardh, int num, int len, int col, int board[][col])
{
    int xb,yp=boardh*row+hseg,h=5*hseg,w=len*boardw,i,ib; //define parameters

    x+=4*w*num;

    for(i=0; i<num; i++) {
        xb=x/boardw;
        for(ib=xb+len; ib>=0; ib--) { //update board
            if(ib>=xb && ib<col)
                board[row][ib]=0;
            else if(board[row][ib]==0)
                board[row][ib]=1;
        } //end for(ib=xb+len;ib>=0;i--)

        gfx_color(255,0,255); //magenta color
        gfx_fill_rectangle(x,yp+hseg,w,h);

        gfx_color(255,255,0); //yellow color
        gfx_fill_rectangle(x+wseg/2,yp,wseg/2,hseg);
        gfx_fill_rectangle(x+wseg/2,yp+h+hseg,wseg/2,hseg);
        gfx_fill_rectangle(x+w-wseg,yp,wseg/2,hseg);
        gfx_fill_rectangle(x+w-wseg,yp+h+hseg,wseg/2,hseg);

        x-=4*w;
    } //end for(i=0;i<num;i++)

    if(x>width) //if car goes off board
        x=10-width; //reset position
    else
        x++; //increment position to move right

    return x; //return new position

} //end drawcar
Exemplo n.º 7
0
void yAxis(){
	int i,j;
	gfx_color(0,0,255);
	gfx_line(250,0,250,500);
	for(i=0,j=-10;i<=500,j<=10;i+=25,j++){
		gfx_line(240,i,260,i);
		gfx_color(255,255,255);
		gfx_text(225,i, num2str(j));
	}
}
Exemplo n.º 8
0
void xAxis(){
	int i,j;
	gfx_color(0,0,255);
	gfx_line(0,250,500,250);
	for(i=0,j=-10;i <= 500,j<=10; i+=25,j++){
		gfx_line(i,240,i,260);
		gfx_color(255,255,255);
		gfx_text(i,275, num2str(j));
	}
}
Exemplo n.º 9
0
int main () {
	int x, y, dx, dy, radius = 100;
	double pi, i = 0.07;
	char c;

	pi = M_PI;

	gfx_open(500,500,"Rotating Animation Emily");

	printf("To speed up display press f key; to slow down display press s key.\n");

	while (1) {
			drawPerson();

			x = radius*cos(i) + 250;
			y = radius*sin(i) + 150;
			gfx_color(0, 0, 255);
			gfx_circle(x, y, 20); //ball 1 (blue)
		
			x = radius*cos(i+1.5) + 250;
			y = radius*sin(i+1.5) + 150;
			gfx_color(0, 255, 0);
			gfx_circle(x, y, 20); //ball 2 (green)

			x = radius*cos(i+3.) + 250;
			y = radius*sin(i+3.) + 150;
			gfx_color(255, 0, 0);
			gfx_circle(x, y, 20); //ball 3 (red)
			

			gfx_flush();
			usleep(10000);
			gfx_clear();
			

			if (gfx_event_waiting()) {
				c = gfx_wait();
				if (c =='s') { //slows down juggling
					i-=0.1;
				} else if (c =='f') { //speeds  juggling
					i+=0.1;
				} else if (c =='q') {
					break;
				}
			}

			i+= 0.01;
		}

	
	

	return 0;
}
Exemplo n.º 10
0
void drawship(double x, double y, double theta, int go)
{
 int i;
 gfx_line(x, y, x+20*cos(theta+4*PI/3), y-20*sin(theta+4*PI/3));  //draws long 2 lines that make up ship
 gfx_line(x, y, x+20*cos(theta+5*PI/3), y-20*sin(theta+5*PI/3));
 gfx_line( x+16*cos(theta+4*PI/3), y-16*sin(theta+4*PI/3), x-16*cos(theta+5*10*PI/3), y-16*sin(theta+5*PI/3));  //draws back of ship
 if(go>0){	//go will be greater than 1 if ship is being propulsed forward
	gfx_color(255, 69, 0);
	for(i=0; i<5; i++){
		gfx_line( x+(17+i)*cos(theta+4*PI/3), y-(17+i)*sin(theta+4*PI/3), x-(17+i)*cos(theta+5*10*PI/3), y-(17+i)*sin(theta+5*PI/3));
	}
 }
 gfx_color(255, 255, 255);
}
Exemplo n.º 11
0
void plot(int num){
	double i;
	gfx_color(255,0,255);
	for(i = -10; i<= 10; i+=.005){
		gfx_point((i*25)+250,(Taylor(i,num)*-25)+250);		
	}
}
Exemplo n.º 12
0
int main()
{
	int ysize = 300;
	int xsize = 300;

	char c;

	// Open a new window for drawing.
	gfx_open(xsize,ysize,"Example Graphics Program");

	// Set the current drawing color to green.
	gfx_color(0,200,100);

	// Draw a triangle on the screen.
	gfx_line(100,100,200,100);
	gfx_line(200,100,150,150);
	gfx_line(150,150,100,100);

	while(1) {
		// Wait for the user to press a character.
		c = gfx_wait();
		if(c=='n')
		
		gfx_line(200,200,300,200);
		gfx_line(300,200,250,250);
		gfx_line(250,250,200,200);

		// Quit if it is the letter q.
		if(c=='q') break;
	}

	return 0;
}
Exemplo n.º 13
0
void uShooter(int xposS){
	gfx_color(24, 238, 0);
	gfx_fill_rectangle(xposS, YPOS, 30, 12);
	gfx_fill_rectangle(xposS+4,YPOS-2,23,2);// CHANGED BY KATIE TO MAKE SHIP
	gfx_fill_rectangle(xposS+12,YPOS-7,6,5);// FEEL FREE TO CHANGE ANYTHING
	gfx_fill_rectangle(xposS+14,YPOS-9,2,2);
}
Exemplo n.º 14
0
void draw_lengths(float sman[SIZE],int length,float xcent,float ycent,int spots,float head_r,int color){	//draws a stickman based on its angle matrix,
	gfx_color(color,color,color);										//center, whether you want spots, the length of
	int F;													//the limbs, the radius of the head, and color 
	float xp=xcent,yp=ycent,nx,ny;										//(so you can make a grey one to show where last
	for(F=0;F<SIZE;F++){											//frame was)
		nx=xp+length*cos(sman[F]);
		ny=yp-length*sin(sman[F]);
		if(F==0||F==1||F==4||F==5||F==8||F==9||F==10||F==13||F==14){
		draw_width(2.5,xp,yp,nx,ny);
		}
		if(spots==1){
			if(F==0||F==1||F==2||F==5||F==6||F==9||F==10||F==11||F==14||F==15){
				draw_spot(xp,yp,length/10,1,0,color);
			}
			if(F==17){
				nx=xp+head_r*2*cos(sman[F]);
				ny=yp-head_r*2*sin(sman[F]);
				draw_spot(nx,ny,length/10,1,0,color);
			}
		}
		if(F==SIZE-1){
			draw_spot(xp+(head_r)*cos(sman[F]),yp-(head_r)*sin(sman[F]),head_r,.3,1,color);
		}
		xp=nx;
		yp=ny;
	}
}
Exemplo n.º 15
0
int drawBird(double x, double y, double r, int flap){
	
    //body
    gfx_color(255,255,0);
    //gfx_fill_circle(x,y,r);
	gfx_fill_arc(x-16, y-16, 29, 24, 0, 360 );
    gfx_color(0,0,0);
    gfx_arc(x-16, y-16, 29, 24, 0, 360); 
    
    //eye ball
    gfx_color(255,255,255);
    gfx_fill_circle(x+7,y-7,(0.50)*r+1);

	//wings
    if(flap<=5){
        gfx_fill_arc(x-18,y-11,12, 6, 0, 360);
        gfx_color(0,0,0);
        gfx_arc(x-18,y-12,11, 6, 0, 360);
        flap++;
    }
    else if( (flap>=5)&&(flap<=10) ){
        gfx_fill_arc(x-18,y-7, 12, 6, 0, 360);
        gfx_color(0,0,0);
        gfx_arc(x-18,y-7, 12, 6, 0, 360);
        flap++;     
    }
    else{
        gfx_fill_arc(x-18,y-5,12, 6, 0, 360);
        gfx_color(0,0,0);
        gfx_arc(x-18,y-5,12, 6, 0, 360);
        flap--;
    }
    
    //pupil
    gfx_fill_rectangle(x+9,y-8,2,4);
    gfx_circle(x+7,y-7,(0.50)*r+1);

	//lips
    gfx_color(255,128,0);
    gfx_fill_arc(x+1, y-1, 16, 4, 0, 360); 
	gfx_fill_arc(x+1, y+3, 14, 3, 0 ,360); 

    gfx_color(0,0,0);
    gfx_arc(x+1, y+3, 14, 3, 0, 360);
    gfx_arc(x+1, y-1, 16, 4, 0, 360);  

    gfx_color(255,128,0);
    gfx_fill_rectangle(x+1,y+0,4,6);

    return flap;

}
Exemplo n.º 16
0
void drawBackground(int width, int height) {
    
    //draw clouds
    gfx_color(255, 255, 255);
    int i;
    for (i = 0; i<10; i++) {
        gfx_fill_circle(i*width/8, height - height/10, 50);
    }
    for (i = 0; i<3; i++) {
      gfx_fill_circle(i*width/3, height - height/7, 40);
  	}
    
    gfx_fill_circle(width*3/4+10, height - height/6+10, 45); 
    gfx_fill_circle(width*2/9-5, height - height/7, 45); 
    
    //draw buildings
    
    for (i = 0; i<5; i++) {
        //outlines
        gfx_color(200, 207, 201);
        gfx_rectangle(-30+i*width/4-1, height-60-1, 22, 60);
        gfx_rectangle(-30+i*width/4+20-1, height-55-1, 22, 55);
        gfx_rectangle(-30+i*width/4+25-1, height-45-1, 27, 45);
        gfx_rectangle(-30+i*width/4+30-1, height-75-1, 32, 75);
        gfx_rectangle(-30+i*width/4+30-1, height-80-1, 15, 80);
        gfx_rectangle(-30+i*width/4+50-1, height-62-1, 22, 62);
        gfx_rectangle(-30+i*width/4+55-1, height-55-1, 27, 55);
        //fills
        gfx_color(218, 227, 219);
        gfx_fill_rectangle(-30+i*width/4, height-60, 20, 60);
        gfx_fill_rectangle(-30+i*width/4+20, height-55, 20, 55);
        gfx_fill_rectangle(-30+i*width/4+25, height-45, 25, 45);
        gfx_fill_rectangle(-30+i*width/4+30, height-75, 30, 75);
        gfx_fill_rectangle(-30+i*width/4+30, height-80, 15, 80);
        gfx_fill_rectangle(-30+i*width/4+50, height-62, 20, 62);
        gfx_fill_rectangle(-30+i*width/4+55, height-55, 25, 55);
   
    }
    
    //draw greenery
    for (i = 0; i<10; i++) {
        gfx_color(107, 179, 118);
        gfx_circle(i*width/8, height - 5, 30);
        gfx_color(153, 224, 163);
        gfx_fill_circle(i*width/8, height - 5, 30);
    }
    for (i = 0; i<6; i++) {
        gfx_fill_circle(i*width/6, height - 5, 25);
    }
    for (i = 0; i<10; i++) {
        gfx_color(107, 179, 118);
        gfx_circle(i*width/8+20, height - 5, 24);
        gfx_color(153, 224, 163);
        gfx_fill_circle(i*width/8+20, height - 5, 24);
    }
   
    //draw base rectangle to cover outlines
    gfx_fill_rectangle(0, height-15, width, 15);
        
}
Exemplo n.º 17
0
int main()
{
  char fractal;
  int x=width/2,y=height/2,radius=width/3;
  int margin=20;	
  int x1=margin,x2=width-margin,x3=width/2,y1=margin,y2=margin,y3=height-margin;	
  gfx_open(width,height,"Fractals");
  gfx_clear_color(0,0,0);
  gfx_clear();
  gfx_color(255,255,255);
  printf("Which fractal would you like to see?\n1: Sierpinski Triangles\n2: Shrinking Squares\n3: Spiral Squares\n4: Circular Lace\n5: Snowflake\n6: Tree\n7: Fern\n8: Spiral of Spirals\n\n"); 
  while(fractal!='q'){
    fractal=gfx_wait();
    gfx_clear();
    switch(fractal){
      case 'q':
	return 0;
	break;
      case '1':
        printf("Sierpinski Triangles\n\n");
	sierpTriangles(x1,y1,x2,y2,x3,y3);
	break;
      case '2':
        printf("Shrinking Squares\n\n");
	shrinkSquares(x,y,width/4);
	break;
      case '3':
	printf("Spiral Squares\n\n");
        spiralSquares(x,y,-M_PI/4,width*2/3);
	break;
      case '4':
        printf("Circular Lace\n\n");
	circularLace(x,y,width);
	break;
      case '5':
        printf("Snowflake\n\n");
	snowflake(x,y,radius);
	break;
      case '6':
        printf("Tree\n\n");
	tree(x,height,x,height*3/4,0,height/4);
	break;
      case '7':
        printf("Fern\n\n");
	fern(width/2,height-margin,2*height/3,0);
	break;
      case '8':
        printf("Spiral of Spirals\n\n");
	spiralSpirals(x,y,0,width);
	break;
      default:
	printf("Please enter a valid option\n\n");
	break;
    }
  }  
}
Exemplo n.º 18
0
void draw_spot(float xp,float yp,int length,float dt,int filled,int color){	//draws the spots for all objects.  Also draws the stickmans head (thats why you can 
	if(filled==0){								//leave the circle unfilled and uncolored.
		gfx_color(color,color==100?100:0,color==100?color:0);
	}
	float F;
	float x1,y1,x2,y2;
	for(F=0;F<2*M_PI;F+=dt){
		x1=xp+length*cos(F);
		y1=yp-length*sin(F);
		x2=xp+length*cos(F+dt);
		y2=yp-length*sin(F+dt);
		if(filled==0){
			draw_width(2.5,xp,yp,x1,y1);
		}else{
			draw_width(2.5,x1,y1,x2,y2);
		}
	}
	gfx_color(color,color,color);
}
Exemplo n.º 19
0
void printScore(int score, int width){

    //Prints the score at the top of the screen
    gfx_color(255, 255, 255);
    gfx_changefont("-*-helvetica-bold-r-*-*-*-250-90-90-p-*-iso8859-1");
    char str[10];
    sprintf(str, "%d", score);
    gfx_text(width/2-5, 50, str);

}
Exemplo n.º 20
0
void drawAliens(int xdist, int ydist){
	int aliens[2][55] = {};
	unsigned int i, j;

	//hard code y values
	for(i=0; i<=10; i++){
		aliens[0][i] = 100 + ydist;

	}
	for(i=11; i<=21; i++){
		aliens[0][i] = 100 + ydist+30;

	}
	for(i=22; i<=32; i++){
		aliens[0][i] = 100 + ydist+ 2 * 30;

	}
	for(i=33; i<=43; i++){
		aliens[0][i] = 100 + ydist+ 3 *30;

	}
	for(i=44; i<=54; i++){
		aliens[0][i] = 100 + ydist + 4*30;

	}

	// hard code x values
	//now prints row by row in case we want to switch up the colors
	for(i=0; i<=10; i++){
		aliens[1][i] = 100 + xdist + 30*i;
		gfx_color(255,255,255);//White (classic game)
		gfx_fill_rectangle(aliens[1][i], aliens[0][i], 20, 20);// print the first row
	}
	for(i=11; i<=21; i++){
		aliens[1][i] = 100 + xdist + 30 * (i-11);
		gfx_fill_rectangle(aliens[1][i], aliens[0][i], 20, 20);//print the second row
	}
	for(i=22; i<=32; i++){
		aliens[1][i] = 100 + xdist + 30 * (i-22);
		gfx_fill_rectangle(aliens[1][i], aliens[0][i], 20, 20);

	}
	for(i=33; i<=43; i++){
		aliens[1][i] = 100 + xdist + 30 * (i-33);
		gfx_fill_rectangle(aliens[1][i], aliens[0][i], 20, 20);

	}
	for(i=44; i<=54; i++){
		aliens[1][i] = 100 + xdist + 30 * (i-44);
		gfx_fill_rectangle(aliens[1][i], aliens[0][i], 20, 20);

	}
	

}
Exemplo n.º 21
0
//begin main function
int main (void) 
{		
	int xsize = 800, ysize = 800 ;
	gfx_open( xsize, ysize, "Test Graph of Function triangle_waveform" ) ;

	int stillgoing = 1;

	while (stillgoing) {
		gfx_clear() ;
		gfx_color(255, 255, 255) ;	//axis is white		
		draw_axes( xsize, ysize) ;
		gfx_color(150, 0, 255) ;
		plot_triangle(xsize, ysize, -10., 10, .1) ;
		gfx_flush() ;

		char c = gfx_wait() ;
		if (c == 'q') stillgoing = 0 ;
	}
	return 0 ;
}	//end main		
Exemplo n.º 22
0
void draw_lives(int lives)
{
	int l, i;
 
	gfx_color(255,255,0); //yellow

	for (l=0; l<lives; l++)
    	for(i=0; i<10; i++)
        	gfx_circle(20+l*30,630,i);
       	 
} //end draw_lives
Exemplo n.º 23
0
int main() {
	int size = 500;
	int value = 1;
	int wait;
	int counter = 0;

	gfx_open(size, size, "Graphing Calculator");
	
	while(value != 0) {
		gfx_color(255, 255, 255);
		xAxis(size, size);
		yAxis(size, size);
		
		wait = gfx_wait();
		gfx_color(255, 0, 0);
		switch(wait) {
			case 1:
				gfx_clear();
				counter = 0;
				plot(size, size, counter);
				break;
			case '=':
				gfx_clear();
				counter++;
				plot(size, size, counter);
				break;
			case '-':
				gfx_clear();
				counter--;
				plot(size, size, counter);
				break;
			case 'q':
				value = 0;
				break;
			default:
				break;
		}
		printf("%i\n", counter);
	}
	return 0;
}
Exemplo n.º 24
0
void drawPipe(Pipe* pipe, int scrWidth, int scrHeight) {

	//draw filled bottom half
    gfx_color(45, 214, 70);
	gfx_fill_rectangle(pipe->leadingX, pipe->bottomHeight+30, pipe->width, scrHeight-pipe->bottomHeight-30); 
	gfx_fill_rectangle(pipe->leadingX-3, pipe->bottomHeight, pipe->width+6, 30);
    
    //draw filled top half
    gfx_fill_rectangle(pipe->leadingX, 0, pipe->width, pipe->topHeight);
    gfx_fill_rectangle(pipe->leadingX-3, pipe->topHeight-30, pipe->width+6, 30);
    
    
    //draw bottom half outline
    gfx_color(69, 71, 61);
    gfx_rectangle(pipe->leadingX, pipe->bottomHeight+30, pipe->width, scrHeight-pipe->bottomHeight-30);
    gfx_rectangle(pipe->leadingX-3, pipe->bottomHeight, pipe->width+6, 30);
    //top half outline
    gfx_rectangle(pipe->leadingX, -1, pipe->width, pipe->topHeight-30+1);
    gfx_rectangle(pipe->leadingX-3, pipe->topHeight-30, pipe->width+6, 30);
    
}
Exemplo n.º 25
0
void presentHomeScreen(int width, int height) {
    
    //present home screen
    gfx_color(255, 255, 255);
    gfx_changefont("-*-helvetica-bold-r-*-*-*-250-90-90-p-*-iso8859-1");
    gfx_text(width/2-88, 150, "GET READY");
    gfx_text(width/2-5, 50, "0");
    
    //draw spacebar
    gfx_color(255, 255, 255);
    gfx_fill_rectangle(width/2-100, height/2+60, 200, 30);
    gfx_changefont("-*-helvetica-bold-r-*-*-*-120-75-75-p-*-iso8859-1");
    gfx_color(206, 212, 214);
    gfx_text(width/2-20, height/2+80, "SPACE");
    gfx_rectangle(width/2-100, height/2+60, 200, 30);
    
    //draw tap notice
    gfx_color(206, 212, 214);
    gfx_fill_rectangle(width/2-13, height/2+120, 26, 26);
    gfx_color(250, 0, 46);
    gfx_fill_rectangle(width/2-12, height/2+121, 24, 24);
    gfx_color(255, 255, 255);
    gfx_changefont("-*-helvetica-bold-r-*-*-*-100-60-60-p-*-iso8859-1");
    gfx_text(width/2-8, height/2+136, "TAP");
    gfx_fill_rectangle(width/2-1, height/2+98, 2, 15);
    
    //draw background
    drawBackground(width, height);
    
}
Exemplo n.º 26
0
void drawRocket(float xc, float yc, float rotatet, int r)
{
	int i, j;
	// Draw Box
	gfx_color(255,255,255);
	for(i=1;i<=7;i+=2){
		gfx_line(xc+r*cos(rotatet+(i*pi)/4), yc+r*sin(rotatet+(i*pi)/4), xc+r*cos(rotatet+((i+2)*pi)/4), yc+r*sin(rotatet+((i+2)*pi)/4));
	}
	// Draw Triangle
	for(j=-1;j<=1;j+=2){
		gfx_line(xc+r*cos(rotatet+(j*pi)/4), yc+r*sin(rotatet+(j*pi)/4), xc+1.6*r*cos(rotatet), yc+1.6*r*sin(rotatet));
	}
}
Exemplo n.º 27
0
int drawlog(int x, int row, int wseg, int hseg, int boardw, int boardh, int len, int col, int board[][col])
{
    int yp=boardh*row+hseg,xb,i,i2; //define parameters

    xb=x/boardw;
    for(i=xb; i<=xb+len; i++)
        if(i>=0 && i<col)
            board[row][i]=1; //update board with position of log
    if(xb>0 && xb<=col)
        board[row][xb-1]=0; //update board by resetting previous position of log

    for(i=len-1; i>=0; i--) {
        gfx_color(150,75,0); //light brown color
        gfx_fill_rectangle(x+wseg/2+i*boardw,yp,2*wseg,hseg);
        gfx_fill_rectangle(x+i*boardw,yp+hseg,2*wseg,hseg);
        gfx_fill_rectangle(x+2.5*wseg+i*boardw,yp+hseg,wseg/2,hseg);
        gfx_fill_rectangle(x+i*boardw,yp+2*hseg,1*wseg,hseg);
        gfx_fill_rectangle(x+1.5*wseg+i*boardw,yp+2*hseg,1.5*wseg,hseg);

        gfx_color(100,50,0); //medium brown color
        gfx_fill_rectangle(x+i*boardw,yp+3*hseg,1.5*wseg,hseg);
        gfx_fill_rectangle(x+2*wseg+i*boardw,yp+3*hseg,wseg,hseg);
        gfx_fill_rectangle(x+i*boardw,yp+4*hseg,wseg/2,hseg);
        gfx_fill_rectangle(x+1.5*wseg+i*boardw,yp+4*hseg,wseg,hseg);
        gfx_fill_rectangle(x+2.5*wseg+i*boardw,yp+4*hseg,wseg/2,hseg);

        gfx_color(50,25,0); //dark brown color
        gfx_fill_rectangle(x+wseg/2+i*boardw,yp+5*hseg,2*wseg,hseg);
    } //end for(i=0;i<length;i++)

    if(x>width) //when log passes width
        x=10-width/2; //reset position
    else
        x++; //increment position to move right

    return x; //return new position

} //end drawlog
Exemplo n.º 28
0
void drawPerson(){

	//make body - half circle
	gfx_color(204, 0, 102);
	gfx_circle(250, 550, 100);
	usleep(500);

	//make head
	gfx_color(255, 255, 0);
	gfx_circle(250, 400, 50);
	usleep(500);
	//make face
	gfx_point(225, 400); //eye
	usleep(500);
	gfx_point(275, 400); //eye
	usleep(500);

	//make arms
	gfx_line(200, 460, 150, 370);
	gfx_line(300, 460, 350, 370);

	usleep(500);
}
Exemplo n.º 29
0
void move_shots(double shots[][5])
{
 int i, j;
 for(i=0; i<30; i++){
        if(shots[i][3]!=0){
                shots[i][0]=shots[i][0]+6*cos(shots[i][2]+PI/2);  //shots fired at angle ship is at
                shots[i][1]=shots[i][1]-6*sin(shots[i][2]+PI/2);
                if(shots[i][0]>=700){
                        shots[i][3]=0;
                } else if(shots[i][0]<=0){
                        shots[i][3]=0;
                } else if(shots[i][1]>=700){     //this kills shots when they leave the screen
                        shots[i][3]=0;
                } else if(shots[i][1]<=0){
                        shots[i][3]=0;
                }
                gfx_color(0,255,0);
                gfx_circle(shots[i][0], shots[i][1], shots[i][3]);
        	gfx_color(255,255, 255);
	}
 }
 gfx_flush();
}
Exemplo n.º 30
0
int checkDeath(Location *pacman,Location ghosts[],int xtopleft,int ytopleft,int boardHeight,int boardWidth,int height,int width,int lives,int state[],int *score,int newScore[],int frightenLoop[],int loop){
/* Returns 1 if death, returns 0 otherwise */
  int i,j,fright=0;
  for(i=blinky;i<=clyde;i++){
    if(pacman->x==ghosts[i].x && pacman->y==ghosts[i].y && state[i]==frighten){
	printf("Killed a Ghost");
	state[i]=dead;
	frightenLoop[i]=0;
	//Calculate how many ghosts are in the frightened state still to determine number of points
	for(j=0;j<=3;j++){
		if(state[j]==frighten){
			fright++;	
		}
	}
	gfx_color(255,255,255);
	switch(fright){
                case 0:
                        newScore[1]=pacman->x;
                        newScore[2]=pacman->y;
                        newScore[0]=1600;
                        *score+=1600;
                        break;
                case 1:
                        newScore[1]=pacman->x;
                        newScore[2]=pacman->y;
                        newScore[0]=800;
                        *score+=800;
                        break;
                case 2:
                        newScore[1]=pacman->x;
                        newScore[2]=pacman->y;
                        newScore[0]=400;
                        *score+=400;
                        break;
                case 3:
                        newScore[1]=pacman->x;
                        newScore[2]=pacman->y;
                        newScore[0]=200;
                        *score+=200;
                        break;
        }
    } else if(pacman->x==ghosts[i].x && pacman->y==ghosts[i].y && state[i]<frighten){
	printf("\n\nPacman Died\n\n");
	deathAnimation(pacman,ghosts,xtopleft,ytopleft,boardHeight,boardWidth,height,width,lives,state,*score,newScore,frightenLoop,loop); 
	return 1;
    } else { continue; }
  }
  return 0;
}