C语言课程设计实验报告- 联系客服

发布时间 : 星期一 文章C语言课程设计实验报告-更新完毕开始阅读97194b940129bd64783e0912a216147916117e50

void draw_circle(int x,int y,int color) { setcolor(color); setlinestyle(SOLID_LINE,0,1); x=(x+JZ)*BILI; y=(y+JS)*BILI; circle(x,y,8); }

void draw_slice(int x,int y,int color) { x=(x+JZ)*BILI; y=(y+JS)*BILI; setcolor(color) ; setfillstyle(SOLID_FILL,color); circle(x,y,8); floodfill(x,y,color); setcolor(color); setfillstyle(SOLID_FILL,color); pieslice(x,y,0,360,8); setcolor(color); }

void judgekey() { int i; int j; switch(key) { case LEFT : if(step_x-1<0) break; else { for(i=step_x-1,j=step_y;i>=1;i--) if(box[i][j]==0) { draw_circle(step_x,step_y,LIGHTBLUE); break; } if (i<1) break; step_x=i; judgewho(step_x,step_y); break;

9

}

case RIGHT: if(step_x+1>18) break; else { for(i=step_x+1,j=step_y;i<=18;i++) if(box[i][j]==0) { draw_circle(step_x,step_y,LIGHTBLUE); break; } if(i>18) break; step_x=i; judgewho(step_x,step_y); break; }

case DOWN : if((step_y+1)>18) break; else { for(i=step_x,j=step_y+1;j<=18;j++) if(box[i][j]==0) { draw_circle(step_x,step_y,LIGHTBLUE); break; } if(j>18)break; step_y=j; judgewho(step_x,step_y); break; } case UP : if((step_y-1)<0) break; else { for(i=step_x,j=step_y-1;j>=1;j--) if(box[i][j]==0) { draw_circle(step_x,step_y,LIGHTBLUE); break; }

10

if(j<1)break; step_y=j; judgewho(step_x,step_y); break; } case ESC : break; case SPACE : if(step_x>=1 && step_x<=18 && step_y>=1 && step_y<=18) { if(box[step_x][step_y]==0) { box[step_x][step_y]=flag; if (flag == 1) { draw_slice(step_x, step_y, BLUE); } else { draw_slice(step_x, step_y, WHITE); }

if (judgeresult(step_x,step_y)==1) { sound(1000); delay(1000); nosound(); gotoxy(30,4); if(flag==1) { setbkcolor(BLUE); cleardevice(); setviewport(100,100,540,380,1); setfillstyle(1,2); setcolor(YELLOW); rectangle(0,0,439,279); floodfill(50,50,14); setcolor(12); settextstyle(1,0,5); outtextxy(20,20,\ setcolor(14); settextstyle(3,0,5); outtextxy(120,120,\

setcolor(14);

11

}

settextstyle(2,0,8); getch();

closegraph(); exit(0);

if(flag==2) { setbkcolor(BLUE); } } else break; } }

void change() { if(flag==1) flag=2; else flag=1; }

cleardevice(); setviewport(100,100,540,380,1); setfillstyle(1,2); setcolor(YELLOW); rectangle(0,0,439,279); floodfill(50,50,14); setcolor(12); settextstyle(1,0,8); outtextxy(20,20,\ setcolor(14); settextstyle(3,0,5); outtextxy(120,120,\ setcolor(14); settextstyle(2,0,8); getch(); closegraph(); exit(0); } }

change(); break;

12