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

📄 myeluosi.java

📁 完全自己做的俄罗斯方块
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                		}
                		else if(xx[2]==left+max&&yy[2]==bottom-max&&max!=180){
                			fourpoint2.setLocation(left,bottom-max);
                			x2 = left; y2 = bottom-max;
                		}
                		else if(max==120&&xx[2]==left&&yy[2]==bottom-60){ 
                			fourpoint2.setLocation(left+60,bottom);
                			x2 = left+60; y2 = bottom;
                		}
                		else if(max==120&&xx[2]==left+60&&yy[2]==bottom){
                			fourpoint2.setLocation(left+max,bottom-60);
                			x2 = left+max; y2 = bottom-60;
                		}
                		else if(max==120&&xx[2]==left+max&&yy[2]==bottom-60){ 
                			fourpoint2.setLocation(left+60,bottom-max);
                			x2 = left+60; y2 = bottom-max;
                		}
                		else if(max==120&&xx[2]==left+60&&yy[2]==bottom-max){ 
                			fourpoint2.setLocation(left,bottom-60);
                			x2 = left; y2 = bottom-60;
                		}
                		
                		
                		if(xx[3]==left&&yy[3]==bottom-max&&max!=180){
                			fourpoint3.setLocation(left,bottom);
                			x3 = left; y3 = bottom;
                		}
                		else if(xx[3]==left&&yy[3]==bottom&&max!=180){
                			fourpoint3.setLocation(left+max,bottom);
                			x3 = left+max; y3 = bottom;
                		}
                		else if(xx[3]==left+max&&yy[3]==bottom&&max!=180){
                			fourpoint3.setLocation(left+max,bottom-max);
                			x3 = left+max; y3 = bottom-max;
                		}
                		else if(xx[3]==left+max&&yy[3]==bottom-max&&max!=180){
                			fourpoint3.setLocation(left,bottom-max);
                			x3 = left; y3 = bottom-max;
                		}
                		else if(max==120&&xx[3]==left&&yy[3]==bottom-60){ 
                			fourpoint3.setLocation(left+60,bottom);
                			x3 = left+60; y3 = bottom;
                		}
                		else if(max==120&&xx[3]==left+60&&yy[3]==bottom){
                			fourpoint3.setLocation(left+max,bottom-60);
                			x3 = left+max; y3 = bottom-60;
                		}
                		else if(max==120&&xx[3]==left+max&&yy[3]==bottom-60){ 
                			fourpoint3.setLocation(left+60,bottom-max);
                			x3 = left+60; y3 = bottom-max;
                		}
                		else if(max==120&&xx[3]==left+60&&yy[3]==bottom-max){ 
                			fourpoint3.setLocation(left,bottom-60);
                			x3 = left; y3 = bottom-60;
                		}
                			
                			
                		if(xx[4]==left&&yy[4]==bottom-max&&max!=180){
                			fourpoint4.setLocation(left,bottom);
                			x4 = left; y4 = bottom;
                		}
                		else if(xx[4]==left&&yy[4]==bottom&&max!=180){
                			fourpoint4.setLocation(left+max,bottom);
                			x4 = left+max; y4 = bottom;
                		}
                		else if(xx[4]==left+max&&yy[4]==bottom&&max!=180){
                			fourpoint4.setLocation(left+max,bottom-max);
                			x4 = left+max; y4 = bottom-max;
                		}
                		else if(xx[4]==left+max&&yy[4]==bottom-max&&max!=180){
                			fourpoint4.setLocation(left,bottom-max);
                			x4 = left; y4 = bottom-max;
                		}
                		else if(max==120&&xx[4]==left&&yy[4]==bottom-60){ 
                			fourpoint4.setLocation(left+60,bottom);
                			x4 = left+60; y4 = bottom;
                		}
                		else if(max==120&&xx[4]==left+60&&yy[4]==bottom){
                			fourpoint4.setLocation(left+max,bottom-60);
                			x4 = left+max; y4 = bottom-60;
                		}
                		else if(max==120&&xx[4]==left+max&&yy[4]==bottom-60){ 
                			fourpoint4.setLocation(left+60,bottom-max);
                			x4 = left+60; y4 = bottom-max;
                		}
                		else if(max==120&&xx[4]==left+60&&yy[4]==bottom-max){ 
                			fourpoint4.setLocation(left,bottom-60);
                			x4 = left; y4 = bottom-60;
                		}
                	}
                }
            }
        });
    }
    
