當前位置:首頁 » 編程語言 » 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介面了。