-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlink.c
More file actions
37 lines (37 loc) · 1018 Bytes
/
Copy pathlink.c
File metadata and controls
37 lines (37 loc) · 1018 Bytes
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
#include "link.h"
#define tw "\n\033[1B\033[1D"
#define kw "\033[1B\033[1D"
void link(int x,int y)
{
int a[8][2]={{x-2,y+1},{x-1,y+2},{x+1,y+2},{x+2,y+1},{x+2,y-1},{x+1,y-2},{x-1,y-2},{x-2,y-1}};
for(int i=0;i<8;i++)
{
int x1=a[i][0];
int y1=a[i][1];
int dx=x1-x,dy=y1-y;
char z= dx*dy>0?'\\':'/';
if((x1<0||x1>=SIZE) || (y1<0||y1>=SIZE))continue;
if(arr[x][y]!=arr[x1][y1])continue;
if(!check(x,y,dx,dy))continue;
if(abs(dx)==1)
{
printf("\0337");
printf("\033[%d;%dH", (x+x1)+2,1+(y+y1)*2);
printf("%c-----%c",z,z);
fflush(stdout);
printf("\0338");
}
else
{
printf("\0337");
printf("\033[%d;%dH", (x+x1),4+(y+y1)*2);
printf(kw" %c"kw"|"kw"%c",z,z);
fflush(stdout);
printf("\0338");
}
links[x][y][i]=1;
links[x1][y1][(i+4)%8]=1;
}
update(x,y);
return;
}