当前位置:首页 » 编程语言 » c语言图形编程烟花
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

c语言图形编程烟花

发布时间: 2022-06-22 00:54:05

㈠ 模拟烟花的程序,运行总出错,请c语言大师指点!!!

选项->目录->输出目录->不要设置和initgraph(&dr,&mode,"d:\\turboc2");
一样就可以正常执行.
Options->Directories->Output
Directory->不要设置和initgraph(&dr,&mode,"d:\\turboc2");
一样就可以正常执行.

㈡ 请帮忙看一下下面c语言的程序,,让它可以直接在Turboc2.0中实现礼花绽放的动画效果,谢谢!

C程序怎么也得有个主函数吧,否则怎么运行?

㈢ c语言放烟花代码

#include "stdlib.h"

#include "graphics.h"

#include "stdio.h"

#include "math.h"

#include "conio.h "

#define PI 3.1425926

main()

{

int gdriver=DETECT,gmode,errorcode;

int a[10],b[10],x,y,c,r,i,j,t;

double rad = 0.0;

/* 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("Please any key to halt:");

getch();

exit(1); /* terminate with an error code */

}

randomize();

for(;!kbhit();)

{

x=rand()%500+100; /*随机中心坐标*/

y=rand()%300+100;

for(r = 0 ;r <= 8 ; r++ ) /*烟花的大小设定*/

{

for(i = 0,rad = 0.0 ; rad < 2*PI; rad += 0.78 ) /*设定坐标*/

{

a[i++] = x + (int)r *10* cos(rad);

b[ i ] = y + (int)r *10* sin(rad);

}

t = i;

for(i=1;i<t;i++)

{

c=rand()%13+1; /*各点的颜色随机*/

setcolor(c); /*功能:将当前图形屏幕的当前笔画颜色置为color.*/

circle(a[i],b[i],1);/* a[i],b[i] 为圆心 1 为半径 画圆 */

}

delay(10000);

delay(10000);

cleardevice();

函数名: cleardevice

功 能: 清除图形屏幕

用 法: void far cleardevice(void);

}

}

getch();

closegraph();

函数名: closegraph

功 能: 关闭图形系统

用 法: void far closegraph(void);

}

(3)c语言图形编程烟花扩展阅读

C语言:表白显示(多彩小心心)

#include <stdio.h>

#include <math.h>

#include <stdlib.h>

#define I 20

#define R 340

#include <string.h>

int main()

{

char answer[10];

printf("遇到你 我才发现 曾经所有的条件 似乎都成了我等你的借口 ");

printf("我对你的感情已经决堤 所以 请允许我,从今往后映入你 明媚的眼 ");

printf("我 想和你 耳鬓厮磨,相濡以沫!");

printf("答应我吧! 输入yes,你可以看到我的真心 ");

scanf("%s", answer);

float y, x, z, f;

for (y = 1.5f; y > -1.5f; y -= 0.1f)

{

for (x = -1.5f; x < 1.5f; x += 0.05f)

{

z = x * x + y * y - 1;

f = z * z*z - x * x*y*y*y;

putchar(f <= 0.0f ? "*********"[(int)(f*-8.0f)] : ' ');

}

putchar(' ');

}

long time;

for (;;)

{

system("color a");

for (time = 0; time<99999999; time++);

system("color b");

for (time = 0; time<99999999; time++);

system("color c");

for (time = 0; time<99999999; time++);

system("color d");

for (time = 0; time<99999999; time++);

system("color e");

for (time = 0; time<99999999; time++);

system("color f");

for (time = 0; time<99999999; time++);

system("color 0");

for (time = 0; time<99999999; time++);

system("color 1");

for (time = 0; time<99999999; time++);

system("color 2");

for (time = 0; time<99999999; time++);

system("color 3");

for (time = 0; time<99999999; time++);

system("color 4");

for (time = 0; time<99999999; time++);

system("color 5");

for (time = 0; time<99999999; time++);

system("color 6");

for (time = 0; time<99999999; time++);

system("color 7");

for (time = 0; time<99999999; time++);

system("color 8");

for (time = 0; time<99999999; time++);

system("color 9");

}

getchar();

return 0;

}

㈣ c语言图形简单编程问题

楼主,就是我找出来的那个问题吗?还是另有其它为什么也不加分也不说明还有什么?

兄弟的图形能力真是强呀!佩服佩服这么难的三视图都做出来了!

