-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame3.c
More file actions
187 lines (174 loc) · 3.14 KB
/
game3.c
File metadata and controls
187 lines (174 loc) · 3.14 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#include "game3.h"
int g3_timetic = 1499;
//일정시간마다 아이템 사용하게 하는 함수
int istimeto_item(int a)
{
if ((clock() - a) % 20000 == 0)
{
int type = item_decide();
return type;
}
else
return -1;
}
//아이템 타입 확률 정하는 함수
int item_decide()
{
int num = rand() % 100;
if (num < 40)
{
return 1;
}
else if (num >= 40 && num < 80)
{
return 2;
}
else if (num >= 80 && num < 100)
{
return 3;
}
}
//아이템 타입 함수
int item_type(int a, char*** graphic, int** q, int b, int c)
{
switch (a)
{
case 1:
item_one(graphic, a);
break;
case 2:
item_two(graphic, a);
break;
case 3:
one_line_down(a, graphic, q, b, c);
break;
}
}
//딜레이 함수
void g3delay(clock_t n)
{
clock_t begin = clock();
while (clock() - begin < n);
}
//내려오는데 걸리는 시간 감소 함수
void item_one(char*** graphic, int a)
{
g3_timetic = 999;
system("cls");
g3show_graphic(graphic, a);
g3delay(500);
}
//내려오는 데 걸리는 시간 증가 함수
void item_two(char*** graphic, int a)
{
g3_timetic = 1999;
system("cls");
g3show_graphic(graphic, a);
g3delay(500);
}
//한줄 내리는 함수
void one_line_down(int a, char*** graphic, int** q, int b, int c)
{
del_block(graphic, q, b, c);
for (int i = 24; i < 25; i++)
{
graphic[i][10] = "▣";
graphic[i][11] = "▣";
graphic[i][12] = "▣";
system("cls");
g3show_graphic(graphic, a);
graphic[i][13] = "▣";
graphic[i][14] = "▣";
graphic[i][15] = "▣";
system("cls");
g3show_graphic(graphic, a);
graphic[i][16] = "▣";
graphic[i][17] = "▣";
system("cls");
g3show_graphic(graphic, a);
graphic[i][18] = "▣";
graphic[i][19] = "▣";
system("cls");
g3show_graphic(graphic, a);
g3delay(500);
}
for (int i = 24; i > 4; i--)
{
for (int j = 10; j < 20; j++)
{
graphic[i][j] = graphic[i - 1][j];
}
}
put_block(graphic, q, b, c);
}
//일정 시간후 내려가는 시간 원상복귀 함수
void item_exit(int a)
{
g3_timetic = 1499;
}
void g3show_graphic(char*** p, int a)
{
int i, j = 0;
for (i = 0; i < 30; i++)
{
for (j = 0; j < 30; j++)
{
printf("%s", p[i][j]);
}
printf("\n");
}
printf(" 현재점수 : %d\n", g3_point);
//아이템 설명 출력
if (a == 1)
{
printf("10초 동안 블럭이 빠르게 내려옵니다.\n");
}
else if (a == 2)
{
printf("10초 동안 블럭이 느리게 내려옵니다.\n");
}
else if (a == 3)
{
printf("블럭이 한줄 지워집니다.\n");
}
return;
}
void g3row_clear(char*** graphic, int t)
{
int i, j, k, high = 4;
for (i = 24; i > high; i--)
{
if (is_row_full(graphic, i))//i열이 꽉찼으면
{
graphic[i][10] = "▣";
graphic[i][11] = "▣";
graphic[i][12] = "▣";
system("cls");
g3show_graphic(graphic, t);
graphic[i][13] = "▣";
graphic[i][14] = "▣";
graphic[i][15] = "▣";
system("cls");
g3show_graphic(graphic, t);
graphic[i][16] = "▣";
graphic[i][17] = "▣";
system("cls");
g3show_graphic(graphic, t);
graphic[i][18] = "▣";
graphic[i][19] = "▣";
system("cls");
g3show_graphic(graphic, t);
for (k = i; k > high; k--)//i행부터 위로 쭉
{
for (j = 10; j < 20; j++)//모든 열에
{
graphic[k][j] = graphic[k - 1][j];
}
}
i++;
high++;
g3_point += 1000;
}
}
}
//□■▩▣