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

📄 hrd.java

📁 用java编写的华容道小游戏
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
		    		    }
		    		}
		    		if(bx==btzy.getX()&&by==btzy.getY())
		    		{
		    			btzy.move(x1,y1);
		    			btk1.move(lx,ly+82);
		    			js++;
		    			if(qm==0)
		    			{
		    			    new SoundPlayer();
		    		    }
		    		}
		    		if(bx==btmc.getX()&&by==btmc.getY())
		    		{
		    			btmc.move(x1,y1);
		    			btk1.move(lx,ly+82);
		    			js++;
		    			if(qm==0)
		    			{
		    			    new SoundPlayer();
		    		    }
		    		}
		    		if(bx==bthz.getX()&&by==bthz.getY())
		    		{
		    			bthz.move(x1,y1);
		    			btk1.move(lx,ly+82);
		    			js++;
		    			if(qm==0)
		    			{
		    			    new SoundPlayer();
		    		    }
		    		}
		    	}
		    	if(bx-x1==0&&by-y1==164)   //张飞样式向上btk1移动并看棋子与空格中间是否还有btk2
		    	{
		    		x2=btk2.getX();
		    		y2=btk2.getY();
		    		if(bx-x2==0&&by-y2==82)
		    		{
		    			lx=bx;
		    		    ly=by;
			    		if(bx==btzf.getX()&&by==btzf.getY())
			    		{
			    			btzf.move(x1,y1);
			    			btk1.move(lx,ly);
			    			btk2.move(lx,ly+82);
			    			js++;
			    			if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
			    		}
			    		if(bx==btzy.getX()&&by==btzy.getY())
			    		{
			    			btzy.move(x1,y1);
			    			btk1.move(lx,ly);
			    			btk2.move(lx,ly+82);
			    			js++;
			    			if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
			    		}
			    		if(bx==btmc.getX()&&by==btmc.getY())
			    		{
			    			btmc.move(x1,y1);
			    			btk1.move(lx,ly);
			    			btk2.move(lx,ly+82);
			    			js++;
			    			if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
			    		}
			    		if(bx==bthz.getX()&&by==bthz.getY())
			    		{
			    			bthz.move(x1,y1);
			    			btk1.move(lx,ly);
			    			btk2.move(lx,ly+82);
			    			js++;
			    			if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
			    		}
		    		}
		    		
		    	}
		    	if(bx-x1==0&&y1-by==164)  //张飞样式下移动
		    	{
		    		lx=bx;
		    		ly=by;
		    		if(bx==btzf.getX()&&by==btzf.getY())
		    		{
		    			btzf.move(x1,y1-82);
		    			btk1.move(lx,ly);
		    			js++;
		    			if(qm==0)
		    			{
		    			    new SoundPlayer();
		    		    }
		    		}
		    		if(bx==btzy.getX()&&by==btzy.getY())
		    		{
		    			btzy.move(x1,y1-82);
		    			btk1.move(lx,ly);
		    			js++;
		    			if(qm==0)
		    			{
		    			    new SoundPlayer();
		    		    }
		    		}
		    		if(bx==btmc.getX()&&by==btmc.getY())
		    		{
		    			btmc.move(x1,y1-82);
		    			btk1.move(lx,ly);
		    			js++;
		    			if(qm==0)
		    			{
		    			    new SoundPlayer();
		    		    }
		    		}
		    		if(bx==bthz.getX()&&by==bthz.getY())
		    		{
		    			bthz.move(x1,y1-82);
		    			btk1.move(lx,ly);
		    			js++;
		    			if(qm==0)
		    			{
		    			    new SoundPlayer();
		    		    }
		    		}
		    	}
		    	if(x1-bx==0&&y1-by==246)   //张飞样式向下btk1移动并看棋子与空格中间是否还有btk2
		    	{
		    		x2=btk2.getX();
		    		y2=btk2.getY();
		    		if(x2-bx==0&&y2-by==164)
		    		{
		    			lx=bx;
		    		    ly=by;
			    		if(bx==btzf.getX()&&by==btzf.getY())
			    		{
			    			btzf.move(x2,y2);
			    			btk1.move(lx,ly+82);
			    			btk2.move(lx,ly);
			    			js++;
			    			if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
			    		}
			    		if(bx==btzy.getX()&&by==btzy.getY())
			    		{
			    			btzy.move(x2,y2);
			    			btk1.move(lx,ly+82);
			    			btk2.move(lx,ly);
			    			js++;
			    			if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
			    		}
			    		if(bx==btmc.getX()&&by==btmc.getY())
			    		{
			    			btmc.move(x2,y2);
			    			btk1.move(lx,ly+82);
			    			btk2.move(lx,ly);
			    			js++;
			    			if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
			    		}
			    		if(bx==bthz.getX()&&by==bthz.getY())
			    		{
			    			bthz.move(x2,y2);
			    			btk1.move(lx,ly+82);
			    			btk2.move(lx,ly);
			    			js++;
			    			if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
			    		}
		    		}
		    		
		    	}
		    }
		    
		    if(sx==164&&sy==82)         //判断是否是关羽
		    {
		    	x1=btk1.getX();
		    	y1=btk1.getY();
		    	x2=btk2.getX();
		    	y2=btk2.getY();
		    	if(x1-bx==0&&by-y1==82)   //如果是btn1在左,btn2在右时,上移
		    	{		    		
		    	    if(x2-x1==82&&y2-y1==0)
		    	    {
		    	    	lx=bx;
		    	    	ly=by;
		    	    	if(bx==btgy.getX()&&by==btgy.getY())
		    	    	{
		    	    		btgy.move(x1,y1);		    	    		
		    	    		btk1.move(lx,ly);
		    	    		btk2.move(lx+82,ly);
		    	    		js++;
		    	    		if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
		    	    	}
		    	    }
		    	}
		    	if(x2-bx==0&&by-y2==82)   //如果是btn2在左,btn1在右时,上移
		    	{		    		
		    	    if(x1-x2==82&&y1-y2==0)
		    	    {
		    	    	lx=bx;
		    	    	ly=by;
		    	    	if(bx==btgy.getX()&&by==btgy.getY())
		    	   	    {
		    	   	    	btgy.move(x2,y2);		    	    		
		    	    		btk2.move(lx,ly);
		    	    		btk1.move(lx+82,ly);
		    	    		js++;
		    	    		if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
		    	   	    }
		    	    }
		    	    
		    	}
		    	if(x1-bx==0&&y1-by==82)   //如果是btn1在左,btn2在右时,下移
		    	{
		    	    if(x2-x1==82&&y2-y1==0)
		    	    {
		    	    	lx=bx;
		    	    	ly=by;
		    	    	if(bx==btgy.getX()&&by==btgy.getY())
		    	   	    {
		    	   	    	btgy.move(x1,y1);		    	    		
		    	    		btk1.move(lx,ly);
		    	    		btk2.move(lx+82,ly);
		    	    		js++;
		    	    		if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
		    	    	}
		    	    }
		    	    
		    	}
		    	if(x2-bx==0&&y2-by==82)   //如果是btn2在左,btn1在右时,下移
		    	{		    		
		    	    if(x1-x2==82&&y1-y2==0)
		    	    {
		    	    	lx=bx;
		    	    	ly=by;
		    	    	if(bx==btgy.getX()&&by==btgy.getY())
		    	    	{
		    	    		btgy.move(x2,y2);		    	    		
		    	    		btk2.move(lx,ly);
		    	    		btk1.move(lx+82,ly);
		    	    		js++;
		    	    		if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
		    	    	}
		    	    }
		    	    
		    	}                        //关羽样式上下移动完
		    	if(bx-x1==82&&by-y1==0)  //关羽样式左移动
		    	{
		    		lx=bx;
		    		ly=by;
		    		if(bx==btgy.getX()&&by==btgy.getY())
		    		{
		    			btgy.move(x1,y1);
		    			btk1.move(lx+82,ly);
		    			js++;
		    			if(qm==0)
		    			{
		    			    new SoundPlayer();
		    		    }
		    		}
		    	}
		    	if(bx-x1==164&&by-y1==0)     //当关羽向左btk1移动,中间还隔着btk2时
		    	{
		    		if(x2-x1==82&&y2-y1==0)
		    		{
		    			lx=bx;
		    			ly=by;
		    			if(bx==btgy.getX()&&by==btgy.getY())
		    			{
		    				btgy.move(x1,y1);
		    				btk1.move(lx,ly);
		    				btk2.move(lx+82,ly);
		    				js++;
		    				if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
		    			}
		    		}
		    	}
		    	if(x1-bx==164&&y1-by==0)  //关羽样式右移动
		    	{
		    		lx=bx;
		    		ly=by;
		    		if(bx==btgy.getX()&&by==btgy.getY())
		    		{
		    			btgy.move(x1-82,y1);
		    			btk1.move(lx,ly);		    			
		    			js++;
		    			if(qm==0)
		    			{
		    			    new SoundPlayer();
		    		    }
		    		}
		    	}
		    	if(x1-bx==246&&y1-by==0)     //当关羽向右btk1移动,中间还隔着btk2时
		    	{
		    		if(x1-x2==82&&y1-y2==0)
		    		{
		    			lx=bx;
		    			ly=by;
		    			if(bx==btgy.getX()&&by==btgy.getY())
		    			{
		    				btgy.move(x2,y2);
		    				btk1.move(lx+82,ly);
		    				btk2.move(lx,ly);
		    				js++;
		    				if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
		    			}
		    		}
		    	}
		    }       //关羽移动工作完
		    
		    if(sx==164&&sy==164)   //判断要移动的棋是不是曹操
		    {
		    	x1=btk1.getX();
		    	y1=btk1.getY();
		    	x2=btk2.getX();
		    	y2=btk2.getY();
		    	if(x1-bx==164&&y1-by==0)   //如果是btn1在上,btn2在下时,右移
		    	{		    		
		    	    if(x2-x1==0&&y2-y1==82)
		    	    {
		    	    	lx=bx;
		    	    	ly=by;
		    	    	if(bx==btcc.getX()&&by==btcc.getY())
		    	    	{
		    	    		btcc.move(x1-82,y1);		    	    		
		    	    		btk1.move(lx,ly);
		    	    		btk2.move(lx,ly+82);
		    	    		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==164&&y2-by==0)   //如果是btn2在上,btn1在下时,右移
		    	{		    		
		    	    if(x1-x2==0&&y1-y2==82)
		    	    {
		    	    	lx=bx;
		    	    	ly=by;
		    	    	if(bx==btcc.getX()&&by==btcc.getY())
		    	    	{
		    	    		btcc.move(x2-82,y2);		    	    		
		    	    		btk2.move(lx,ly);
		    	    		btk1.move(lx,ly+82);
		    	    		js++;
		    	    		if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
		    	    		if(btcc.getX()==82&&btcc.getY()==246)
		    	    		{
		    	    			String strjs=String.valueOf(js);
		    	    			this.dispose();
		    	    		    new endframe(strjs);  //判断是否成功
		    	    		}
		    	    	}
		    	    }
		    	    
		    	}
		    	if(bx-x1==82&&by-y1==0)   //如果是btn1在上,btn2在下时,左移
		    	{		    		
		    	    if(x2-x1==0&&y2-y1==82)
		    	    {
		    	    	lx=bx;
		    	    	ly=by;
		    	    	if(bx==btcc.getX()&&by==btcc.getY())
		    	    	{
		    	    		btcc.move(x1,y1);		    	    		
		    	    		btk1.move(lx+82,ly);
		    	    		btk2.move(lx+82,ly+82);
		    	    		js++;
		    	    		if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
		    	    		if(btcc.getX()==82&&btcc.getY()==246)
		    	    		{
		    	    			String strjs=String.valueOf(js);
		    	    			this.dispose();
		    	    		    new endframe(strjs);  //判断是否成功
		    	    		}
		    	    	}
		    	    }
		    	    
		    	}
		    	if(bx-x2==82&&by-y2==0)   //如果是btn2在上,btn1在下时,左移
		    	{		    		
		    	    if(x1-x2==0&&y1-y2==82)
		    	    {
		    	    	lx=bx;
		    	    	ly=by;
		    	    	if(bx==btcc.getX()&&by==btcc.getY())
		    	    	{
		    	    		btcc.move(x2,y2);		    	    		
		    	    		btk1.move(lx+82,ly+82);
		    	    		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(x1-bx==0&&by-y1==82)   //如果是btn1在左,btn2在右时,上移
		    	{		    		
		    	    if(x2-x1==82&&y2-y1==0)
		    	    {
		    	    	lx=bx;
		    	    	ly=by;
		    	    	if(bx==btcc.getX()&&by==btcc.getY())
		    	    	{
		    	    		btcc.move(x1,y1);		    	    		
		    	    		btk1.move(lx,ly+82);
		    	    		btk2.move(lx+82,ly+82);
		    	    		js++;
		    	    		if(qm==0)
		    			    {
		    			        new SoundPlayer();
		    		        }
		    	    	}
		    	    }
		    	}
		    	if(x2-bx==0&&by-y2==82)   //如果是btn2在左,btn1在右时,上移
		    	{		    		
		    	    if(x1-x2==82&&y1-y2==0)
		    	    {
		    	    	lx=bx;
		    	    	ly=by;
		    	    	if(bx==btcc.getX()&&by==btcc.getY())
		    	   	    {
		    	   	    	btcc.move(x2,y2);

⌨️ 快捷键说明

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