本文目錄一覽:
同學,怎麼用C語言製作簡單的動畫啊?
因為C的圖形處理功能太一般,不便於創作大型動畫。製作動畫用flash。
flash製作動畫:
打開Flash,點擊【文件】→【新建】,在打開的「新建」窗口中選擇「Flash文件(ActiveScript 3.0)「,然後點擊」確定「創建空白文檔。
點擊【插入】→【新建元件】,在打開的」新建元件「窗口中,將名稱設置為」運動的小人「,勾選」影片剪輯「,然後點擊」確定「按鈕。
點擊【文件】→【導入】→【導入到庫】,然後在打開的」導入到庫「窗口中,選擇事先準備好的小人走動姿勢圖片,全部選擇並點擊」打開「按鈕,導入到庫。
在圖層1 的第一幀,把庫中的「Result0」拖動到場景中。
點擊「時間軸」上的「新建圖層」按鈕,創建圖層2,然後在圖層2的第5幀處,點擊【插入】→【關鍵幀】,把庫中的「Result1」拖動到場景中。
利用同樣的原理,將」Result2「、 」Result3「和」Result4「分別到圖層3、圖層4和圖層5中,對應的幀分別為10、15和20處。
最後調整各個圖層圖像的延續時間。至此,運動的小人影片剪輯製作完成。
切換至主場景中,使主場景處於活動狀態,點擊」屬性「面板中的」大小「按鈕,將場景的大小設置為」800*300「,同時將背景色設置為」黑色「點擊」確定「按鈕。
從庫中將」運動的小人「影片剪輯拖動到場景左邊外邊。
然後在」時間軸「第30幀處,點擊【插入】→【時間軸】→【關鍵幀】,在30幀處插入關鍵幀,然後將小人從場景的左側外面拖動到場景右側外面。至此,整個動畫設置完成。
在1到30幀之間滑鼠右擊,選擇」創建補間動畫「。
最後按下鍵盤組合鍵」CTRL+Enter「進行測試。如果感覺小人運動不規律,可適當將1至30幀的距離調整的稍微大一些,直到滿意為止。
C語言程序設計題:模擬時鐘轉動的程序,怎麼做?
/*開發環境:turbo c 2.0模擬時鐘轉動程序代碼*/ #include”graphics.h” #include”math.h” #include”dos.h” #define pi 3.1415926 #define X(a,b,c) x=a*cos(b*c*pi/180-pi/2)+300 #define Y(a,b,c) y=a*sin(b*c*pi/180-pi/2)+240 #define d(a,b,c) X(a,b,c);Y(a,b,c);line(300,240,x,y) void init() /*劃時鐘邊框函數*/ { int i,l,x1,x2,y1,y2; setbkcolor(1); circle(300,240,200); circle(300,240,205); circle(300,240,5); for(i=0;i60;i++) /*劃鐘點上的短線*/ { if(i%5==0) l=15; else l=5; x1=200*sin(i*6*pi/180)+300; y1=200*cos(i*6*pi/180)+240; x2=(200-l)*sin(i*6*pi/180)+300; y2=(200-l)*cos(i*6*pi/180)+240; line(x1,y1,x2,y2); } } main() { int x,y,i,k=1; int gdriver=9,gmode=2; unsigned char h,m,s; int o,p,q; float n; struct time t[1]; struct date d[1]; initgraph(gdriver,gmode,”c:\\tc”); initgraph(gdriver,gmode,”c:\\tc”); for(i=0;i=6;i++) { settextstyle(TRIPLEX_FONT,HORIZ_DIR,i); /*控制輸出字元的字體,方向,大小*/ cleardevice(); settextjustify(1,1); /*在指定坐標上輸出字元串*/ outtextxy(300,80,”12″) ; outtextxy(300,390,”6″); outtextxy(140,230,”9″); outtextxy(460,230,”3″); outtextxy(380,100,”1″); outtextxy(220,100,”11″); outtextxy(430,160,”2″); outtextxy(430,310,”4″); outtextxy(380,370,”5″); outtextxy(220,370,”7″); outtextxy(160,160,”10″); outtextxy(160,310,”8″); } init(); setwritemode(1); /*設置畫線的輸出模式*/ if(k!=0) { getdate(d); /*獲得系統日期函數*/ o=d[0].da_year; p=d[0].da_mon; q=d[0].da_day; gettime(t); /*獲得系統時間函數*/ h=t[0].ti_hour; m=t[0].ti_min; s=t[0].ti_sec; } setcolor(7); /*設置時針顏色*/ n=(float)h+(float)m/60; d(150,n,30); /*畫出時針*/ setcolor(14); /*設置分針顏色*/ d(170,m,6); /*畫出分針*/ setcolor(4); /*設置秒針顏色*/ d(190,s,6); /*畫出秒針*/ while(!kbhit()) /*控制程序按下任意鍵退出*/ { while(t[0].ti_sec==s) gettime(t); gotoxy(44,18); /*使游標移動到指定坐標*/ printf(“\b\b\b\b\b\b\b\b\b”); /*退格,使表示時間的字元串不斷變化*/ sound(400); /*按給定的頻率打開PC揚聲器*/ delay(70); /*中斷程序的執行,時間為70毫秒*/ sound(200); delay(30); nosound(); /*按給定的頻率關閉PC揚聲器*/ setcolor(4); d(190,s,6); s=t[0].ti_sec; d(190,s,6); if(t[0].ti_min!=m) { setcolor(14); d(170,m,6); m=t[0].ti_min; d(170,m,6); } if(t[0].ti_hour!=h) { setcolor(7); d(150,h,30); h=t[0].ti_hour; d(150,h,30); sound(1000); delay(240); nosound(); delay(140); sound(2000); delay(240); nosound(); } if(s10) /*用字元的形式輸出時間*/ { if(m10) printf(“%u:0%u:0%u”,h,m,s); else printf(“%u:%u:0%u”,h,m,s); } else { if(m10) printf(“%u:0%u:%u”,h,m,s); else printf(“%u:%u:%u”,h,m,s); } gotoxy(34,19); /*在指定坐標上輸出日期*/ printf(“%d年%d月%d日”,o,p,q); printf(“\b\b\b\b\b\b\b\b\b”); } getch(); closegraph(); }
用C語言編寫模擬石英鐘程序
TurboC – 八角形指針式羅馬錶
#include dos.h
#include math.h
#include conio.h
#include stdio.h
#include stdlib.h
#include graphics.h
void drawhourbrick(int x, int y, int color, float arg);
void drawminutebrick(int x, int y, int color, float arg);
void drawsecondbrick(int x, int y, int color, float arg);
void polygon(int n, int x, int y, int r, int color, float arg, int fillstyle);
int main()
{
int GraphDriver;
int GraphMode;
float arg = 292.5;
float hourarg = 0;
float minuterarg = 0;
float secondrarg = 0;
char buffer[10];
int a, b;
int x, y, r;
int h;
int xmo[12] = {1, 2, -6, -1, -1, -2, -2, -1, 0, -4, -4, -5};
int ymo[12] = {-1, -2, -1, -1, -1, -5, 2, 1, -2, -4, -4, 0};
long delay;
float degree;
struct time time, time1;
GraphDriver = DETECT;
initgraph(GraphDriver, GraphMode, “”);
x = 300;
y = 220;
r = 200;
degree = atan(1) / 45;
polygon(8, x, y, r, 12, arg, 0);
polygon(8, x, y, r – 2, 11, arg, 0);
polygon(8, x, y, r – 4, 14, arg, 0);
setcolor(12);
for (a = 0; a 12; a++)
{
sprintf(buffer, “%d”, a + 1);
outtextxy(x + (r – 22) * cos((a – 2) * 30 * degree) + xmo[a], y + (r – 22) * sin((a – 2) * 30 * degree) + ymo[a], buffer);
}
drawhourbrick(x, y, 14, hourarg);
drawminutebrick(x, y, 9, minuterarg);
drawsecondbrick(x, y, 13, secondrarg);
while(1)
{
gettime(time);
if (time.ti_hour != time1.ti_hour || time.ti_min != time1.ti_min || time.ti_sec != time1.ti_sec)
{
h = time.ti_hour;
if (h 12)
h -= 12;
drawhourbrick(x, y, 0, hourarg);
drawminutebrick(x, y, 0, minuterarg);
drawsecondbrick(x, y, 0, secondrarg);
hourarg = (h % 12) * 30 + time.ti_min * 0.5 + time.ti_sec * 0.1 / 60;
minuterarg = time.ti_min * 6 + time.ti_sec * 0.1;
secondrarg = time.ti_sec * 6;
setcolor(8);
outtextxy(x – 15, y + 120, “Roma”);
drawhourbrick(x, y, 14, hourarg);
drawminutebrick(x, y, 9, minuterarg);
drawsecondbrick(x, y, 13, secondrarg);
time1 = time;
}
while(kbhit())
{
a = getch();
if (a == 27)
{
closegraph();
return 0;
}
}
}
}
void polygon(int n, int x, int y, int r, int color, float arg, int fillstyle)
{
double pi;
int i;
float x1[9], y1[9];
setcolor(color);
pi = atan(1) * 4;
arg = atan(1) / 45 * arg;
x1[1] = x + r * cos(2 * pi / n + arg);
y1[1] = y + r * sin(2 * pi / n + arg);
moveto(x1[1], y1[1]);
for (i = 2; i = n; i++)
{
x1[i] = x + r * cos(2 * pi * i / n + arg);
y1[i] = y + r * sin(2 * pi * i / n + arg);
lineto(x1[i], y1[i]);
}
lineto(x1[1], y1[1]);
if (fillstyle != 0)
{
setfillstyle(SOLID_FILL, color);
floodfill(x, y, color);
}
}
void drawhourbrick(int x, int y, int color, float arg)
{
double pi;
int i;
float x1[4], y1[4];
setcolor(color);
pi = atan(1) / 45;
x1[0] = x;
y1[0] = y;
x1[1] = x + 20 * cos(pi * (arg – 90 – 23));
y1[1] = y + 20 * sin(pi * (arg – 90 – 23));
x1[2] = x + 25 * cos(pi * (arg – 90 + 23));
y1[2] = y + 25 * sin(pi * (arg – 90 + 23));
x1[3] = x + 120 * cos(pi * (arg – 90 + 0));
y1[3] = y + 120 * sin(pi * (arg – 90 + 0));
moveto(x1[1], y1[1]);
lineto(x1[0], y1[0]);
lineto(x1[2], y1[2]);
lineto(x1[3], y1[3]);
lineto(x1[1], y1[1]);
setfillstyle(SOLID_FILL, color);
/*
floodfill((x1[0] + x1[3]) / 2, (y1[0] + y1[3]) / 2, color);
*/
}
void drawminutebrick(int x, int y, int color, float arg)
{
double pi;
int i;
float x1[4], y1[4];
setcolor(color);
pi = atan(1) / 45;
x1[0] = x;
y1[0] = y;
x1[1] = x + 20 * cos(pi * (arg – 90 – 23));
y1[1] = y + 20 * sin(pi * (arg – 90 – 23));
x1[2] = x + 25 * cos(pi * (arg – 90 + 23));
y1[2] = y + 25 * sin(pi * (arg – 90 + 23));
x1[3] = x + 160 * cos(pi * (arg – 90 + 0));
y1[3] = y + 160 * sin(pi * (arg – 90 + 0));
moveto(x1[1], y1[1]);
lineto(x1[0], y1[0]);
lineto(x1[2], y1[2]);
lineto(x1[3], y1[3]);
lineto(x1[1], y1[1]);
setfillstyle(SOLID_FILL, color);
/*
floodfill((x1[0] + x1[3]) / 2, (y1[0] + y1[3]) / 2, color);
*/
}
void drawsecondbrick(int x, int y, int color, float arg)
{
double pi;
int i;
float x1[4], y1[4];
setcolor(color);
pi = atan(1) / 45;
x1[0] = x;
y1[0] = y;
x1[1] = x + 20 * cos(pi * (arg – 90 – 6));
y1[1] = y + 20 * sin(pi * (arg – 90 – 6));
x1[2] = x + 25 * cos(pi * (arg – 90 + 6));
y1[2] = y + 25 * sin(pi * (arg – 90 + 6));
x1[3] = x + 160 * cos(pi * (arg – 90 + 0));
y1[3] = y + 160 * sin(pi * (arg – 90 + 0));
moveto(x1[1], y1[1]);
lineto(x1[0], y1[0]);
lineto(x1[2], y1[2]);
lineto(x1[3], y1[3]);
lineto(x1[1], y1[1]);
setfillstyle(SOLID_FILL, color);
/*
floodfill((x1[0] + x1[3]) / 2, (y1[0] + y1[3]) / 2, color);
*/
}
原創文章,作者:DCWJ,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/132699.html