⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 squareshape.java

📁 俄罗斯方块游戏
💻 JAVA
字号:
import java.awt.*;
public abstract class SquareShape {

	private int RotateFlag=0;
	public int postion[][]=new int[4][2];
	public int xpos=100,ypos=0;
	public Color color;
	public SquareShape() {
		defaultRotate();
		// TODO Auto-generated constructor stub
	}
	protected abstract void defaultRotate();
	protected abstract void firstRotate();
	protected abstract void secondRotate();
	protected abstract void thirdRotate();
	public void drawShape(Graphics g)
	{
		g.setColor(color);
		for(int i=0;i<4;i++)
		g.fill3DRect(postion[i][0],postion[i][1],20,20,true);
	}
	public void rotate()
	{
		RotateFlag++;
		if(RotateFlag==4)
			RotateFlag=0;
	}
	public void contraRotate()
	{
		RotateFlag--;
		if(RotateFlag==-1)
			RotateFlag=3;
	}
	public void setPlace(int x,int y)
	{
		xpos=x;
		ypos=y;
		switch(RotateFlag)
		{
			case 0:defaultRotate();
			break;
			case 1:firstRotate();
			break;
			case 2:secondRotate();
			break;
			case 3:thirdRotate();
		}
	}
	public int getLeft()
	{
		int Left[]={postion[0][0],postion[1][0],postion[2][0],postion[3][0]};
		for(int i=0;i<3;i++)
			for(int j=i+1;j<4;j++)
				if(Left[i]>Left[j])
				{
					int temp=Left[i];
					Left[i]=Left[j];
					Left[j]=temp;
				}
		return Left[0];
	}
	public int getRight()
	{
		int Right[]={postion[0][0],postion[1][0],postion[2][0],postion[3][0]};
		for(int i=0;i<3;i++)
			for(int j=i+1;j<4;j++)
				if(Right[i]>Right[j])
				{
					int temp=Right[i];
					Right[i]=Right[j];
					Right[j]=temp;
				}
		return Right[3]+20;
	}
	public int getBottom()
	{
		int Bottom[]={postion[0][1],postion[1][1],postion[2][1],postion[3][1]};
		for(int i=0;i<3;i++)
			for(int j=i+1;j<4;j++)
				if(Bottom[i]>Bottom[j])
				{
					int temp=Bottom[i];
					Bottom[i]=Bottom[j];
					Bottom[j]=temp;
				}
		return Bottom[3]+20;
	}
	public int[] getFirstPlace()
	{
		int F[]=new int[2];
		F[0]=postion[0][0]/20;
		F[1]=postion[0][1]/20;
		return F;
	}
	public int[] getSecondPlace()
	{
		int S[]=new int[2];
		S[0]=postion[1][0]/20;
		S[1]=postion[1][1]/20;
		return S;
	}
	public int[] getThirdPlace()
	{
		int T[]=new int[2];
		T[0]=postion[2][0]/20;
		T[1]=postion[2][1]/20;
		return T;
	}
	public int[] getFourthPlace()
	{
		int F1[]=new int[2];
		F1[0]=postion[3][0]/20;
		F1[1]=postion[3][1]/20;
		return F1;
	}
}

⌨️ 快捷键说明

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