用c語言運行時鐘的動畫,用c語言編寫一個時鐘程序

本文目錄一覽:

同學,怎麼用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

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
DCWJ的頭像DCWJ
上一篇 2024-10-03 23:53
下一篇 2024-10-03 23:53

相關推薦

  • python強行終止程序快捷鍵

    本文將從多個方面對python強行終止程序快捷鍵進行詳細闡述,並提供相應代碼示例。 一、Ctrl+C快捷鍵 Ctrl+C快捷鍵是在終端中經常用來強行終止運行的程序。當你在終端中運行…

    編程 2025-04-29
  • Python程序需要編譯才能執行

    Python 被廣泛應用於數據分析、人工智慧、科學計算等領域,它的靈活性和簡單易學的性質使得越來越多的人喜歡使用 Python 進行編程。然而,在 Python 中程序執行的方式不…

    編程 2025-04-29
  • Python程序文件的拓展

    Python是一門功能豐富、易於學習、可讀性高的編程語言。Python程序文件通常以.py為文件拓展名,被廣泛應用於各種領域,包括Web開發、機器學習、科學計算等。為了更好地發揮P…

    編程 2025-04-29
  • AES加密解密演算法的C語言實現

    AES(Advanced Encryption Standard)是一種對稱加密演算法,可用於對數據進行加密和解密。在本篇文章中,我們將介紹C語言中如何實現AES演算法,並對實現過程進…

    編程 2025-04-29
  • 學習Python對學習C語言有幫助嗎?

    Python和C語言是兩種非常受歡迎的編程語言,在程序開發中都扮演著非常重要的角色。那麼,學習Python對學習C語言有幫助嗎?答案是肯定的。在本文中,我們將從多個角度探討Pyth…

    編程 2025-04-29
  • Python購物車程序

    Python購物車程序是一款基於Python編程語言開發的程序,可以實現購物車的相關功能,包括商品的添加、購買、刪除、統計等。 一、添加商品 添加商品是購物車程序的基礎功能之一,用…

    編程 2025-04-29
  • 爬蟲是一種程序

    爬蟲是一種程序,用於自動獲取互聯網上的信息。本文將從如下多個方面對爬蟲的意義、運行方式、應用場景和技術要點等進行詳細的闡述。 一、爬蟲的意義 1、獲取信息:爬蟲可以自動獲取互聯網上…

    編程 2025-04-29
  • Python被稱為膠水語言

    Python作為一種跨平台的解釋性高級語言,最大的特點是被稱為”膠水語言”。 一、簡單易學 Python的語法簡單易學,更加人性化,這使得它成為了初學者的入…

    編程 2025-04-29
  • Vb運行程序的三種方法

    VB是一種非常實用的編程工具,它可以被用於開發各種不同的應用程序,從簡單的計算器到更複雜的商業軟體。在VB中,有許多不同的方法可以運行程序,包括編譯器、發布程序以及命令行。在本文中…

    編程 2025-04-29
  • Python一元二次方程求解程序

    本文將詳細闡述Python一元二次方程求解程序的相關知識,為讀者提供全面的程序設計思路和操作方法。 一、方程求解 首先,我們需要了解一元二次方程的求解方法。一元二次方程可以寫作: …

    編程 2025-04-29

發表回復

登錄後才能評論