-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGrid.java
More file actions
112 lines (96 loc) · 1.93 KB
/
Grid.java
File metadata and controls
112 lines (96 loc) · 1.93 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
public class Grid {
public int grid[][];
public int def; // Ön deðer
protected int x,y;
public Grid(int sx,int sy,int sdeger)
{
x=sx;
y=sy;
def=sdeger;
grid = new int[x][y];
for(int i=0;i<x;i++)
for(int j=0;j<y;j++)
grid[i][j]=def;
}
public Grid(int sx,int sy)
{
this(sx,sy,0);
}
public Grid(Grid g)
{
x=g.x;
y=g.y;
def = g.def;
grid = new int[x][y];
for(int i=0;i<x;i++)
for(int j=0;j<y;j++)
grid[i][j]=g.grid[i][j];
}
public void Doldur(int sx,int sy,int w,int h,int deger)
{
for(int i=0;i<w;i++)
for(int j=0;j<h;j++)
if((sx+i<x) && (sy+j<y) && (sx+i>=0) && (sy+j>=0)){
grid[sx+i][sy+j]=deger;
}
}
public void SagaDon() // Saða döndürme
{
int yeniGrid[][] = new int[y][x];
int s=y-1;
for(int i=0;i<y;i++)
for(int j=0;j<x;j++)
{
yeniGrid[i][j] = grid[j][s-i];
}
grid=yeniGrid;
int tmp=x;
x=y;
y=tmp;
}
public void SolaDon() // Sola Döndürme
{
int yeniGrid[][] = new int[y][x];
int s=x-1;
for(int i=0;i<y;i++)
for(int j=0;j<x;j++)
yeniGrid[i][j]=grid[s-j][i];
grid=yeniGrid;
int tmp=x;
x=y;
y=tmp;
}
public int BoyX() {return x;}
public int BoyY() {return y;}
public void Indir(Grid model,int sx,int sy)
{
int mx,my;
mx=model.x;
my=model.y;
if(mx+sx>x) mx=x-sx;
if(my+sy>y) my=y-sy;
for(int i=0;i<mx;i++)
for(int j=0;j<my;j++)
if((sx+i<x) && (sy+j<y) && (sx+i>=0) && (sy+j>=0))
grid[sx+i][sy+j]= grid[sx+i][sy+j] | model.grid[i][j];
}
public boolean Bosmu(Grid model,int sx,int sy)
{
int mx,my;
mx=model.x;
my=model.y;
for(int i=0;i<mx;i++)
for(int j=0;j<my;j++)
{
if((sx+i<x) && (sy+j<y) && (sx+i>=0) && (sy+j>=0)){
if(grid[sx+i][sy+j]!=0 && model.grid[i][j]!=0)
return true;
}
else{
if(def!=0 && model.grid[i][j]!=0)
return true;
}
}
return false;
}
}