我对java相当陌生。我只是想消除我的疑惑。这是否将阵列旋转 90 度,然后再旋转 90 度,因为它是在相同的方法中还是没有。
这是我的rotate90代码:
void rotate90() {
int temp = x;
x = -y;
y = temp;
}
这是调用方法:
static void randomPattern(Screen2D window) {
while (notFull()) {
walk.clear();
Point2D start = getFreePoint();
recursiveSelfAvoidingWalk(0, start.x, start.y);
for (Point2D pt: walk) {
pt.rotate90();
pt.translate(Screen2D.HEIGHT-1, 0);
}
Point2D [] pts = walk.toArray(new Point2D[] {});
PolyLine myWalk = new PolyLine(pts, '#');
myWalk.setParent(window);
myWalk.draw();
for (Point2D pt: walk) {
pt.rotate90();
pt.rotate90();
pt.translate(Screen2D.WIDTH, Screen2D.HEIGHT);
}
myWalk.draw();
}
window.display();
}
猛跑小猪
相关分类