用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/n/132699.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
DCWJDCWJ
上一篇 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

发表回复

登录后才能评论