1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
| #include<windows.h>
#include<cstring>
#include<cstdio>
#include<iostream>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <math.h>
using namespace std;
#define Blue RGB(0,0,255)
#define Green RGB(0,100,0)
int drawLine(HWND,int,int,int,int,int,HDC=0);
void DrawCircle (int, int, int,int);
int main()
{
HWND hConWnd=GetConsoleWindow();
if(hConWnd)
{
int n=0;
do
{
Sleep(100);
HANDLE h=GetStdHandle(STD_OUTPUT_HANDLE);
COORD p={n%2,20};
SetConsoleCursorPosition(h,p);
for(int i=0;i<400;i++)
{
if(i%3)
cout<<'_';
if(!(i%3))
cout<<' ';
}
system("color 10");
DrawCircle(0,0,20,0);
drawLine(hConWnd,303,0,470,155,Green);
drawLine(hConWnd,303,0,130,210,Green);
drawLine(hConWnd,470,155,303,155,Green);
drawLine(hConWnd,303,0,303,215,Green);
drawLine(hConWnd,120,215,517,215,Green);
drawLine(hConWnd,475,275,517,215,Green);
drawLine(hConWnd,475,275,191,275,Green);
drawLine(hConWnd,120,215,191,275,Green);
n++;
}
while(1);
getchar();
}
return 0;
}
int drawLine (HWND Wnd,int x1,int y1,int x2,int y2,int Pen,HDC DrawHDC)
{
int a,b=0;
HPEN hOPen;
HPEN hNPen=CreatePen(PS_SOLID,2,Pen);
if(!DrawHDC)
DrawHDC=GetDC(Wnd),b=1;
hOPen=(HPEN)SelectObject(DrawHDC,hNPen);
MoveToEx(DrawHDC,x1,y1,NULL);
a=LineTo(DrawHDC,x2,y2);
DeleteObject(SelectObject(DrawHDC,hOPen));
if(b)
ReleaseDC(Wnd,DrawHDC);
return a;
}
void DrawCircle(int x, int y, int r, int color)
{
static const double PI = 3.1415926535;
double i, angle, x1, y1;
for(i = 0; i < 360; i += 0.1)
{
angle = i;
x1 = r * cos(angle * PI / 180);
y1 = r * sin(angle * PI / 180);
}
} |