-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHallway.java
More file actions
55 lines (50 loc) · 1.27 KB
/
Hallway.java
File metadata and controls
55 lines (50 loc) · 1.27 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
package com.gmail.x544647.bettermc;
public class Hallway {
public boolean[][] Layout;
public enum Face{
North,
South,
East,
West,
NONE
}
public static Hallway Empty = new Hallway(new boolean[][] {
{false, false, false},
{false, false, false},
{false, false, false}});
public static Hallway Solid = new Hallway(new boolean[][] {
{true, true, true},
{true, true, true},
{true, true, true}});
public static Hallway Straight = new Hallway(new boolean[][] {
{true, false, true},
{true, false, true},
{true, false, true}});
public static Hallway Cross = new Hallway(new boolean[][] {
{true, false, true},
{false, false, false},
{true, false, true}});
public Hallway(boolean[][] layout) {
Layout = layout;
}
public boolean HasRayHit(double rayX, double rayZ) {
return Layout[(int) (rayX * 3)][(int) (rayZ * 3)];
}
public Hallway Clone() {
Hallway h = new Hallway(new boolean[3][3]);
for(int z=0; z<3; z++) {
for(int x=0; x<3; x++) {
h.Layout[x][z] = Layout[x][z];
}
}
return h;
}
public Hallway Rotate90Once() {
boolean temp = Layout[0][1];
Layout[0][1] = Layout[1][0];
Layout[1][0] = Layout[2][1];
Layout[2][1] = Layout[1][2];
Layout[1][2] = temp;
return this;
}
}