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

📄 tishi.java

📁 用java做的
💻 JAVA
字号:
package lianliankan;

import java.awt.AWTException;
import java.awt.Color;
import java.awt.Robot;

import javax.swing.BorderFactory;

public class Tishi extends Thread{
	public int[] tupian = new int[170];
	public int tishi1x=0;
	public int tishi1y=0;
	public int tishi2x=0;
	public int tishi2y=0;
	Map map = new Map();
	public Tishi(){

	}
	public boolean chazhao(boolean bomb,boolean test1){
		int i=0;int j=0;boolean test=false;boolean candet=false;
		for(i=0;i<MainFrame.map.iconnum;i++){
			for(j=i+1;j<MainFrame.map.iconnum;j++){
          if(MainFrame.map.iconblack[i]!=-1&&MainFrame.map.iconblack[j]!=-1&&MainFrame.map.iconblack[i]==MainFrame.map.iconblack[j]){
			tishi1y=MainFrame.map.buttonblack[i]/17+1;
			tishi1x=MainFrame.map.buttonblack[i]-(tishi1y-1)*17+1;
			tishi2y=MainFrame.map.buttonblack[j]/17+1;
			tishi2x=MainFrame.map.buttonblack[j]-(tishi2y-1)*17+1;
			System.out.println("tishi1x:"+tishi1x+"tishi1y:"+tishi1y+"tishi2x:"+tishi2x+"tishi2y:"+tishi2y);
	        if(test=test(i,j,bomb,test1))
		    break;
          }
			}
			if(test&&!bomb){
				MainFrame.score-=10;
			MainFrame.scorelb.setText("分数:"+MainFrame.score);
			}
			if(test){
				candet=true;
				break;
			}
		}
		return(candet);
}
	public boolean test(int i,int j,boolean bomb,boolean test1){
		boolean test=false;int direction=0;
		direction=map.diretion(tishi1x,tishi2x,tishi1y,tishi2y);
		test=map.det(direction,tishi1x,tishi2x,tishi1y,tishi2y,test1);
		if(test){
			MainFrame.iconbutton[MainFrame.map.buttonblack[i]].setBorder(BorderFactory.createLineBorder(Color.RED,3));
			MainFrame.iconbutton[MainFrame.map.buttonblack[j]].setBorder(BorderFactory.createLineBorder(Color.RED,3));
		}
		if(test&&bomb){
			MainFrame.iconbutton[MainFrame.map.buttonblack[i]].setVisible(false);
			MainFrame.iconbutton[MainFrame.map.buttonblack[j]].setVisible(false);
			MainFrame.map.iconblack[i]=-1;
			MainFrame.map.iconblack[j]=-1;
			MainFrame.refreshiconnum-=2;
			MainFrame.chushihuablack();
			MainFrame.score=MainFrame.score-12;
			MainFrame.scorelb.setText("分数:"+MainFrame.score);
			MainFrame.kongzhi=0;
			if(MainFrame.EndGame()){
				MainFrame.xianshi.setText("点击 GO TO TOP10 查看你的排名!!!");
				MainFrame.isEmp=true;
				MainFrame.top10.setEnabled(true);
			}
		}
		return(test);
	}
	public void start(Tishi th){	
		th.start();
	}
	public void run(){
		while(!MainFrame.EndGame()){
			chazhao(true,false);
			yanshi(1500);
		}
	}
	public void yanshi(int shijian){
	  	  try {
					Robot ne=new Robot();
					ne.delay(shijian);
				  } catch (AWTException en) {
					en.printStackTrace();
				  }
	    }
}

⌨️ 快捷键说明

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