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

📄 hrd.java

📁 用java编写的华容道小游戏
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
		    	   	    	btk1.move(lx+82,ly+82);		    	    		
		    	    		btk2.move(lx,ly+82);
		    	    		js++;
		    	    		if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
		    	   	    }
		    	    }
		    	    
		    	}
		    	if(x1-bx==0&&y1-by==164)   //如果是btn1在左,btn2在右时,下移
		    	{
		    	    if(x2-x1==82&&y2-y1==0)
		    	    {
		    	    	lx=bx;
		    	    	ly=by;
		    	    	if(bx==btcc.getX()&&by==btcc.getY())
		    	   	    {
		    	   	    	btcc.move(x1,y1-82);		    	    		
		    	    		btk1.move(lx,ly);
		    	    		btk2.move(lx+82,ly);
		    	    		js++;
		    	    		if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
		    	    		if(btcc.getX()==82&&btcc.getY()==246)
		    	    		{
		    	    			String strjs=String.valueOf(js);
		    	    			this.dispose();
		    	    		    new endframe(strjs);  //判断是否成功
		    	    		}
		    	    	}
		    	    }
		    	    
		    	}
		    	if(x2-bx==0&&y2-by==164)   //如果是btn2在左,btn1在右时,下移
		    	{		    		
		    	    if(x1-x2==82&&y1-y2==0)
		    	    {
		    	    	lx=bx;
		    	    	ly=by;
		    	    	if(bx==btcc.getX()&&by==btcc.getY())
		    	    	{
		    	    		btcc.move(x2,y2-82);		    	    		
		    	    		btk1.move(lx+82,ly);
		    	    		btk2.move(lx,ly);
		    	    		js++;
		    	    		if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
		    	    		if(btcc.getX()==82&&btcc.getY()==246)
		    	    		{
		    	    			String strjs=String.valueOf(js);
		    	    			this.dispose();
		    	    		    new endframe(strjs);  //判断是否成功
		    	    		}
		    	    	}
		    	    }
		    	    
		    	}                        //曹操样式上下移动完
		    
		    }            //曹操移动部分完成
		}
		
		
		if(e.getSource()==btk2)     //选中往btk2移动时
		{
			btzf.setBorder(BorderFactory.createEtchedBorder());
		    btcc.setBorder(BorderFactory.createEtchedBorder());
		    btzy.setBorder(BorderFactory.createEtchedBorder());
		    btmc.setBorder(BorderFactory.createEtchedBorder());
		    btgy.setBorder(BorderFactory.createEtchedBorder());
		    bthz.setBorder(BorderFactory.createEtchedBorder());
		    btz1.setBorder(BorderFactory.createEtchedBorder());
		    btz2.setBorder(BorderFactory.createEtchedBorder());
	        btz3.setBorder(BorderFactory.createEtchedBorder());
		    btz4.setBorder(BorderFactory.createEtchedBorder());
		    x1=btk2.getX();
		    y1=btk2.getY();
		    if(sx==82&&sy==82)           //此处判断要移动的是否是卒
		    {
		    	x1=btk2.getX();
		    	y1=btk2.getY();
		    	if(x1-bx==82&&y1-by==0)   //用于卒向右btk2移动
		    	{
		    		lx=bx;
		    		ly=by;
		    		if(bx==btz1.getX()&&by==btz1.getY())
		    		{
		    			btz1.move(x1,y1);
		    			btk2.move(lx,ly);
		    			js++;
		    			if(qm==0)
		    			{
		    			    new SoundPlayer();
		    		    }
		    		}
		    		if(bx==btz2.getX()&&by==btz2.getY())
		    		{
		    			btz2.move(x1,y1);
		    			btk2.move(lx,ly);
		    			js++;
		    			if(qm==0)
		    			{
		    			    new SoundPlayer();
		    		    }
		    		}
		    		if(bx==btz3.getX()&&by==btz3.getY())
		    		{
		    			btz3.move(x1,y1);
		    			btk2.move(lx,ly);
		    			js++;
		    			if(qm==0)
		    			{
		    			    new SoundPlayer();
		    		    }
		    		}
		    		if(bx==btz4.getX()&&by==btz4.getY())
		    		{
		    			btz4.move(x1,y1);
		    			btk2.move(lx,ly);
		    			js++;
		    			if(qm==0)
		    			{
		    			    new SoundPlayer();
		    		    }
		    		}
		    	}
		    	if(x1-bx==164&&y1-by==0)   //用于卒向右btk2移动并看棋子与空格中间是否还有btk1
		    	{
		    		x2=btk1.getX();
		    		y2=btk1.getY();
		    		
		    		if(x2-bx==82&&y2-by==0)
		    		{
		    			lx=bx;
		    		    ly=by;
			    		if(bx==btz1.getX()&&by==btz1.getY())
			    		{
			    			btz1.move(x1,y1);
			    			btk2.move(lx,ly);
			    			js++;
			    			if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
			    		}
			    		if(bx==btz2.getX()&&by==btz2.getY())
			    		{
			    			btz2.move(x1,y1);
			    			btk2.move(lx,ly);
			    			js++;
			    			if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
			    		}
			    		if(bx==btz3.getX()&&by==btz3.getY())
			    		{
			    			btz3.move(x1,y1);
			    			btk2.move(lx,ly);
			    			js++;
			    			if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
			    		}
			    		if(bx==btz4.getX()&&by==btz4.getY())
			    		{
			    			btz4.move(x1,y1);
			    			btk2.move(lx,ly);
			    			js++;
			    			if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
			    		}
		    		}
		    		
		    	}
		    	if(bx-x1==82&&by-y1==0)      //卒向左btk2移动
		    	{
		    		lx=bx;
		    		ly=by;
		    		if(bx==btz1.getX()&&by==btz1.getY())
		    		{
		    			btz1.move(x1,y1);
		    			btk2.move(lx,ly);
		    			js++;
		    			if(qm==0)
		    			{
		    			    new SoundPlayer();
		    		    }
		    		}
		    		if(bx==btz2.getX()&&by==btz2.getY())
		    		{
		    			btz2.move(x1,y1);
		    			btk2.move(lx,ly);
		    			js++;
		    			if(qm==0)
		    			{
		    			    new SoundPlayer();
		    		    }
		    		}
		    		if(bx==btz3.getX()&&by==btz3.getY())
		    		{
		    			btz3.move(x1,y1);
		    			btk2.move(lx,ly);
		    			js++;
		    			if(qm==0)
		    			{
		    			    new SoundPlayer();
		    		    }
		    		}
		    		if(bx==btz4.getX()&&by==btz4.getY())
		    		{
		    			btz4.move(x1,y1);
		    			btk2.move(lx,ly);
		    			js++;
		    			if(qm==0)
		    			{
		    			    new SoundPlayer();
		    		    }
		    		}
		    	}
		    	if(bx-x1==164&&by-y1==0)   //用于卒向左btk2移动并看棋子与空格中间是否还有btk1
		    	{
		    		x2=btk1.getX();
		    		y2=btk1.getY();
		    		if(bx-x2==82&&by-y2==0)
		    		{
		    			lx=bx;
		    		    ly=by;
			    		if(bx==btz1.getX()&&by==btz1.getY())
			    		{
			    			btz1.move(x1,y1);
			    			btk2.move(lx,ly);
			    			js++;
			    			if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
			    		}
			    		if(bx==btz2.getX()&&by==btz2.getY())
			    		{
			    			btz2.move(x1,y1);
			    			btk2.move(lx,ly);
			    			js++;
			    			if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
			    		}
			    		if(bx==btz3.getX()&&by==btz3.getY())
			    		{
			    			btz3.move(x1,y1);
			    			btk2.move(lx,ly);
			    			js++;
			    			if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
			    		}
			    		if(bx==btz4.getX()&&by==btz4.getY())
			    		{
			    			btz4.move(x1,y1);
			    			btk2.move(lx,ly);
			    			js++;
			    			if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
			    		}
		    		}
		    		
		    	}
		    	if(bx-x1==0&&by-y1==82)      //卒向上btk2移动
		    	{
		    		lx=bx;
		    		ly=by;
		    		if(bx==btz1.getX()&&by==btz1.getY())
		    		{
		    			btz1.move(x1,y1);
		    			btk2.move(lx,ly);
		    			js++;
		    			if(qm==0)
		    			{
		    			    new SoundPlayer();
		    		    }
		    		}
		    		if(bx==btz2.getX()&&by==btz2.getY())
		    		{
		    			btz2.move(x1,y1);
		    			btk2.move(lx,ly);
		    			js++;
		    			if(qm==0)
		    			{
		    			    new SoundPlayer();
		    		    }
		    		}
		    		if(bx==btz3.getX()&&by==btz3.getY())
		    		{
		    			btz3.move(x1,y1);
		    			btk2.move(lx,ly);
		    			js++;
		    			if(qm==0)
		    			{
		    			    new SoundPlayer();
		    		    }
		    		}
		    		if(bx==btz4.getX()&&by==btz4.getY())
		    		{
		    			btz4.move(x1,y1);
		    			btk2.move(lx,ly);
		    			js++;
		    			if(qm==0)
		    			{
		    			    new SoundPlayer();
		    		    }
		    		}
		    	}
		    	if(bx-x1==0&&by-y1==164)   //用于卒向上btk2移动并看棋子与空格中间是否还有btk1
		    	{
		    		x2=btk1.getX();
		    		y2=btk1.getY();
		    		if(bx-x2==0&&by-y2==82)
		    		{
		    			lx=bx;
		    		    ly=by;
			    		if(bx==btz1.getX()&&by==btz1.getY())
			    		{
			    			btz1.move(x1,y1);
			    			btk2.move(lx,ly);
			    			js++;
			    			if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
			    		}
			    		if(bx==btz2.getX()&&by==btz2.getY())
			    		{
			    			btz2.move(x1,y1);
			    			btk2.move(lx,ly);
			    			js++;
			    			if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
			    		}
			    		if(bx==btz3.getX()&&by==btz3.getY())
			    		{
			    			btz3.move(x1,y1);
			    			btk2.move(lx,ly);
			    			js++;
			    			if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
			    		}
			    		if(bx==btz4.getX()&&by==btz4.getY())
			    		{
			    			btz4.move(x1,y1);
			    			btk2.move(lx,ly);
			    			js++;
			    			if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
			    		}
		    		}
		    		
		    	}
		    	if(bx-x1==0&&y1-by==82)      //卒向下btk2移动
		    	{
		    		lx=bx;
		    		ly=by;
		    		if(bx==btz1.getX()&&by==btz1.getY())
		    		{
		    			btz1.move(x1,y1);
		    			btk2.move(lx,ly);
		    		    js++;
		    		    if(qm==0)
		    		    {
		    			    new SoundPlayer();
		    		    }	
		    		}
		    		if(bx==btz2.getX()&&by==btz2.getY())
		    		{
		    			btz2.move(x1,y1);
		    			btk2.move(lx,ly);
		    			js++;
		    			if(qm==0)
		    		    {
		    			    new SoundPlayer();
		    		    }
		    		}
		    		if(bx==btz3.getX()&&by==btz3.getY())
		    		{
		    			btz3.move(x1,y1);
		    			btk2.move(lx,ly);
		    			js++;
		    			if(qm==0)
		    		    {
		    			    new SoundPlayer();
		    		    }
		    		}
		    		if(bx==btz4.getX()&&by==btz4.getY())
		    		{
		    			btz4.move(x1,y1);
		    			btk2.move(lx,ly);
		    			js++;
		    			if(qm==0)
		    		    {
		    			    new SoundPlayer();
		    		    }
		    		}
		    	}
		    	if(x1-bx==0&&y1-by==164)   //用于卒向下btk2移动并看棋子与空格中间是否还有btk1
		    	{
		    		x2=btk1.getX();
		    		y2=btk1.getY();
		    		if(x2-bx==0&&y2-by==82)
		    		{
		    			lx=bx;
		    		    ly=by;
			    		if(bx==btz1.getX()&&by==btz1.getY())
			    		{
			    			btz1.move(x1,y1);
			    			btk2.move(lx,ly);
			    			js++;
			    			if(qm==0)
		    		        {
		    			        new SoundPlayer();
		    		        }
			    		}
			    		if(bx==btz2.getX()&&by==btz2.getY())
			    		{
			    			btz2.move(x1,y1);
			    			btk2.move(lx,ly);
			    			js++;
			    			if(qm==0)
		    		        {
		    			        new SoundPlayer();
		    		        }
			    		}
			    		if(bx==btz3.getX()&&by==btz3.getY())
			    		{
			    			btz3.move(x1,y1);
			    			btk2.move(lx,ly);
			    			js++;
			    			if(qm==0)
		    		        {
		    			        new SoundPlayer();
		    		        }
			    		}
			    		if(bx==btz4.getX()&&by==btz4.getY())
			    		{
			    			btz4.move(x1,y1);
			    			btk2.move(lx,ly);
			    			js++;
			    			if(qm==0)
		    		        {
		    			        new SoundPlayer();
		    		        }
			    		}
		    		}
		    		
		    	}
		    	if(x1-bx==0&&y1-by==164)   //用于卒向下btk1移动并看棋子与空格中间是否还有btk2
		    	{
		    		x2=btk2.getX();
		    		y2=btk2.getY();
		    		if(x2-bx==0&&y2-by==82)
		    		{
		    			lx=bx;
		    		    ly=by;
			    		if(bx==btz1.getX()&&by==btz1.getY())
			    		{
			    			btz1.move(x1,y1)

⌨️ 快捷键说明

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