在网格中旋转对象(GUI,JAVA SWING)

好的,所以我正在尝试这个教程: http : //mathcs.slu.edu/~fritts/cse131/labs/lab9/index.html

但我不知道如何旋转物体

synchronized void moveDown() { } 

是否有任何已定义的方法或我是否必须实现自己的代码? 我想改变对象的形状,但这意味着我每次都要改变我当前的对象,这可能有点复杂。

调用moveDown的方法:

 public void keyPressed(KeyEvent event) { int key = event.getKeyCode(); switch (key) { case KeyEvent.VK_UP: // up arrow case KeyEvent.VK_KP_UP: currentPiece.rotateCounterclockwise(); break; case KeyEvent.VK_DOWN: // down arrow case KeyEvent.VK_KP_DOWN: currentPiece.rotateClockwise(); break; case KeyEvent.VK_LEFT: // left arrow case KeyEvent.VK_KP_LEFT: currentPiece.moveLeft(); break; case KeyEvent.VK_RIGHT: // right arrow case KeyEvent.VK_KP_RIGHT: currentPiece.moveRight(); break; case KeyEvent.VK_SPACE: // space bar currentPiece.drop(); } } 

我正要添加L1a,L1b,L1c等。是否还有其他办法吗?

  public static final int[][] L1 = {{1,1}, {0,1}, {0,1} }; public static final int[][] L2 = {{0,1}, {0,1}, {1,1} }; public static final int[][] T = {{0,1}, {1,1}, {0,1} }; public static final int[][] BOX = {{1,1}, {1,1} }; public static final int[][] BAR = {{1,1,1,1} }; public static final int[][] STEP1 = {{1,0}, {1,1}, {0,1} }; public static final int[][] STEP2 = {{0,1}, {1,1}, {1,0} };