老师让我用c语言画一个小球平抛轨迹图#include <winbgim.h>#include <conio2.h>#include <math.h>#include <time.h>#define PI 3.1415926int main(){time_t now;int x,y;initwindow(1000,700); //open a 640x480 graphics windowsetcolor(WHITE); circle(100,50,10); //Draw a circlefloodfill(100,50,WHITE);//在圆内填充白色; bar(0,60,100,65);//上面板 bar(100,565,850,570);//下面板setcolor(WHITE);now=time(NULL); setwritemode(1);while(now==1000){x=100+100*now;y=50+(1/2)*10*now*now;setcolor(WHITE);cricle(x,y,10);delay(1000/24);cricle(x,y,10); }getch(); //wait for user to press a keyclosegraph(); //close graphics windowreturn 0;}
1 回答
蛊毒传说
TA贡献1895条经验 获得超3个赞
circle函数是TURBO C提供的图形接口,用来画圆。不属于标准库函数,不具备可移植性。
函数名:circle
功 能: 在给定半径以(x, y)为圆心画圆
用 法:void far circle(int x, int y, int radius)
随时间变化,可以用cleardevice函数清除屏幕,不断画半径不同的圆。看起来就像是一个随时间变化的圆形。
函数名: cleardevice
功 能: 清除图形屏幕
用 法: void far cleardevice(void);
例程:
#include <graphics.h>#include <stdlib.h>#include <stdio.h>#include <conio.h>int main(void){/* request auto detection */int gdriver = DETECT, gmode, errorcode;int midx, midy;int radius = 100;/* initialize graphics and local variables */initgraph(&gdriver, &gmode, "");/* read result of initialization */errorcode = graphresult();if (errorcode != grOk) /* an error occurred */{printf("Graphics error: %s\n", grapherrormsg(errorcode));printf("Press any key to halt:");getch();exit(1); /* terminate with an error code */}midx = getmaxx() / 2;midy = getmaxy() / 2;setcolor(getmaxcolor());for(i=0;i<1000000;i++) if(i%50000==0){ cleardevice();/* clean the screen */ circle(midx, midy, radius--);/* draw the circle */}getch();closegraph();return 0;} |
- 1 回答
- 0 关注
- 299 浏览
添加回答
举报
0/150
提交
取消
