square.java

来自「我自己写的一个java tetrix。是上学期的作业」· Java 代码 · 共 55 行

JAVA
55
字号
import java.util.*;
import java.io.*;

/** the square class. include its generate method  and the check methods. */
public class square extends block
{
 /** generate new block using the row[4],col[4] to store the location of the new block. */
       public square()
      {
		  tile[0][4]='*';
		  tile[0][5]='*';
		  tile[1][4]='*';
		  tile[1][5]='*';

		  row[0]=0; col[0]=4;
		  row[1]=0; col[1]=5;
		  row[2]=1; col[2]=4;
		  row[3]=1; col[3]=5;

          left = true;
          right = true;
          down = true;
	  }

/** square block does not need rotate. */
	public void rotate()
	{
	}

/** unlike the Move_Downward,Left,Right methods,Check and Rotation is different depend on the shape and position of the block. */
   public void  check()
    {

       if(col[0]==0)
          left =false;
       else if((tile[row[0]][col[0]-1]!=' ')||(tile[row[2]][col[2]-1]!=' ') )
          left = false;


       if(col[1]==bwidth-1)
         right = false;
	   else if((tile[row[1]][col[1]+1]!=' ')||(tile[row[3]][col[3]+1]!=' ') )
	      right = false;

       if(row[2]==bheight-1)
          down = false;
	   else if((tile[row[2]+1][col[2]]!=' ')||(tile[row[3]+1][col[3]]!=' ') )
	      down = false;

	}




}

⌨️ 快捷键说明

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