shape.java

来自「俄罗斯方块源代码」· Java 代码 · 共 46 行

JAVA
46
字号
/*
 * Created on 2004-10-21
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

/**
 * @author Administrator
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
abstract public class Shape
{
    public byte cell[][]; //矩形必须是能够置换(4*4, 3*3等)
    public int iSideLength;
    
    public Shape(int l)
    {
        iSideLength = l;
        cell = new byte[l][l];
        for (int i=0; i<l; i++)
        {
            for (int j=0; j<l; j++)
            {
                cell[i][j] = 0;
            }
        }
    }
    
    public void Rotate() //矩形置换
    {
        byte change[][] = new byte[iSideLength][iSideLength];
        for (int i=0; i<iSideLength; i++)
        {
            for (int j=0; j<iSideLength; j++)
            {
                change[i][j] = cell[j][iSideLength - i - 1];
            }
        }
        cell = null;
        cell = change;
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?