Beispiel #1
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);
    
}
Beispiel #2
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
Beispiel #3
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
Beispiel #4
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);
}
Beispiel #5
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);

	}
	

}
Beispiel #6
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;

}
Beispiel #7
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);
        
}
Beispiel #8
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);
    
}
Beispiel #9
0
static void draw_arrow(uint16_t x, uint16_t y, bool_t up)
{
    uint16_t i;

    gfx_set_color(up ? COLOR_DARK_GREEN : COLOR_DARK_RED);

    gfx_fill_rectangle(x-2, y, 4, 16);

    if(up)
        for(i = 0; i < 4; i++)
        {
            gfx_draw_line(x-2,y+i,x-8,y+6+i);
            gfx_draw_line(x+1,y+i,x+7,y+6+i);
        }
    else
        for(i = 0; i < 4; i++)
        {
            gfx_draw_line(x-2,y+15-i,x-8,y+9-i);
            gfx_draw_line(x+1,y+15-i,x+7,y+9-i);
        }
}
Beispiel #10
0
void perform_delayed_operation(uint16_t opId, bool_t pleaseWaitInfo)
{
    if(!isSensorBusy)
    {
        // Do immediately
        handle_delayed_operation_event(opId);
    }
    else
    {
        if(pleaseWaitInfo)
        {
            gfx_set_color(COLOR_BLACK);
            gfx_fill_rectangle(120, 100, 240, 72);
            gfx_set_color(COLOR_YELLOW);
            gfx_draw_rectangle(120, 100, 240, 72);
            gfx_set_text_pos(200, 130);
            gfx_set_font(&FONT_DIALOG_12);
            gfx_outtext("Please wait...", 20);
        }

        delayedOperation = opId;
        // ... and wait
    }
}
Beispiel #11
0
void drawBoard(int x,int y,int height,int width,int h,int w,int lives,int win,int score){	
/* This function draws the board in blue, one pixel wide borders
 * x and y are the coordinates of the top left corner of the board */
  gfx_color(0,0,255);
 
/* This loop draws the rectangles (1) in blue to prevent pacman from going over them
 * It also draws the dots (0) if pacman has not eaten them yet 
 * Also draws the big dots (7) if pacman has not eaten them yet */
  int i,j;
  for(i=0;i<rows;i++){
    for(j=0;j<columns;j++){
	if(board[i][j]==1){
	  gfx_color(0,0,255);
	  gfx_fill_rectangle(x+radius*j,y+radius*i,radius,radius);
	} else if(board[i][j]==0){//draws dots in place
	  gfx_color(255,200,0);
	  gfx_fill_rectangle(x+radius*(j+0.5)-2,y+radius*(i+0.5)-2,4,4);
	} else if (board[i][j]==7){//draw big dots
	  gfx_color(255,200,0);
          gfx_fill_circle(x+radius*(j+.5),y+radius*(i+.5),8);
	} else if(board[i][j]==8){
	  gfx_color(0,0,255);
          gfx_rectangle(x+radius*j,y+radius*i,radius,radius);
	}//printf("%i",board[i][j]); 
    }//printf("\n");
  }
/* This block draws borders for the board */
  gfx_color(0,0,255);
  gfx_line(x,y,x+width,y);			//top border
  gfx_line(x,y+height,x+width,y+height);	//bottom border
  gfx_line(x,y,x,y+radius*7);				//left top border    (above gap)
  gfx_line(x,y+radius*8,x,y+height);			//left bottom border (below gap)
  gfx_line(x+width,y,x+width,y+radius*7);		//right top border    (above gap)
  gfx_line(x+width,y+radius*8,x+width,y+height);	//right bottom border (below gap)

/* This block draws the score and number of lives left */
  gfx_color(255,255,255);
  gfx_text((w-width)/4-radius/2,h*1/2-2*radius/3,"LIVES:");
  gfx_text((w-width)/4-radius/2,h*.3-16,"SCORE:");
  gfx_text((w-width)/4-radius/2,h*.3,num2str(score));
  for(i=0;i<lives;i++){
    drawPacman((w-width)/4,h*1/2+radius*i,right,1);
  }
  if(lives<=0){
	gfx_color(255,255,255);
	gfx_text(w/2-27,h/2-8,"GAME OVER");
        gfx_text(w/2-48,h/2+8,"Play Again? (y/n)");	
  } else if(win==1){
	gfx_color(255,255,255);
        gfx_text(w/2-18,h/2-8,"WINNER!");	
        gfx_text(w/2-48,h/2+8,"Play Again? (y/n)");	
  } else if(win==2){
        gfx_color(255,255,255);
        gfx_text(w/2-18,h/2-8,"READY?");	
  } else if(win==3){
        gfx_color(255,255,255);
        gfx_text(w/2-8,h/2-8,"GO!"); 
  } else if(win==5){
        gfx_color(255,255,255);
        gfx_text(w/2-23,h/2-8,"YOU DIED");
        gfx_text(w/2-38,h/2+8,"Click 7 times");
  } else if(win==6){
        gfx_color(255,255,255);
        gfx_text(w/2-23,h/2-8,"YOU DIED");
        gfx_text(w/2-38,h/2+8,"Click 6 times");
  } else if(win==7){
        gfx_color(255,255,255);
        gfx_text(w/2-23,h/2-8,"YOU DIED");
        gfx_text(w/2-38,h/2+8,"Click 5 times");
  } else if(win==8){
        gfx_color(255,255,255);
        gfx_text(w/2-23,h/2-8,"YOU DIED");
        gfx_text(w/2-38,h/2+8,"Click 4 times");
  } else if(win==9){
        gfx_color(255,255,255);
        gfx_text(w/2-23,h/2-8,"YOU DIED");
        gfx_text(w/2-38,h/2+8,"Click 3 times");
  } else if(win==10){
        gfx_color(255,255,255);
        gfx_text(w/2-23,h/2-8,"YOU DIED");
        gfx_text(w/2-38,h/2+8,"Click 2 times");
  } else if(win==11){
        gfx_color(255,255,255);
        gfx_text(w/2-23,h/2-8,"YOU DIED");
        gfx_text(w/2-36,h/2+8,"Click 1 time");
  }
} 
Beispiel #12
0
void dashboard_draw_func(handle_t obj)
{
    gui_widget_t *w = (gui_widget_t *) obj;

    gfx_set_color(COLOR_BLACK);
    gfx_fill_rectangle(w->left, w->top, w->width, w->height);

    if(gui_widget_get_state(w, STATE_FOCUSED))
        gfx_set_color(COLOR_YELLOW);
    else
        gfx_set_color(COLOR_DARK_YELLOW);

    gfx_draw_rectangle(w->left, w->top, w->width, w->height);

    gfx_set_color(COLOR_WHITE);
    gfx_set_font(&FONT_DIALOG_12);
    gfx_set_text_pos(w->left + 10, w->top + 10);
    gfx_outtext("Pressure:", 100);
    gfx_set_text_pos(w->left + 10, w->top + 90);
    gfx_outtext("Humidity:", 100);
    gfx_set_text_pos(w->left + 10, w->top + 170);
    gfx_outtext("Temperature:", 100);

    if(w->extra != NULL)
    {
        dashboard_data_t *data = (dashboard_data_t*) w->extra;
        char buf[16];
        int16_t trend;

        // Min & max

        gfx_set_text_pos(w->left + 10, w->top + 60);
        gfx_set_color(COLOR_CYAN);
        gfx_outtext("min: ", 10);
        if(data->pressure.min != 0x8000)
            tiny_sprintf(stringCache, "%d1 hPa", data->pressure.min);
        else
            tiny_sprintf(stringCache, "---");
        gfx_set_color(data->alarmMask & ALARM_MIN_P ? COLOR_RED : COLOR_WHITE);
        gfx_outtext_ram(stringCache, 25);
        gfx_set_color(COLOR_CYAN);
        gfx_outtext(", max: ", 10);
        if(data->pressure.max != 0x8000)
            tiny_sprintf(stringCache, "%d1 hPa", data->pressure.max);
        else
            tiny_sprintf(stringCache, "---");
        gfx_set_color(data->alarmMask & ALARM_MAX_P ? COLOR_RED : COLOR_WHITE);
        gfx_outtext_ram(stringCache, 25);
        
        gfx_set_text_pos(w->left + 10, w->top + 140);
        gfx_set_color(COLOR_MAGENTA);
        gfx_outtext("min: ", 10);
        if(data->humidity.min != 0x8000)
            tiny_sprintf(stringCache, "%d2 %%RH", data->humidity.min);
        else
            tiny_sprintf(stringCache, "---");
        gfx_set_color(data->alarmMask & ALARM_MIN_H ? COLOR_RED : COLOR_WHITE);
        gfx_outtext_ram(stringCache, 25);
        gfx_set_color(COLOR_MAGENTA);
        gfx_outtext(", max: ", 10);
        if(data->humidity.max != 0x8000)
            tiny_sprintf(stringCache, "%d2 %%RH", data->humidity.max);
        else
            tiny_sprintf(stringCache, "---");
        gfx_set_color(data->alarmMask & ALARM_MAX_H ? COLOR_RED : COLOR_WHITE);
        gfx_outtext_ram(stringCache, 25);
        
        gfx_set_text_pos(w->left + 10, w->top + 220);
        gfx_set_color(COLOR_YELLOW);
        gfx_outtext("min: ", 10);
        if(data->temperature.min != 0x8000)
            tiny_sprintf(stringCache, "%d2 *C", data->temperature.min);
        else
            tiny_sprintf(stringCache, "---");
        gfx_set_color(data->alarmMask & ALARM_MIN_T ? COLOR_RED : COLOR_WHITE);
        gfx_outtext_ram(stringCache, 25);
        gfx_set_color(COLOR_YELLOW);
        gfx_outtext(", max: ", 10);
        if(data->temperature.max != 0x8000)
            tiny_sprintf(stringCache, "%d2 *C", data->temperature.max);
        else
            tiny_sprintf(stringCache, "---");
        gfx_set_color(data->alarmMask & ALARM_MAX_T ? COLOR_RED : COLOR_WHITE);
        gfx_outtext_ram(stringCache, 25);

        // TREND

        trend = (data->pressure.trend - data->pressure.trendLast);
        if(trend < 2 && trend > -2)
            draw_minus(w->left + 170, w->top + 38);
        else
        {
            draw_arrow(w->left + 170, w->top + 23, (bool_t) (trend > 0));
            tiny_sprintf(buf, "%c%d1", trend > 0? '+' : ' ', trend);
            gfx_set_text_pos(w->left + 150, w->top + 43);
            gfx_outtext_ram(buf, 16);
        }

        trend = (data->humidity.trend - data->humidity .trendLast);
        if (trend < 5 && trend > -5)
            draw_minus(w->left + 170, w->top + 118);
        else
        {
            draw_arrow(w->left + 170, w->top + 103, (bool_t) (trend > 0));
            tiny_sprintf(buf, "%c%d2", trend > 0? '+' : ' ', trend);
            gfx_set_text_pos(w->left + 150, w->top + 123);
            gfx_outtext_ram(buf, 16);
        }

        trend = (data->temperature.trend - data->temperature.trendLast);
        if (trend < 2 && trend > -2)
            draw_minus(w->left + 170, w->top + 198);
        else
        {
            draw_arrow(w->left + 170, w->top + 183, (bool_t) (trend > 0));
            tiny_sprintf(buf, "%c%d2", trend > 0? '+' : ' ', trend);
            gfx_set_text_pos(w->left + 150, w->top + 203);
            gfx_outtext_ram(buf, 16);
        }

        // Big digits
        
        gfx_set_font(&FONT_ARIALBLACK_36);
        gfx_set_color(COLOR_WHITE);
    
        gfx_set_text_pos(w->left + 10, w->top + 18);
        tiny_sprintf(stringCache, "%d1", data->pressure.val);
        gfx_outtext_ram(stringCache, 10);

        gfx_set_text_pos(w->left + 10, w->top + 98);
        tiny_sprintf(stringCache, "%d2", data->humidity.val);
        gfx_outtext_ram(stringCache, 10);

        gfx_set_text_pos(w->left + 10, w->top + 178);
        tiny_sprintf(stringCache, "%d2", data->temperature.val);
        gfx_outtext_ram(stringCache, 10);
    }
}
Beispiel #13
0
int presentEndScreen (int score, int highScore, int width, int height) {

    //present end screen
    gfx_color(255, 255, 255);
    gfx_changefont("-*-helvetica-bold-r-*-*-*-250-90-90-p-*-iso8859-1");
    gfx_text(width/2-88, 150, "GAME OVER");
    
    //draw score block
    gfx_color(0,0,0);
    gfx_fill_rectangle(50, 180, width-100, 164);
    gfx_color(237, 206, 111);
    gfx_fill_rectangle(54, 184, width-108, 156);
    gfx_color(209, 181, 98);
    gfx_fill_rectangle(61, 191, width-122, 142);
    gfx_color(245, 228, 176);
    gfx_fill_rectangle(62, 192, width-124, 140);
    
    //labels
    gfx_color(209, 181, 98);
    gfx_changefont("-*-helvetica-bold-r-*-*-*-160-85-85-p-*-iso8859-1");
    gfx_text(width/2-110, height/2-50, "MEDAL");
    gfx_text(width/2+50, height/2-50, "SCORE");
    gfx_text(width/2+65, height/2+8, "BEST");
    
    if (score > highScore) {
        highScore = score;
        //print new best label
        gfx_color(250, 0, 46);
        gfx_fill_rectangle(width/2+14, height/2-9, 46, 20);
        gfx_color(255, 255, 255);
        gfx_text (width/2+15, height/2+8, "NEW");
    }
    
    //scores
    gfx_changefont("-*-helvetica-bold-r-*-*-*-200-90-90-p-*-iso8859-1");
    char scoreStr[5], highScoreStr[5];
    sprintf(scoreStr, "%d", score);
    sprintf(highScoreStr, "%d", highScore);
    gfx_color(255, 255, 255);
    gfx_text(width/2+100, height/2-25, scoreStr);
    gfx_text(width/2+100, height/2+33, highScoreStr);
    
    
    //medals
    int red, green, blue;
    if (score > 40) {
        //platinum
        red = 245;
        green = 245;
        blue = 245;
    }
    else if (score > 30) {
        //gold
        red = 250;
        green = 239;
        blue = 82;
    }
    else if (score > 20) {
        //silver
        red = 214;
        green = 214;
        blue = 214;
    }
    else {
        //bronze
        red = 242;
        green = 152;
        blue = 87;
    }
    gfx_color(red, green, blue);
    gfx_fill_circle(width/2-80, height/2, 28);
    
    //medal bird
    int birdX = 105;
    int birdY = 264;
    
    //draw the bird    
    gfx_color(red, green, blue);
    gfx_fill_arc(birdX, birdY, 29, 24, 0, 360);
    
    gfx_color(red-60,green-20,blue);
    gfx_arc(birdX, birdY, 29, 24, 0, 360);
    
    gfx_color(red, green, blue);
    gfx_fill_circle(birdX+23,birdY+9,(0.50)*12+1);
    
    gfx_color(red-60,green-20,blue);
    gfx_circle(birdX+23,birdY+9,(0.50)*12+1);
    
    gfx_color(red, green, blue);
    gfx_fill_arc(birdX-2,birdY+4,11, 6, 0, 360);
    
    gfx_color(red-60,green-20,blue);
    gfx_arc(birdX-2,birdY+4,11, 6, 0, 360);
    
    gfx_color(red, green, blue);
    gfx_fill_arc(birdX+17, birdY+19, 14, 3, 0, 360);
    
    gfx_color(red-60,green-20,blue);
    gfx_arc(birdX+17, birdY+19, 14, 3, 0, 360);
    
    gfx_color(red, green, blue);
    gfx_fill_arc(birdX+17, birdY+15, 16, 4, 0, 360);
    
    gfx_color(red-60, green-20,blue);
    gfx_arc(birdX+17, birdY+15, 16, 4, 0, 360);
    
    gfx_color(red, green, blue);
    gfx_fill_rectangle(birdX+25,birdY+8, 2, 4);
    
    gfx_color(red-60,green-20,blue);
    gfx_rectangle(birdX+25,birdY+8, 2, 4);   
    
    //play again button
    gfx_color(0, 0, 0);
    gfx_fill_rectangle(width/2-79, height/2+96, 158, 28);
    gfx_color(255, 255, 255);
    gfx_fill_rectangle(width/2-77, height/2+98, 154, 24);
    gfx_color(250, 0, 46);
    gfx_fill_rectangle(width/2-75, height/2+100, 150, 20);
    gfx_color(255, 255, 255);
    gfx_changefont("-*-helvetica-bold-r-*-*-*-120-75-75-p-*-iso8859-1");
    gfx_text(width/2-38, height/2+115, "PLAY AGAIN");
    
	return highScore; 

}
Beispiel #14
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
Beispiel #15
0
static void draw_minus(uint16_t x, uint16_t y)
{
    gfx_set_color(COLOR_DARK_YELLOW);
    gfx_fill_rectangle(x-10, y+6, 20, 4);
}
Beispiel #16
0
char win(void)
{
  gfx_clear_color(0,0,255); //blue background
  gfx_clear();
  gfx_color(255,255,255); //white letters

  //You
  gfx_fill_rectangle(370,160,40,60);
  gfx_fill_rectangle(470,160,40,60);
  gfx_fill_rectangle(390,220,100,20);
  gfx_fill_rectangle(410,240,60,60);
 
  //yOu
  gfx_fill_rectangle(530,180,40,100);
  gfx_fill_rectangle(630,180,40,100);
  gfx_fill_rectangle(550,160,100,20);
  gfx_fill_rectangle(550,280,100,20);

  //yoU
  gfx_fill_rectangle(690,160,40,120);
  gfx_fill_rectangle(790,160,40,120);
  gfx_fill_rectangle(710,280,100,20);

  //Won
  gfx_fill_rectangle(370,350,40,140);
  gfx_fill_rectangle(470,350,40,140);
  gfx_fill_rectangle(410,430,20,40);
  gfx_fill_rectangle(430,410,20,40);
  gfx_fill_rectangle(450,430,20,40);

  //wOn
  gfx_fill_rectangle(530,370,40,100);
  gfx_fill_rectangle(630,370,40,100);
  gfx_fill_rectangle(550,350,100,20);
  gfx_fill_rectangle(550,470,100,20);

  //woN
  gfx_fill_rectangle(690,350,40,140);
  gfx_fill_rectangle(790,350,40,140);
  gfx_fill_rectangle(730,370,20,40);
  gfx_fill_rectangle(750,390,20,40);
  gfx_fill_rectangle(770,410,20,40);

  gfx_text(450,520,"Press any key to play Frogger. Press \'q\' to quit.");

  return gfx_wait();
}
Beispiel #17
0
char blood(void)
{
	gfx_clear_color(255,0,0);
	gfx_clear();

	gfx_color(255,255,255);

	//Game over
	gfx_fill_rectangle(330,160,100,20);  
	gfx_fill_rectangle(310,180,40,20);
	gfx_fill_rectangle(290,200,40,60);
	gfx_fill_rectangle(310,260,40,20);
	gfx_fill_rectangle(330,280,100,20);
	gfx_fill_rectangle(390,260,40,20);
	gfx_fill_rectangle(370,240,60,20);

	//gAme over
	gfx_fill_rectangle(450,200,40,100);
	gfx_fill_rectangle(470,180,40,20);
	gfx_fill_rectangle(490,160,60,20);
	gfx_fill_rectangle(530,180,40,20);
	gfx_fill_rectangle(550,200,40,100);
	gfx_fill_rectangle(490,240,60,20);

	//gaMe over
	gfx_fill_rectangle(610,160,40,140);
	gfx_fill_rectangle(650,180,20,40);
	gfx_fill_rectangle(670,200,20,40);
	gfx_fill_rectangle(690,180,20,40);
	gfx_fill_rectangle(710,160,40,140);

	//gamE over
	gfx_fill_rectangle(770,160,40,140);
	gfx_fill_rectangle(810,160,100,20);
	gfx_fill_rectangle(810,220,80,20);
	gfx_fill_rectangle(810,280,100,20);

	//game Over
	gfx_fill_rectangle(290,370,40,100);
	gfx_fill_rectangle(390,370,40,100);
	gfx_fill_rectangle(310,350,100,20);
	gfx_fill_rectangle(310,470,100,20);

	//game oVer
	gfx_fill_rectangle(450,350,40,80);
	gfx_fill_rectangle(550,350,40,80);
	gfx_fill_rectangle(470,430,40,20);
	gfx_fill_rectangle(530,430,40,20);
	gfx_fill_rectangle(490,450,60,20);
	gfx_fill_rectangle(510,470,20,20);

	//game ovEr
	gfx_fill_rectangle(610,350,40,140);
	gfx_fill_rectangle(650,350,100,20);
	gfx_fill_rectangle(650,410,80,20);
	gfx_fill_rectangle(650,470,100,20);

	//game oveR
	gfx_fill_rectangle(770,350,40,140);
	gfx_fill_rectangle(810,350,80,20);
	gfx_fill_rectangle(870,370,40,60);
	gfx_fill_rectangle(850,410,20,20);
	gfx_fill_rectangle(810,430,60,20);
	gfx_fill_rectangle(830,450,60,20);
	gfx_fill_rectangle(860,470,60,20);

	//directions to continue
	gfx_text(450, 520, "Press any key to play Frogger again. Press \'q\' to quit.");

	return gfx_wait();
} //end blood
Beispiel #18
0
void dispScore(void){
	gfx_color(24, 238, 0);
	gfx_text(3,10,"SCORE");//to be used to display score
	gfx_fill_rectangle(0,498,800,2);
}
Beispiel #19
0
void drawGhost(int x,int y,int ghost,int orientation,int state[],int frightenLoop){
/* ghost is the number of ghost to draw
 * 0:blinky, 1:pinky, 2:inky, 3:clyde */
  static int ghostLoop[4]={0,1,1,0};
  int f; //f determines whether a frightened ghost is white or blue (flashes at end of frightened state)
  if(frightenLoop>=20 && state[ghost]==frighten){ f=frightenLoop%2; } else { f=-1; }
/* Choose color */
  if(state[ghost]==frighten){
     if(!f){ gfx_color(0,0,150); } else if(f==1){ gfx_color(255,255,255); } else {gfx_color(0,0,150);}
  } else {
     switch(ghost){
	case blinky: 
		gfx_color(255,0,0); 
		ghostLoop[blinky]++;
		break; 
	case pinky: 
		gfx_color(255,150,200); 
		ghostLoop[pinky]++;
		break; 	
	case inky: 	
		gfx_color(0,255,255); 
		ghostLoop[inky]++;
		break;		
	case clyde: 
		gfx_color(255,130,0); 
		ghostLoop[clyde]++;
		break;
     } 
  }

/* Draw body */
  int P=radius/10;	//value that helped make the ghosts look better
  int i,r=radius/2-P;
 if(state[ghost]!=dead){
   gfx_fill_circle(x,y-P,r);
  for(i=0;i<=r;i++){//left leg
    	gfx_line(x-r+i,y-P,   x-r+i,  y+r-i);
  }
  for(i=1;i<=r;i++){//right leg
    	gfx_line(x+i, y-P,    x+i,    y+i);
  }
  gfx_fill_rectangle(x-r,y-P,2*r,r);
    
  if(ghostLoop[ghost]%2){
    for(i=0;i<r;i++){//right middle leg
      	gfx_line(x+i, y-P,    x+i,    y+r-i);
    }
    for(i=0;i<=r;i++){//left middle leg
    	gfx_line(x-r+i, y-P,    x-r+i,    y+i);
    }
  } else {
    for(i=3*P/2;i<=r;i++){//left middle leg
    	gfx_line(x-i, y-P,    x-i,    y+r+3*P/2-i);
    }
    for(i=3*P/2;i<=r;i++){//right leg
    	gfx_line(x+i,   y-P,    x+i,    y+r+3*P/2-i);
    }
  }
 }

/* Add the eyes based on orientation *
 * Frightened ghosts will have two whit dot eyes and a mouth
 * Values for all circle centers are made by trial and error, until the ghost looked good */
  gfx_color(255,255,255);
  if(state[ghost]==frighten){
    if(f==1){gfx_color(0,0,150);}
	gfx_fill_circle(x-4*r/10,y-2*P,r/4);
        gfx_fill_circle(x+4*r/10,y-2*P,r/4);
	//next six are the mouth
	gfx_line(x-r,y+2*P,x-2*r/3,y+P);
	gfx_line(x-2*r/3,y+P,x-r/3,y+2*P);
	gfx_line(x-r/3,y+2*P,x,y+P);
	gfx_line(x,y+P,x+r/3,y+2*P);
	gfx_line(x+r/3,y+2*P,x+2*r/3,y+P);
	gfx_line(x+2*r/3,y+P,x+r,y+2*P);
  } else {
	gfx_fill_circle(x-4*r/10,y-2*P,r/3);
        gfx_fill_circle(x-4*r/10,y-3*P/2,r/3);
        gfx_fill_circle(x+4*r/10,y-2*P,r/3);
        gfx_fill_circle(x+4*r/10,y-3*P/2,r/3);

/* Now on to the pupils */        
     gfx_color(0,0,150);
     switch(orientation){
        case up:
        /*pupils*/      
                gfx_fill_circle(x-4*r/10,y-11*P/4,r/6);
                gfx_fill_circle(x+4*r/10,y-11*P/4,r/6);
                break;
        case down:
                gfx_fill_circle(x-4*r/10,y-3*P/4,r/6);/*pupils are 1/2 radius of the entire eye */
                gfx_fill_circle(x+4*r/10,y-3*P/4,r/6);
                break;
        case left:
                gfx_fill_circle(x-4*r/10-3*P/4,y-7*P/4,r/6);
                gfx_fill_circle(x+4*r/10-3*P/4,y-7*P/4,r/6);
                break;
        case right:
                gfx_fill_circle(x-4*r/10+3*P/4,y-7*P/4,r/6);
                gfx_fill_circle(x+4*r/10+3*P/4,y-7*P/4,r/6);
                break;
      }
  }
}
Beispiel #20
0
char welcome(void)
{
	gfx_clear_color(0,255,0); //green
	gfx_clear();

	gfx_color(255,255,255);

	//Frogger
	gfx_fill_rectangle(50,160,40,140);
	gfx_fill_rectangle(90,160,100,20);
	gfx_fill_rectangle(90,220,80,20);

	//fRogger
	gfx_fill_rectangle(210,160,40,140);
	gfx_fill_rectangle(250,160,80,20);
	gfx_fill_rectangle(310,180,40,60);
	gfx_fill_rectangle(290,220,20,20);
	gfx_fill_rectangle(250,240,60,20);
	gfx_fill_rectangle(270,260,60,20);
	gfx_fill_rectangle(300,280,60,20);

	//frOgger
	gfx_fill_rectangle(370,180,40,100);
	gfx_fill_rectangle(470,180,40,100);
	gfx_fill_rectangle(390,160,100,20);
	gfx_fill_rectangle(390,280,100,20);

	//froGger
	gfx_fill_rectangle(570,160,100,20);  
	gfx_fill_rectangle(550,180,40,20);
	gfx_fill_rectangle(530,200,40,60);
	gfx_fill_rectangle(550,260,40,20);
	gfx_fill_rectangle(570,280,100,20);
	gfx_fill_rectangle(630,260,40,20);
	gfx_fill_rectangle(610,240,60,20);

	//frogGer
	gfx_fill_rectangle(730,160,100,20);  
	gfx_fill_rectangle(710,180,40,20);
	gfx_fill_rectangle(690,200,40,60);
	gfx_fill_rectangle(710,260,40,20);
	gfx_fill_rectangle(730,280,100,20);
	gfx_fill_rectangle(790,260,40,20);
	gfx_fill_rectangle(770,240,60,20);

	//froggEr
	gfx_fill_rectangle(850,160,40,140);
	gfx_fill_rectangle(890,160,100,20);
	gfx_fill_rectangle(890,220,80,20);
	gfx_fill_rectangle(890,280,100,20);

	//froggeR
	gfx_fill_rectangle(1010,160,40,140);
	gfx_fill_rectangle(1050,160,80,20);
	gfx_fill_rectangle(1110,180,40,60);
	gfx_fill_rectangle(1090,220,20,20);
	gfx_fill_rectangle(1050,240,60,20);
	gfx_fill_rectangle(1070,260,60,20);
	gfx_fill_rectangle(1100,280,60,20);

	gfx_text(530,325, "CSE20211: Final Project");
	gfx_text(510,345, "Sara Cunningham and Jenna Wilson");
	gfx_text(470,365, "Press any key to play Frogger. Press \'q\' to quit");

	return gfx_wait();
} //end welcome
Beispiel #21
0
void deathAnimation(Location *pacman,Location ghosts[],int xtl,int ytl,int boardHeight,int boardWidth,int height,int width,int lives,int state[],int score,int newScore[],int frightenLoop[],int loop){
/* Death animation is in four states, first full circle, then pacman oriented upward, then half circle, then small sliver below, then gone, then explode */
  int r=radius/2-1;
  int timer=1000000;
  int x=xtl+pacman->x*radius+radius/2;   //first location to draw, will increment 5 times
  int y=ytl+pacman->y*radius+radius/2;
  
  animateMotion(xtl,ytl,boardHeight,boardWidth,pacman,ghosts,height,width,lives,state,score,newScore,frightenLoop,loop);
  gfx_wait();

  gfx_clear();
  drawBoard(xtl,ytl,boardHeight,boardWidth,height,width,lives,5,score);
  gfx_color(255,255,0);
  gfx_fill_circle(x,y,radius/2-1);
  //gfx_wait();

  gfx_wait();
  //usleep(timer);
  gfx_clear();
  drawBoard(xtl,ytl,boardHeight,boardWidth,height,width,lives,6,score);
  drawPacman(x,y,up,1);

  gfx_wait();
  //usleep(timer);
  gfx_clear();
  drawBoard(xtl,ytl,boardHeight,boardWidth,height,width,lives,7,score);
  gfx_color(255,255,0);
  drawPacman(x,y,0,0);
  gfx_color(0,0,0);
  gfx_fill_rectangle(x-radius/2-1,y-radius/2+1,radius,radius/2-1);

  gfx_wait();
  //usleep(timer);  
  gfx_clear();
  drawBoard(xtl,ytl,boardHeight,boardWidth,height,width,lives,8,score);
  gfx_color(255,255,0);
  gfx_fill_circle(x,y,radius/2-1);
  gfx_color(0,0,0);
  gfx_fill_triangle(x-r,y-r,x+r,y-r,up);
  gfx_fill_triangle(x+r,y-r,x+r,y+r,right);
  gfx_fill_triangle(x-r,y-r,x-r,y+r,left);

  gfx_wait();
  //usleep(timer); 
  gfx_clear();
  drawBoard(xtl,ytl,boardHeight,boardWidth,height,width,lives,9,score);

  gfx_wait();
  //usleep(timer);
  gfx_clear();
  drawBoard(xtl,ytl,boardHeight,boardWidth,height,width,lives,10,score);
  gfx_color(255,255,0);

  float angle=2*M_PI/5;       //partial snowflake
  int i,xnew[5],ynew[5];
  for(i=1;i<=5;i++){
    xnew[i-1]=x+r*cos(i*angle+3*M_PI/2);
    ynew[i-1]=y+r*sin(i*angle+3*M_PI/2);
    gfx_line(x,y,xnew[i-1],ynew[i-1]);
  }

  gfx_wait();
  //usleep(timer);
  gfx_clear();
  drawBoard(xtl,ytl,boardHeight,boardWidth,height,width,lives,11,score);
  gfx_color(255,255,0);
  angle=2*M_PI/5;              //snowflake with short lines
  for(i=1;i<=5;i++){
    xnew[i-1]=x+r*cos(i*angle+3*M_PI/2);
    ynew[i-1]=y+r*sin(i*angle+3*M_PI/2);
    gfx_line((x+xnew[i-1])/2,(y+ynew[i-1])/2,xnew[i-1],ynew[i-1]);
  }
  gfx_wait();
  //usleep(timer);
}
Beispiel #22
0
void background(int w,int h,int level)
{  
	int wnum=50,wseg=w/wnum,hnum=100,hseg=h/hnum,i,ic; //define parameters
   
	gfx_clear_color(0,0,0);
	gfx_clear();
	gfx_color(255,255,255); //white
 	gfx_text(w/2, h-20, "Use arrow keys to navigate frog safely to a lilly pad. Do not get hit by a car or fall in the water.");
 	gfx_text(w/4,h-20,"LEVEL: ");
 	gfx_text(w/4+50,h-20,num2str(level));
 
	gfx_color(20,0,150); //blue color
	gfx_fill_rectangle(0,0,w,h/2); //draws water
    
	gfx_color(20,150,0); //green color
	gfx_fill_rectangle(0,0,w,hseg); //draws top green border
    
	for(i=0;i<6;i++) //draws lily pads
    	for(ic=1;ic<(3*hseg);ic++) //increment radius to fill circle
        	gfx_circle((i*8+5)*wseg,5*hseg,ic);
       	 
	for(i=0;i<wnum;i++){ //draws pad details
    	if((i+2)%4!=0)
        	gfx_fill_rectangle(wseg*i*2,hseg,2*wseg,hseg);
       	 
    	if((i+1)%8<4){
        	switch((i+2)%4){
            	case 1:
                	gfx_fill_rectangle(wseg*i,2*hseg,wseg,hseg);
                	gfx_fill_rectangle(wseg*i,4*hseg,wseg,2*hseg);
                	break;
            	case 2:
                	gfx_fill_rectangle(wseg*i,3*hseg,wseg,2*hseg);
                	gfx_fill_rectangle(wseg*i,6*hseg,wseg,1*hseg);
                	break;
            	case 3:
                	gfx_fill_rectangle(wseg*i,2*hseg,wseg,2*hseg);
                	gfx_fill_rectangle(wseg*i,5*hseg,wseg,2*hseg);
                	break;
            	case 0:
                	gfx_fill_rectangle(wseg*i,2*hseg,wseg,hseg);
                	gfx_fill_rectangle(wseg*i,4*hseg,wseg,2*hseg);
                	break;
        	} //end switch((i+2)%4)
    	} //end if((i+1)%8<4)
   	 
    	switch(i%8){ //draw middle grass
            	case 0:
            	case 1:
            	case 3:
            	case 6:
                	gfx_fill_rectangle(wseg*i,(h/2)-(4*hseg),wseg,5*hseg);
                	break;
            	case 2:
            	case 7:
                	gfx_fill_rectangle(wseg*i,(h/2)-(5*hseg),wseg,7*hseg);
                	break;
            	case 4:
                	gfx_fill_rectangle(wseg*i,(h/2)-(4*hseg),wseg,6*hseg);
                	break;
            	case 5:
                	gfx_fill_rectangle(wseg*i,(h/2)-(5*hseg),wseg,6*hseg);
                	break;
        	} //end switch((i+2)%4)
       	 
    	switch(i%8){ //draw bottom grass
        	case 0:
        	case 1:
        	case 3:
        	case 6:
            	gfx_fill_rectangle(wseg*i,h-(18*hseg),wseg,5*hseg);
            	break;
        	case 2:
        	case 7:
            	gfx_fill_rectangle(wseg*i,h-(19*hseg),wseg,7*hseg);
            	break;
        	case 4:
            	gfx_fill_rectangle(wseg*i,h-(18*hseg),wseg,6*hseg);
            	break;
        	case 5:
            	gfx_fill_rectangle(wseg*i,h-(19*hseg),wseg,6*hseg);
            	break;
    	} //end switch((i+2)%4)
   	 
	} //end for(i=0;i<wnum;i++)
    
	gfx_color(150,75,0); //brown color
	for(i=0;i<wnum;i++){ //draws grass details
    	switch(i%8){ //draw middle grass details
            	case 0:
            	case 1: break;
            	case 3:
            	case 6:
                	gfx_fill_rectangle(wseg*i,(h/2)-(2*hseg),wseg,hseg);
                	break;
            	case 2:
            	case 7:
                	gfx_fill_rectangle(wseg*i,(h/2)-(4*hseg),wseg,hseg);
                	break;
            	case 4:
                	gfx_fill_rectangle(wseg*i,(h/2)-(3*hseg),wseg,hseg);
                	break;
            	case 5:
                	gfx_fill_rectangle(wseg*i,(h/2)-hseg,wseg,hseg);
                	break;
        	} //end switch((i+2)%4)
       	 
        	switch(i%8){ //draw bottom grass details
            	case 0:
            	case 1: break;
            	case 3:
            	case 6:
                	gfx_fill_rectangle(wseg*i,h-(16*hseg),wseg,hseg);
                	break;
            	case 2:
            	case 7:
                	gfx_fill_rectangle(wseg*i,h-(18*hseg),wseg,hseg);
                	break;
            	case 4:
                	gfx_fill_rectangle(wseg*i,h-(17*hseg),wseg,hseg);
                	gfx_fill_rectangle(wseg*i,h-(14*hseg),wseg,hseg);
                	break;
            	case 5:
                	gfx_fill_rectangle(wseg*i,h-(15*hseg),wseg,hseg);
                	break;
        	} //end switch((i+2)%4)
       	 
	} //end for(i=0;i<wnum;i++)
    
} //end background
Beispiel #23
0
void titleScreen(int height,int width,Location ghosts[],Location *pacman,int state[]){
/*Draws the title screen */
  int i=-1,x,y;
  gfx_clear();
  gfx_color(255,255,255);
  gfx_text(width*.35+10,height*.8,"Programmed By: CORY JBARA");
  gfx_text(width*.7,height*.8-32,"Use the arrow keys to move");
  gfx_text(width*.7,height*.8,"Press any button to start");
  
/* Draw dots and point values */
  gfx_color(255,200,0);
  gfx_fill_rectangle(width*.8-2,height/2-15,4,4);
  gfx_color(255,255,255);
  gfx_text(width*.8+10,height/2-9,"- 10 Points");

  gfx_color(255,200,0);
  gfx_fill_circle(width*.8-4,height/2+15,8);
  gfx_color(255,255,255);
  gfx_text(width*.8+10,height/2+20,"- 50 Points");
  
/* Draws ghosts and their names */  
  x=width/3;
  y=height*.45+i*height/15;
  gfx_text(x,y,"CHARACTER ------------------------ NICKNAME");
  
  for(i=0;i<4;i++){
	state[i]=chase;
	x=width/4;
	y=height*.45+i*height/15;
	drawGhost(x,y,i,right,state,0);
	
	x=width/3;
	switch(i){
	    case blinky:
                gfx_color(255,0,0);
		gfx_text(x,y,"SHADOW  -------------------------- \"BLINKY\"");
                break;
            case pinky:
                gfx_color(255,150,200);
		gfx_text(x,y,"SPEEDY  -------------------------- \"PINKY\"");
                break;
            case inky:
                gfx_color(0,255,255);
		gfx_text(x,y,"BASHFUL -------------------------- \"INKY\"");
                break;
            case clyde:
                gfx_color(255,130,0);
		gfx_text(x,y,"POKEY   -------------------------- \"CLYDE\"");
                break;
     	}
  }
/* Pacman being chased */
  i++;
  y=height*.72;
  for(i=0;i<=3;i++){
	x=width*.4+i*width/20;
        drawGhost(x,y,i,left,state,0);
  }
  drawPacman(width*.4-width/20,y,left,1);

/* P */
  gfx_color(255,255,0);
  gfx_fill_rectangle(10,height/5-50,width/15,150);
  gfx_fill_circle(10+width/15,height/5,50);
  gfx_color(0,0,0);
  gfx_fill_circle(10+width/15,height/5,10);

/* A */
  gfx_color(255,255,0);
  int loop=0;
  int x1=width*.1;
  int x2=width*.27;
  int center=(x1+x2)/2;
  y=height/5+100-1;
  while(x1<x2){//down
        gfx_line(x1,y,x2,y);
    if(loop%2){
        x1++;
        x2--;
    }
        y--;
    	loop++;
  }
  gfx_color(0,0,0);
  gfx_fill_circle(center,height*.24,10);

/* C ::::: Code copied from drawPacman*/
  int rad=200;
  x=width*.24+rad/2;
  y=height/5;
  gfx_color(255,255,0);
  gfx_fill_circle(x,y,rad/2-1);

  gfx_color(0,0,0);
  int r=rad/2-1;
  gfx_fill_triangle(x+r,y-r,x+r,y+r,right);

/* M */
  gfx_color(255,255,0);
  x=width*.47;
  y=height/5-50;
  gfx_fill_rectangle(x,y,width*.15,150);
  gfx_color(0,0,0);
  gfx_fill_triangle(x,y,x+width*.15,y,up);

/* A */
  gfx_color(255,255,0);
  loop=0;
  x1=width*.63;
  x2=width*.17 +x1;
  center=(x1+x2)/2;
  y=height/5+100-1;
  while(x1<x2){//down
        gfx_line(x1,y,x2,y);
    if(loop%2){
        x1++;
        x2--;
    }
        y--;
        loop++;
  }
  gfx_color(0,0,0);
  gfx_fill_circle(center,height*.24,10);

/* N */
  gfx_color(255,255,0);
  x=width*.81;
  y=height/5-50;
  gfx_fill_rectangle(x,y,width*.15,150);
  gfx_color(0,0,0);
  x-=2;
  y-=height/10;
  gfx_fill_triangle(x+width*.1,y,x+width*.1,y+height*.2,right);
}