/*---------------------------------------------------------------------------*/
    //五点
    public void getFivePoints(int r){
    	final JButton fivepoint1 = new JButton("1");
    	final JButton fivepoint2 = new JButton("2");
    	final JButton fivepoint3 = new JButton("3");
    	final JButton fivepoint4 = new JButton("4");
    	final JButton fivepoint5 = new JButton("5");
    	
    	if(r == 0){	  //十字架
    		fivepoint1.setBounds(240,60,60,60);
    		fivepoint2.setBounds(300,0,60,60);
    		fivepoint3.setBounds(300,60,60,60);
    		fivepoint4.setBounds(300,120,60,60);
    		fivepoint5.setBounds(360,60,60,60);
    		this.setTitle("俄罗斯方块   十字架"+"      现在积分:"+(scores*11));
    	}
    	else if(r==1){//下凹形
    		fivepoint1.setBounds(240,0,60,60);
    		fivepoint2.setBounds(300,0,60,60);
    		fivepoint3.setBounds(360,0,60,60);
    		fivepoint4.setBounds(240,60,60,60);
    		fivepoint5.setBounds(360,60,60,60);
    		this.setTitle("俄罗斯方块   下凹形"+"      现在积分:"+(scores*11));
    	}
    	else {//左凹形
    		fivepoint1.setBounds(240,0,60,60);
    		fivepoint2.setBounds(240,120,60,60);
    		fivepoint3.setBounds(300,0,60,60);
    		fivepoint4.setBounds(300,60,60,60);
    		fivepoint5.setBounds(300,120,60,60);
    		this.setTitle("俄罗斯方块   左凹形"+"      现在积分:"+(scores*11));
    	}
    	
    	fivepoint1.setBackground(Color.red);
    	fivepoint2.setBackground(Color.red);
    	fivepoint3.setBackground(Color.red);
    	fivepoint4.setBackground(Color.red);
    	fivepoint5.setBackground(Color.red);
    	c.add(fivepoint1);
    	c.add(fivepoint2);
    	c.add(fivepoint3);
    	c.add(fivepoint4);
    	c.add(fivepoint5);
    	fivepoint1.requestFocus();
    	
    	Thread thread=new Thread(){
			public void run(){
				x = fivepoint1.getX();
				y = fivepoint1.getY();
				y2 = fivepoint2.getY();
				x2 = fivepoint2.getX();
				y3 = fivepoint3.getY();
				x3 = fivepoint3.getX();
				y4 = fivepoint4.getY();
				x4 = fivepoint4.getX();
				y5 = fivepoint5.getY();
				x5 = fivepoint5.getX();
				
				while( y<600&&y2<600&&y3<600&&y4<600&&y5<600&&
						c.getComponentAt(x,y+60).isEnabled()&&
						c.getComponentAt(x2,y2+60).isEnabled()&&
						c.getComponentAt(x3,y3+60).isEnabled()&&
						c.getComponentAt(x4,y4+60).isEnabled()&&
						c.getComponentAt(x5,y5+60).isEnabled() ){
					x = fivepoint1.getX(); y = fivepoint1.getY()+60;
					x2 = fivepoint2.getX(); y2 = fivepoint2.getY()+60;
					x3 = fivepoint3.getX(); y3 = fivepoint3.getY()+60;
					x4 = fivepoint4.getX(); y4 = fivepoint4.getY()+60;
					x5 = fivepoint5.getX(); y5 = fivepoint5.getY()+60;
        			try{
            			Thread.sleep(slep);
            			fivepoint1.setLocation(x,y);
            			fivepoint2.setLocation(x2,y2);
            			fivepoint3.setLocation(x3,y3);
            			fivepoint4.setLocation(x4,y4);
            			fivepoint5.setLocation(x5,y5);
        			}catch(InterruptedException e){}      
        		}
        		//当方块遇到障碍物时不可再用
                int fivey1 = fivepoint1.getY()+60;
                int fivex1 = fivepoint1.getX();
                int fivey2 = fivepoint2.getY()+60;
                int fivex2 = fivepoint2.getX();
                int fivey3 = fivepoint3.getY()+60;
                int fivex3 = fivepoint3.getX();
                int fivey4 = fivepoint4.getY()+60;
                int fivex4 = fivepoint4.getX();
                int fivey5 = fivepoint5.getY()+60;
                int fivex5 = fivepoint5.getX();
                
                if(fivey1==660||!c.getComponentAt(fivex1,fivey1).isEnabled()){
                	fivepoint1.setBackground(Color.magenta);
                	fivepoint2.setBackground(Color.magenta);
                	fivepoint3.setBackground(Color.magenta);
                	fivepoint4.setBackground(Color.magenta);
                	fivepoint5.setBackground(Color.magenta);
                	fivepoint1.setEnabled(false);
                	fivepoint2.setEnabled(false);
                	fivepoint3.setEnabled(false);
                	fivepoint4.setEnabled(false);
                	fivepoint5.setEnabled(false);
                	ClearRows();
                	getRandomDiamonds();
                }
                else if(fivey2==660||!c.getComponentAt(fivex2,fivey2).isEnabled()){
                	fivepoint1.setBackground(Color.magenta);
                	fivepoint2.setBackground(Color.magenta);
                	fivepoint3.setBackground(Color.magenta);
                	fivepoint4.setBackground(Color.magenta);
                	fivepoint5.setBackground(Color.magenta);
                	fivepoint1.setEnabled(false);
                	fivepoint2.setEnabled(false);
                	fivepoint3.setEnabled(false);
                	fivepoint4.setEnabled(false);
                	fivepoint5.setEnabled(false);
                	ClearRows();
                	getRandomDiamonds();
                }
                else if(fivey3==660||!c.getComponentAt(fivex3,fivey3).isEnabled()){
                	fivepoint1.setBackground(Color.magenta);
                	fivepoint2.setBackground(Color.magenta);
                	fivepoint3.setBackground(Color.magenta);
                	fivepoint4.setBackground(Color.magenta);
                	fivepoint5.setBackground(Color.magenta);
                	fivepoint1.setEnabled(false);
                	fivepoint2.setEnabled(false);
                	fivepoint3.setEnabled(false);
                	fivepoint4.setEnabled(false);
                	fivepoint5.setEnabled(false);
                	ClearRows();
                	getRandomDiamonds();
                }
                else if(fivey4==660||!c.getComponentAt(fivex4,fivey4).isEnabled()){
                	fivepoint1.setBackground(Color.magenta);
                	fivepoint2.setBackground(Color.magenta);
                	fivepoint3.setBackground(Color.magenta);
                	fivepoint4.setBackground(Color.magenta);
                	fivepoint5.setBackground(Color.magenta);
                	fivepoint1.setEnabled(false);
                	fivepoint2.setEnabled(false);
                	fivepoint3.setEnabled(false);
                	fivepoint4.setEnabled(false);
                	fivepoint5.setEnabled(false);
                	ClearRows();
                	getRandomDiamonds();
                }
                else if(fivey5==660||!c.getComponentAt(fivex5,fivey5).isEnabled()){
                	fivepoint2.setBackground(Color.magenta);
                	fivepoint3.setBackground(Color.magenta);
                	fivepoint4.setBackground(Color.magenta);
                	fivepoint5.setBackground(Color.magenta);
                	fivepoint1.setEnabled(false);
                	fivepoint2.setEnabled(false);
                	fivepoint3.setEnabled(false);
                	fivepoint4.setEnabled(false);
                	fivepoint5.setEnabled(false);
                	ClearRows();
                	getRandomDiamonds();
                }
                DefineOver();
			}
		};
		thread.start();
		
		KeyAdapter k;
    	
    	fivepoint1.addKeyListener(k=new KeyAdapter(){
            public void keyPressed(KeyEvent e){
                int key = e.getKeyCode();
                x = fivepoint1.getX();y = fivepoint1.getY();
                x2 = fivepoint2.getX();y2 = fivepoint2.getY();
                x3 = fivepoint3.getX();y3= fivepoint3.getY();
                x4 = fivepoint4.getX();y4 = fivepoint4.getY();
                x5 = fivepoint5.getX();y5 = fivepoint5.getY();
    			int xx2,yy2,xx3,yy3,xx4,yy4,xx5,yy5;
                
                //使twopoint相应移动
                if(e.getKeyText(key).equals("Right")){
                	xx5 = x5;
                	xx4 = x4;
                	xx3 = x3;
                	xx2 = x2;
                	xx = x;
                	x+=60;
                	x2+=60;
                	x3+=60;
                	x4+=60;
                	x5+=60;
                	int fivey1 = fivepoint1.getY();
                	int fivex1 = fivepoint1.getX()+60;
                	int fivey2 = fivepoint2.getY();
                	int fivex2 = fivepoint2.getX()+60;  
                	int fivey3 = fivepoint3.getY();
                	int fivex3 = fivepoint3.getX()+60;
                	int fivey4 = fivepoint4.getY();
                	int fivex4 = fivepoint4.getX()+60;
                	int fivey5 = fivepoint5.getY();
                	int fivex5 = fivepoint5.getX()+60;
                	
                	if( x>=0&&x<=600&&x2>=0&&x2<=600&&x3>=0&&x3<=600&&
                		x4>=0&&x4<=600&&x5>=0&&x5<=600&&
                		c.getComponentAt(fivex1,fivey1).isEnabled()&&
                		c.getComponentAt(fivex2,fivey2).isEnabled()&&
                		c.getComponentAt(fivex3,fivey3).isEnabled()&&
                		c.getComponentAt(fivex4,fivey4).isEnabled()&&
                		c.getComponentAt(fivex5,fivey5).isEnabled() )
                		{
                		fivepoint1.setLocation(x,y);
                		fivepoint2.setLocation(x2,y2);
                		fivepoint3.setLocation(x3,y3);
                		fivepoint4.setLocation(x4,y4);
                		fivepoint5.setLocation(x5,y5);
                	}
                	else{
                		x = xx;
                		x2 = xx2;
                		x3 = xx3;
                		x4 = xx4;
                		x5 = xx5;
                	}
                }
                e

⌨️ 快捷键说明

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