-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGui.cpp
88 lines (59 loc) · 1.74 KB
/
Gui.cpp
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 "head.h"
extern _Rock_t rockArray[];
void DrawRock(int rockindex,_Location_t RockLocation, bool displayed){
int x, y;
int mask;
x=RockLocation.x;
y=RockLocation.y;
mask=(unsigned int)1<<15;
for (int i=1;i<=16;i++)
{
if(rockArray[rockindex].bit_value&mask)
{
COORD coord = { x, y };
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
switch(displayed){
case 1:
printf("■");break;
case 0:
printf(" ");break;
default:
printf("error");break;
}
}
(i%4==0)?(x=RockLocation.x,y+=1):(x+=2);
mask>>=1;
}
}
void DrawGame(){
int x,y;
//画边界
for (int i=0;i<=Y_ROCK_NUM;i++){
x=0;y=i;
COORD coord = { x, y };
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
printf("□");
}
for (int i=0;i<=Y_ROCK_NUM;i++){
x=X_ROCK_NUM*2+2;y=i;
COORD coord = { x, y };
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
printf("□");
}
for (int i=2;i<=X_ROCK_NUM*2;i+=2){
x=i;y=Y_ROCK_NUM;
COORD coord = { x, y };
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
printf("□");
}
x=X_ROCK_NUM*2+8;
y=Y_ROCK_NUM*0.618;
COORD coord = { x, y };
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
cout<<"don't worry, be happy!";
x=X_ROCK_NUM*2+20;
y=Y_ROCK_NUM*0.618+1;
coord = { x, y };
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
cout<<"----yang";
}