问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

求一C语言动画程序,急~~

发布网友 发布时间:2024-10-23 23:17

我来回答

1个回答

热心网友 时间:2024-10-29 14:34

#include <math.h>
#include <stdio.h>
#include <graphics.h>
#include <dos.h>

#define pi 3.1415926535

double ca3mm1(double m1,double m2);
double ca3fm1(double cosine,double sine);
double ca5fm2(double a6m,double a5m,double a4m,double a4f,int shang);
double ca6fm2(double a4m ,double a4f,double a5m , double a5f);
char inbox(int x,int y,int x1,int y1);
char buf();

main()
{
double m=3.0;
double xo=100.0,yo=200.0,a1=30.0,t1=pi;
double xc=xo+m*a1,yc=yo;
double a2=8.0,a3,a4=25.0,a5=30.0,a6=20.0,a7=35.0;
double t2,t3,t4,t5,t6,t7;
double xo1=xo+m*150,yo1=yo;
double xc1=xo1-m*a1,yc1=yo1;
double i,j,k;
double l1;
double n=116.1,nt;
initscreen();

setfillstyle(SOLID_FILL,DARKGRAY);
bar(0,0,640,480);
mybutton(10,10,"BEGIN",1,0);
mybutton(500,10,"EXIT",1,0);
line(0,69,640,69);
mouseinit();
changemousecross();
setmousexy(320,20);
mouseshow();
setmousearea(0,0,640,60);
do{
if(inbox(10,10,70,26)&&button()==1)
{mousehide();
mybutton(10,10,"BEGIN",0,0);
mouseshow();
mousehold();
mousehide();
mybutton(10,10,"BEGIN",1,7);
mouseshow();
break;
}
if(inbox(500,10,555,26)&&button()==1)
{mousehide();
mybutton(500,10,"EXIT",0,0);
mouseshow();
mousehold();
mousehide();
mybutton(500,10,"EXIT",1,7);
mouseshow();
exit(0);
}
if(buf()==56)
for(i=0;i<10000;i++){
switch (buf()){
case 18:{
mousehide();
mybutton(500,10,"EXIT",0,0);
mouseshow();
delay(4000);
mousehide();
mybutton(500,10,"EXIT",1,7);
mouseshow();
exit(0);
}
case 48: {
mousehide();
mybutton(10,10,"BEGIN",0,0);
mouseshow();
delay(4000);
mousehide();
mybutton(10,10,"BEGIN",1,7);
mouseshow();
goto run;
}
default:break;
}
}
}while(1);
run:
drawjijia(xo,yo,1);
drawjijia(xc,yc,1);
drawjijia(xo1,yo1,1);
drawjijia(xc1,yc1,1);
setwritemode(1);
do{
for(i=0;i<360.0;i+=1.0)
{
t2=i;
a3=ca3mm1(a1*cos(t1)+a2*cos(t2*pi/180.0),a1*sin(t1)+a2*sin(t2*pi/180.0));
t3=ca3fm1(a1*cos(t1)+a2*cos(t2*pi/180.0),a1*sin(t1)+a2*sin(t2*pi/180.0));
a4=a3;
t4=t3;
t5=ca5fm2(a6,a5,a4,t4,0);
t6=ca6fm2(a4,t4,a5,t5);
t7=t6-90.0;
l1=xc1-xc-2*m*a7*cos(t7*pi/180);
nt=(asin(l1/2/(n/2))*180/pi)-90.0;
drawline(xo,yo,a2,t2,m,LIGHTGRAY);
drawline(xo+m*a2*cos(t2*pi/180),yo-m*a2*sin(t2*pi/180),a5,t5,m,LIGHTGRAY);
drawline(xc,yc,a6,t6,m,LIGHTGRAY);
drawline(xc,yc,a7,t7,m,LIGHTGRAY);
drawline1(xo1,yo1,a2,t2,m,LIGHTGRAY);
drawline1(xo1+m*a2*cos((180-t2)*pi/180),yo1-m*a2*sin((180-t2)*pi/180),a5,t5,m,LIGHTGRAY);
drawline1(xc1,yc1,a6,t6,m,LIGHTGRAY);
drawline1(xc1,yc1,a7,t7,m,LIGHTGRAY);
for(j=-1;j<20;j++)
{ drawline(xc+m*a7*cos(t7*pi/180),(yc-m*a7*sin(t7*pi/180)-j*n*sin(nt*pi/180)),n,nt,1.0,GREEN);
drawline1(xc1-m*a7*cos(t7*pi/180),(yc1-m*a7*sin(t7*pi/180)-j*n*sin(nt*pi/180)),n,nt,1.0,DARKGRAY);
}
delay(300);
drawline(xo,yo,a2,t2,m,LIGHTGRAY);
drawline(xo+m*a2*cos(t2*pi/180.0),yo-m*a2*sin(t2*pi/180.0),a5,t5,m,LIGHTGRAY);
drawline(xc,yc,a6,t6,m,LIGHTGRAY);
drawline(xc,yc,a7,t7,m,LIGHTGRAY);
drawline1(xo1,yo1,a2,t2,m,LIGHTGRAY);
drawline1(xo1+m*a2*cos((180-t2)*pi/180),yo1-m*a2*sin((180-t2)*pi/180),a5,t5,m,LIGHTGRAY);
drawline1(xc1,yc1,a6,t6,m,LIGHTGRAY);
drawline1(xc1,yc1,a7,t7,m,LIGHTGRAY);
for(j=-1;j<20;j++)
{ drawline(xc+m*a7*cos(t7*pi/180),(yc-m*a7*sin(t7*pi/180)-j*n*sin(nt*pi/180)),n,nt,1.0,GREEN);
drawline1(xc1-m*a7*cos(t7*pi/180),(yc1-m*a7*sin(t7*pi/180)-j*n*sin(nt*pi/180)),n,nt,1.0,DARKGRAY);
}
setwritemode(0);
if(inbox(500,10,555,26)&&button()==1)
{mousehide();
mybutton(500,10,"EXIT",0,0);
mouseshow();
mousehold();
mousehide();
mybutton(500,10,"EXIT",1,7);
mouseshow();
exit(0);
}
if(buf()==56)
for(k=0;k<10000;k++){
switch (buf()){
case 18:{
mousehide();
mybutton(500,10,"EXIT",0,0);
mouseshow();
delay(4000);
mousehide();
mybutton(500,10,"EXIT",1,7);
mouseshow();
exit(0); }
default:break;
}
}
setwritemode(1);
}
}while(1);
}

