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); }
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); }
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); }
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"); } }
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; }