diff options
author | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-11-23 14:17:59 +0900 |
---|---|---|
committer | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-11-23 14:17:59 +0900 |
commit | fdc4638c4bbd84e1429812387d0f3a2626b95ae6 (patch) | |
tree | fdad2b2accbaef2303a98d2c7494ee6fa3a7fef7 /src/main/java/kr/syeyoung/dungeonsguide/utils | |
parent | bcf47265dc731b8124015756a0154bd25c2c7279 (diff) | |
download | Skyblock-Dungeons-Guide-fdc4638c4bbd84e1429812387d0f3a2626b95ae6.tar.gz Skyblock-Dungeons-Guide-fdc4638c4bbd84e1429812387d0f3a2626b95ae6.tar.bz2 Skyblock-Dungeons-Guide-fdc4638c4bbd84e1429812387d0f3a2626b95ae6.zip |
room building
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/utils')
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/utils/ArrayUtils.java | 22 | ||||
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/utils/ShortUtils.java | 8 |
2 files changed, 26 insertions, 4 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/ArrayUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/ArrayUtils.java new file mode 100644 index 00000000..7b9e8b59 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/ArrayUtils.java @@ -0,0 +1,22 @@ +package kr.syeyoung.dungeonsguide.utils; + +public class ArrayUtils { + public static int[][] rotateCounterClockwise(int[][] arr) { + int[][] res = new int[arr[0].length][arr.length]; + for(int y=0; y<arr.length; y++) { + for (int x = 0; x< arr[0].length; x++) { + res[res.length - x - 1][y] = arr[y][x]; + } + } + return res; + } + public static int[][] rotateClockwise(int[][] arr) { + int[][] res = new int[arr[0].length][arr.length]; + for(int y=0; y<arr.length; y++) { + for (int x = 0; x< arr[0].length; x++) { + res[x][res[0].length - y - 1] = arr[y][x]; + } + } + return res; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/ShortUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/ShortUtils.java index d7ce60c5..ffe306a4 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/ShortUtils.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/ShortUtils.java @@ -1,21 +1,21 @@ package kr.syeyoung.dungeonsguide.utils; public class ShortUtils { - public static short rotateClockwise(short integer) { + public static short rotateCounterClockwise(short integer) { int res = 0; for(int i=0; i<16; i++){ int x = i % 4; int y = i / 4; - res |= (integer >> i & 0x1) << (x*4 + y); + res |= (integer >> i & 0x1) << ((4-x-1)*4 + y); } return (short) (res & 0xFFFF); } - public static short rotateCounterClockwise(short integer) { + public static short rotateClockwise(short integer) { int res = 0; for(int i=0; i<16; i++){ int x = i % 4; int y = i / 4; - res |= (integer >> i & 0x1) << ((4-x-1) *4 +(4 - y - 1)); + res |= (integer >> i & 0x1) << (x *4 +(4 - y - 1)); } return (short) (res & 0xFFFF); } |