drawline(double xo,double yo,double mo,double fujiao,double m,int color)
{
double x,y;
x=(xo+m*mo*cos(fujiao*pi/180));
y=(yo-m*mo*sin(fujiao*pi/180));
setcolor(color);
line (xo,yo,x,y);
}
drawline1(double xo,double yo,double mo,double fujiao,double m,int color)
{
double x,y;
x=(xo-m*mo*cos(fujiao*pi/180));
y=(yo-m*mo*sin(fujiao*pi/180));
setcolor(color);
line (xo,yo,x,y);
}
drawjijia(double x,double y,int shang)
{
setcolor(RED);
if (shang==1){
circle(x,y,3);
line(x-3.0,y+3.0,x-15.0,y+20.0);
moveto(x-15,(int)(y+20));
lineto((int)(x+15),(int)(y+20));
moveto((int)(x+15),(int)(y+20));
lineto(x+3,y+3);}
setcolor(RED);
if (shang==0){
circle((int)x,(int)y,3);
line (x-3,y-3,x-15,y-20);
moveto(x-15,y-20);
lineto(x+15,y-20);
moveto(x+15,y-20);
lineto(x+3,y-3);
}
}
double ca3mm1(double m1,double m2)
{
double temp;
temp = sqrt(m1*m1 + m2*m2);
return(temp);
}
double ca3fm1(double cosine,double sine)
{
float temp;
if (sine > 0 && cosine > 0)
temp = atan(sine / cosine) * 180 / pi;
if (sine > 0 && cosine < 0)
temp = (atan(sine / cosine) + pi) * 180 / pi;
if (sine < 0 && cosine < 0)
temp = (atan(sine / cosine) + pi) * 180 / pi;
if (sine < 0 && cosine > 0)
temp = (atan(sine / cosine) + 2 * pi) * 180 / pi;
return(temp);
}
double ca5fm2(double a6m,double a5m,double a4m,double a4f,int shang)
{
double temp,sine1,cosine1;
cosine1 = (a6m *a6m - a4m *a4m - a5m*a5m) / (2 * a4m * a5m);
sine1 = sqrt(1 - cosine1 *cosine1);
if (shang==0)
sine1 = sine1*(-1);
if (sine1 > 0 && cosine1 > 0)
temp = a4f + (atan(sine1 / cosine1) * 180 / pi);
if (sine1 > 0 && cosine1 < 0)
temp = a4f + ((atan(sine1 / cosine1) + pi) * 180 / pi);
if (sine1 < 0 && cosine1 < 0)
temp = a4f + ((atan(sine1 / cosine1) + pi) * 180 / pi);
if (sine1 < 0 && cosine1 > 0)
temp = a4f + ((atan(sine1 / cosine1) + 2 * pi) * 180 / pi);
return(temp);
}
double ca6fm2(double a4m ,double a4f,double a5m , double a5f)
{
double temp,sine1,cosine1;
sine1 = a4m * sin(a4f * pi / 180) + a5m * sin(a5f * pi / 180);
cosine1 = a4m * cos(a4f * pi / 180) + a5m * cos(a5f * pi / 180);

if (sine1 > 0 && cosine1 > 0)
temp = (atan(sine1 / cosine1) * 180 / pi);
if (sine1 > 0 && cosine1 < 0)
temp = ((atan(sine1 / cosine1) + pi) * 180 / pi);
if (sine1 < 0 && cosine1 < 0)
temp = ((atan(sine1 / cosine1) + pi) * 180 / pi);
if (sine1 < 0 && cosine1 > 0)
temp = ((atan(sine1 / cosine1) + 2 * pi) * 180 / pi);
return(temp);
}
initscreen()
{
int gd=DETECT,gm;
registerbgidriver(EGAVGA_driver);
initgraph(&gd,&gm,"");
}
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
梦见和同性发生关糸了 梦见和同性朋友发生亲密关系 学生党如何科学护肤? 学生党该怎么基础护肤? 有什么美容护肤的技巧适合学生党? 怎么@全部成员啊? 新洲摩尔城一楼小吃租金多少 武汉王家湾有哪些广场 你好 请问 晚上6点开始 学瑜伽 可以吗? 因为我想在下班时间去 锻炼锻 ... 电脑联网有哪些条件台式电脑无线上网需要具备哪些条件 ...斤,但是腿相比较有点短,如何穿衣可以改善一下呢? 我165,120斤,上半身胖,壮,厚,且下半身瘦,但腿短,冬天我该穿什么上衣,裤... ...不想报班,特求一份鼎元公考的面试讲义,听说很有用。 我想问一下,在四川有很多的机构,其中四川群海,中公,鼎元公考都很有口 ... 伽马源是怎么产生的 现金支票用途填什么 哥哥姐姐们~谁能帮我用英文翻译一句话~谢谢了 小孩车祸大腿骨折是几级伤残 由于车祸,右侧大腿粉碎骨折属于几级伤残 车祸腿骨折几级伤残 我的两个手机丢了,然后有人捡到了,问我要钱,我觉得这成了敲诈。我知道... 稻城亚丁三大神山 violin(oy)和enjoy(io)辨音 学车离合刹车油门顺序 新手学车第一课:真确认识离合器、刹车、油门及... QQ空间天气预报代码 两个人相爱四年,现在分手二十天了,能挽回吗? ...四年,以前很相爱。和我分手了,分手三个多月了,她恨我,但不是背叛... ...两个数都是1.从第三个数开始,每一个数都是前两 个数的和, ...个书都是1,从第三个数开始,每一个数是前面两个数的合,即 ...两个数都是1,从第三个数开始,每一个数都是前两个数的和.如下所示... 想问太阳能可以朝西安装吗 世界野生古茶谷—勐海普洱茶 大雪山古树茶 ...买到特价机票,一月份想去哈尔滨,北京到哈尔滨机票怎么才能买到便宜的... 二战时期的军事名将? 猝急的意思是什么 猝暴的意思是什么 宝马m3 1.5mm宽 0.8mm深 70~80cm长 的刮痕 修多少钱 跟峰做选择活动怎么玩 计提营业税及附加分录怎么做计提营业税金及附加会计分录 ...对数e的值时在第三十五次循环时输出的数为1.#INF00 ...处罚法的规定,下列不属于当事人应当依法从轻或者减轻行政处罚的情形... 台球比赛用什么球桌 “VC”指代“腔静脉”在英语中的使用频率高吗? 特大型地下室机动车库(1124辆)应设几个出口;几个入口; 1米6的女生120斤很愁人啊不知道怎么搭配衣服才能显得个子高一些而且我属... 我是男生身高165左右体重120斤左右适合穿修身裤吗? chapters , the,book,divided,into,is,parts,in,inf 小学二年级学习内容是什么? 急需 蓝建业生平事迹 相关介绍