我已经给你修正过了,并在修正的地方加了注释
#include<stdio.h>
#include<math.h>
#include<graphics.h>
#define PI 3.1415926
void main()
{
int gdriver=DETECT,gmode;
double D,H,E,R;
double S,XF,YF,XT,YT,XL,YL,M,N;
printf("please put in the D,H,E\n");
scanf("%lf%lf%lf",&D,&H,&E);
R=D/2;
S=sqrt(R*R-E*E);
XF=R+30;
YF=H+30;
XT=XF;
YT=YF+D+30;
XL=XF+D+30;
YL=YF;
initgraph(&gdriver,&gmode,"c:\\wexam\\tc");
cleardevice();
setlinestyle(USERBIT_LINE,0xFDBF,NORM_WIDTH);
line(XL,YL-H-5,XL,YL+5);
setlinestyle(SOLID_LINE,0,THICK_WIDTH);
rectangle(XL-R,YL-H,XL+E,YL);
setlinestyle(USERBIT_LINE,0xFDBF,NORM_WIDTH);
line(XF,YF-H-5,XF,YF+5);
setlinestyle(SOLID_LINE,0,THICK_WIDTH);
rectangle(XF-R,YF-H,XF+R,YF);
rectangle(XF-S,YF-H,XF+S,YF);
setlinestyle(USERBIT_LINE,0xFDBF,NORM_WIDTH);
line(XT,YT-R-5,XT,YT+E+5+10);/*我给你把这条线加长了点原来没有那个+10*/
line(XF-R-5,YT,XT+R+5,YT);
setlinestyle(SOLID_LINE,0,THICK_WIDTH);
/*line(XT-S,YT+E,XT+S,YT+E);*//*我屏蔽的这句就是画那条线的,不知这条线是干什么用的*/
M=atan(E/S);
M=M*180/PI;
N=180+M;
M=-M;
arc(XT,YT,M,N,R);
getch();
closegraph();
}


㈤ c语言图形编程

我试了一下,发现两个问题
第一个呢是我个人机器上的devcpp没有graphics.h文件,自然也没有对应的库。这个会报DETECT未定义。
第二个呢,"C:\Program Files\WINYES\TC20H\BGI"这里,斜杠都要写成双斜杠。这应该是你的问题所在了~
希望有帮助

㈥ 用C语言设计屏幕界面程序!

呵呵 我有哦 今天刚编了一个 是一个运动的羽毛球拍
然后是在写汉字 是一笔一画写的哦 在写“我爱你”这三个字
现在还不想分享 我送给了女朋友
你要的话加我QQ

还有一个是烟花的程序
可以现场给你 挺简单的

#include "slib.h"
#include"graphics.h"
yanhua()
{int gd=DETECT,gr,a[8],b[8],x,y,i,j,c;
initgraph(&gd,&gr,"");
randomize();
for(;!kbhit();)
{x=rand()P0 100; /*随机中心坐标*/
y=rand()00 100;
a[0]=x; /*各点坐标的计算,我的烟花图形没能是圆的*/
b[0]=y-10;
a[1]=a[0] 5;
a[2]=a[1] 5;
a[3]=a[1];
a[4]=a[0];
a[5]=a[0]-5;
a[6]=a[5]-5;
a[7]=a[6] 5;
for(j=1;j<5;j )
b[j]=b[j-1] 5;
for(j=5;j<8;j )
b[j]=b[j-1]-5;
for(j=0;j<6;j ) /*烟花的大小设定*/
{
for(i=0;i<8;i )
{
c=rand() 1; /*各点的颜色随机*/
setcolor(c);
circle(a[i],b[i],1);
}
delay(5000);
cleardevice();
b[0]-=10; /*各点的坐标变换*/
a[1] =5;
b[1]-=5;
a[2] =10;
a[3] =5;
b[3] =5;
b[4] =10;
a[5]-=5;
b[5] =5;
a[6]-=10;
a[7]-=5;
b[7]-=5;
}
}
getch();
closegraph();
}

main()
{while(1)
yanhua();
}

㈦ C语言图形编程问题

图形编程首选的当然Turbo c了,这个编译器虽然并不大,但是支持一般的图形编程。除了不支持鼠标外,其他的都还很好用的。

㈧ C语言屏幕保护程序

较简单的是用MFC编一个屏幕上画图程序,测定屏幕大小,图框内缘尺寸要大于屏幕大小,这样显示出来就是full screen. 生成的可执行程序扩展名用 .scr

把它装入系统,选屏保程序时选它 就可以了。

㈨ c语言怎么编程图形

这看你具体是要去干什么的。
一般在嵌入式系统的硬件之用有专门用的显存看你定义的什么格式比如说ARGB888,YUV,RGB565等格式。你直接打点即可画图。
若你要更复杂的,建议你去学习下QT Dfb GTK等图形引擎。
在现在流行的android上都是封装好了的java接口了。