1 Star 0 Fork 0

李凌志/llz

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
434.cpp 2.06 KB
一键复制 编辑 原始数据 按行查看 历史
李凌志 提交于 2019-06-15 15:28 . 434
#define _CRT_SECURE_NO_WARNINGS
#include <conio.h>
#include <graphics.h>
#include <conio.h>
#include <math.h>
#define High 480 //游戏画面尺寸
#define Width 640
#definePiI 3.14159
int main()
{
initgraph(Width, High); //初始化640*480的绘画窗口
int center_x, center_y; //中心点的坐标,也是钟表的中心
center_x = Width / 2;
center_y = High / 2;
int secondLength = Width / 7; //秒针的长度
int minuteLength = Width / 6; // 分针的长度
int hourLength = Width / 5; //时针的长度
int secondEnd_x, secondEnd_y; //秒针的终点
int minuteEnd_x, minuteEnd_y; //分钟的终点
int hourEnd_x, hourEnd_y; //时钟的终点
float secondAngle; //秒针对应的角度
float mimuteAngle; //分针对应的角度
float hourAngle; //时针对应的角度
SYSTEMTIME ti; //定义变量保存当前时间
while(1)
{
GetLocalTime(&ti); //获取当前时间
secondAngle = ti.wSecond * 2 * PI / 60;
secondAngle = ti.wMinute * 2 * PI / 60;
hourAngle = ti.wHour * 2 * PI / 12;
secondEnd_x = center_x + secondLength * sin(secondAngle);
secondEnd_y = center_y - secondLendth * cos(secondAngle);
minuteEnd_x = center_x + secondLength * sin(minuteAngle);
munuteEnd_y = center_y - minuteLength * cos(minuteAngle);
hourEnd_x = center_x + hourLength * sin(hourAngle);
hourEnd_y = center_y - hourLength * cos(hourAngle);
setlinestyle(PS_SOLID, 2);
setcolor(WHITE);
line(center_x, center_y, secondEnd_x, secondEnd_y); //画秒针
setlinestyle(PS_SOLID, 4);
setcolor(BLUE);
line(center_x, center_y, minuteEnd_x, minuteEnd_y); //画分针
setlinestyle(PS_SOLID, 6);
setcolor(RED);
line(center_x, center_y, hourEnd_x, hour_End_y); //画时针
sleep(10);
setcolor(BLACK);
setlinestyle(PS_SOLID, 2);
line(center_x, center_y, secondEnd_x, secondEnd_y); //隐藏前一帧的秒针
setlinestyle(PS_SOLID, 4);
line(center_x, center_t, minuteEnd_x, minuteEnd_y); //隐藏前一帧的分针
serlinestyle(PS_SOLID, 6);
line(center_x, center_y, hourEnd_x, hourEnd_y); //隐藏前一帧的时针
}
getch();
closegraph();
return 0;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/sanctions/llz.git
git@gitee.com:sanctions/llz.git
sanctions
llz
llz
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385