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

📄 arithmetic.java

📁 俄罗斯方块 Java游戏 按"Enter"键开始-暂停游戏;按"Backspace"结束游戏;按"左右"移动;按"上"改变;按"下"加速。
💻 JAVA
字号:
package crui;

public class Arithmetic {

	protected int go_flag=0;//1 start;2 pause;0 stop
	protected int fix_flag=0;
	
	protected final int mysize = 32; //length of side 
//	private final int blue=1;
//	private final int green=2;
//	private final int red=3;
//	private final int yellow=4;
	
	public int row=12; //number of rows
	public int col=6; //number of columns
 
	public int initrow=0; 
	public int initcol=2; 
	public int remove_num=4;
	public int speed1=500;
	public int speed2=50;
	 
	protected int[][] grid=new int[row][col]; //screen array
	protected int[][] fix=new int[row][col];
	
	protected int now_x=0;
	protected int now_y=0;
	protected int change_pic=0;
	protected int add_speed=0;
	protected int new_p=0;
	
	protected int one_p=1,two_p=1,array=0,clear=0;

	protected void initialize() 
    {
		new_p=0;
    	for(int i=0;i<row;i++)
    		for(int j=0;j<col;j++){
    			grid[i][j]=0;//no picture
    			fix[i][j]=0;
    		}
    }
    
    protected void myarithmetic(){
    	//horizontal

    	int w_num=1,h_num=1;
    	for(int i=row-1;i>=0;i--){
    		int j=0;
    		int remove_end=0;
    		
    		while(j<col-1){
    			if(fix[i][j]==1&&fix[i][j+1]==1&&grid[i][j]==grid[i][j+1]){
    				remove_end=j+1;
    				w_num++;
    				j++;
    			}
    			else{
    				if(w_num>=remove_num)
    					j=col-1;
    				else{    				
    					w_num=1;
    					j++;
    				}
    			}
			}
	    	if(j==col-1){
	    		if(w_num>=remove_num){
	    			while(w_num>0){
	    				if(i!=0){
	    					int temp=i;
	    					for(int m=i-1;m>=0;m--,temp--){System.out.println(remove_end);
	    						if(fix[m][remove_end]==1)
	    							grid[temp][remove_end]=grid[m][remove_end];
	    						else{
	    							grid[temp][remove_end]=0;
	    							fix[temp][remove_end]=0;
	    						}
	    						
	    					}
	    				}
	    				else if(i==0){
	    					grid[i][remove_end]=0;
	    					fix[i][remove_end]=0;
	    				}
	    				remove_end--;
	    				w_num--;
	    			}
	    			i++;	
	    		}
	    		else{
	    			w_num=1;
	    		}    			    			
	    	}    		
    	}
    	//vertical

    	for(int i=0;i<col;i++){
    		int j=row-1;
    		int remove_end=0;
    		
    		while(j>0){
    			if(fix[j][i]==1&&fix[j-1][i]==1&&grid[j][i]==grid[j-1][i]){
    				remove_end=j-1;System.out.println(remove_end);
    				h_num++;
    				j--;
    			}
    			else{
    				if(h_num>=remove_num)
    					j=0;
    				else{    				
    					h_num=1;
    					j--;
    				}
    			}
			} 
	    	if(j==0){System.out.println("***** "+h_num+" ******");
	    		if(h_num>=remove_num){
	    			int temp=remove_end-1;
	    				
	    			if(remove_num==0){
	    				grid[remove_end+h_num-1][i]=two_p;
	    				for(int n=remove_end+h_num-1;n>=0;n--){
	    					grid[n][i]=0;
	    					fix[n][i]=0;
	    				}
	    			}
	    			else{
		    			for(int m=remove_end+h_num-1;m>=0;m--,temp--){ 
		    				if(temp>=0){  					
		    					if(fix[temp][i]==1)
		    						grid[m][i]=grid[temp][i];
		    					else{
		    						grid[m][i]=0;
		    						fix[m][i]=0;
		    					}
		    				}
		    				else{
		    					grid[m][i]=0;
		    					fix[m][i]=0;	    					
		    				}
		    			}	    				
	    			}	
	    		}
	    		h_num=1;  			    			
	    	}   			   		
    	} 
    	//slant
    	   	
    }	    
}

⌨️ 快捷键说明

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