/*
 * 作成日: 2005/06/23
 *
 * TODO この生成されたファイルのテンプレートを変更するには次へジャンプ:
 * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート
 */

import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Label;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

/**
 * @author ワチャロー
 *
 * TODO この生成された型コメントのテンプレートを変更するには次へジャンプ:
 * ウィンドウ - 設定 - Java - コード・スタイル - コード・テンプレート
 */
public class Tetris11 extends Applet implements Runnable, KeyListener {

    private  int LOWSPEED=1000,HIGHSPEED=100;
    private final int startXX=50,startYY=20;
    private final int block=10;
    private final int width=100,height=200;
    private final int margin=15;
    private int nextBoxX,nextBoxY;
    private int SPEED=LOWSPEED;
    private int x,y;
    private int xx,yy=startYY;
    private int pattern,turn;
    
    private int ran,next;
    
    private boolean[][] Status;
    private int[][] colorStatus;
        
    private Graphics offG;
    private Image img;
    private Thread th;
    private Label lblLevel,lblScore,Level,Score;

    public void init() {
        setSize(200,270);
        setBackground(Color.lightGray);
        setLayout(null);
        img = createImage(width+1,height+1);
        offG = img.getGraphics();
        
        x=width/block;
        y=height/block;
        
        nextBoxX = width+margin*2;
        nextBoxY = margin*4;
        
        lblLevel = new Label("Level:");
        lblLevel.setBounds(nextBoxX,nextBoxY+70,40,30);
        add(lblLevel);
        Level = new Label("1",Label.RIGHT);
        Level.setBounds(nextBoxX+45,nextBoxY+70,20,30);
        add(Level);
        
        lblScore = new Label("Score:");
        lblScore.setBounds(nextBoxX,nextBoxY+100,40,30);
        add(lblScore);
        Score = new Label("0",Label.RIGHT);
        Score.setBounds(nextBoxX+30,nextBoxY+100,35,30);
        add(Score);
        
        Status = new boolean[x][y+1];
        colorStatus = new int[x][y];
        
        for(int i=0;i<x;i++) {
            for(int j=0;j<y;j++) {
                Status[i][j] = true;
            }
        }
        
        xx=startXX;
        
        ran = (int)(Math.random()*10)%7;
        next = (int)(Math.random()*10)%7;
        
        addKeyListener(this);
        setVisible(true);
        requestFocus();
    }
    
    public void start() {
        if(th==null) {
            th = new Thread(this);
            th.start();
        }
    }
    
    public void paint(Graphics G) {
        offG.clearRect(0,0,width,height);
        offG.setColor(Color.gray);
        offG.fillRect(0,0,width,height);
        offG.setColor(Color.BLACK);
        offG.drawRect(0,0,width,height);
        
        Block.polygon(xx,yy,block,offG,pattern,ran);
        
        for(int i=0;i<x;i++) {
            for(int j=0;j<y;j++) {
                if(Status[i][j]==false) {
                    offG.setColor(Clr.clr[colorStatus[i][j]]);
                    offG.fillRect(i*block,j*block,block,block);
                    offG.setColor(Color.black);
                    offG.drawRect(i*block,j*block,block,block);
                }
            }
        }
        
        G.drawImage(img,margin,margin*2,this);
        
        G.setColor(Color.DARK_GRAY);
        G.fillRect(nextBoxX,nextBoxY,50,60);
        G.setColor(Color.BLACK);
        G.drawRect(nextBoxX,nextBoxY,50,60);
        Block.polygon(nextBoxX+block*2,nextBoxY+block*3,block,G,0,next);
    }
    
    public void update(Graphics g) {
        paint(g);
    }
    
    /* (非 Javadoc)
     * @see java.lang.Runnable#run()
     */
    public void run() {
        // TODO 自動生成されたメソッド・スタブ
        while(th == Thread.currentThread()) {
            try {
                Thread.sleep(SPEED);
            } catch (InterruptedException e) {
                // TODO 自動生成された catch ブロック
                e.printStackTrace();
            }
            repaint();
            if(Seigyo.downCheck(xx,yy,block,Status,colorStatus,pattern,ran)) {
                Delete.delete(Status,colorStatus,x,y);
                
                Score.setText(new Integer(Delete.deleteScore).toString());
                
                Level.setText(new Integer(Delete.deleteCount/5+1).toString());
                
                LOWSPEED = 1000-(Delete.deleteCount/5)*100;
                
                yy=startYY;
                xx=startXX;
                ran = next;
                next = (int)(Math.random()*10)%7;
            
            }
            yy += block;
        }
    }

    /* (非 Javadoc)
     * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
     */
    public void keyPressed(KeyEvent e) {
        // TODO 自動生成されたメソッド・スタブ
        if(e.getKeyCode()==KeyEvent.VK_LEFT) {
            if(xx>=block && Seigyo.leftCheck(xx,yy,width,block,Status,pattern,ran)) {
                xx-=block;
            }
            repaint();
            
            if(Seigyo.downCheck(xx,yy,block,Status,colorStatus,pattern,ran)) {
                yy=startYY;
                xx=startXX;
                ran = (int)(Math.random()*10)%2;
            }
        }
        
        if(e.getKeyCode() == KeyEvent.VK_RIGHT) {
            if(xx<width-block && Seigyo.rightCheck(xx,yy,width,block,Status,pattern,ran)) {
                xx+=block;
            }
            repaint();
            
            if(Seigyo.downCheck(xx,yy,block,Status,colorStatus,pattern,ran)) {
                yy=startYY;
                xx=startXX;
                ran = (int)(Math.random()*10)%2;
            }
        }
        
        if(e.getKeyCode() == KeyEvent.VK_DOWN) {
            SPEED = HIGHSPEED;
        }
    }

    /* (非 Javadoc)
     * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
     */
    public void keyReleased(KeyEvent e) {
        // TODO 自動生成されたメソッド・スタブ
        if(e.getKeyCode() == KeyEvent.VK_DOWN) {
            SPEED = LOWSPEED;
        }
        
        if(e.getKeyCode() == KeyEvent.VK_SPACE && Seigyo.rightTurnCheck(xx,yy,width,block,Status,pattern,ran)) {
            turn++;
            pattern = turn%4;
            repaint();
        }
    }

    /* (非 Javadoc)
     * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
     */
    public void keyTyped(KeyEvent e) {
        // TODO 自動生成されたメソッド・スタブ

    }
}
		

Block.java
/*
 * 作成日: 2004/07/18
 *
 * この生成されたコメントの挿入されるテンプレートを変更するため
 * ウィンドウ > 設定 > Java > コード生成 > コードとコメント
 */

import java.awt.*;

/**
 * @author wacharo
 *
 * この生成されたコメントの挿入されるテンプレートを変更するため
 * ウィンドウ > 設定 > Java > コード生成 > コードとコメント
 */
public class Block {
    public static void polygon(int xx,int yy,int block,Graphics offG,int pattern,int ran) {
        switch(ran) {
            case 0:
                if(pattern==0) {                                    /* _ */
                    offG.setColor(Clr.clr[ran]);                    /*|_|*/
                    offG.fillRect(xx,yy+block,block,block);         /*|_|*/
                    offG.fillRect(xx,yy,block,block);               /*|@|*/
                    offG.fillRect(xx,yy-block,block,block);         /*|_|*/
                    offG.fillRect(xx,yy-block*2,block,block);
                    
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx,yy+block,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx,yy-block,block,block);
                    offG.drawRect(xx,yy-block*2,block,block);
                }
                        
                if(pattern==1) {                                    /* _ _ _ _ */
                    offG.setColor(Clr.clr[ran]);                    /*|_|@|_|_|*/
                    offG.fillRect(xx-block,yy,block,block);
                    offG.fillRect(xx,yy,block,block);
                    offG.fillRect(xx+block,yy,block,block);
                    offG.fillRect(xx+block*2,yy,block,block);
                        
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx-block,yy,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx+block,yy,block,block);
                    offG.drawRect(xx+block*2,yy,block,block);
                }
                        
                if(pattern==2) {                                    /* _ */
                    offG.setColor(Clr.clr[ran]);                    /*|_|*/
                    offG.fillRect(xx,yy-block,block,block);         /*|@|*/
                    offG.fillRect(xx,yy,block,block);               /*|_|*/
                    offG.fillRect(xx,yy+block,block,block);         /*|_|*/
                    offG.fillRect(xx,yy+block*2,block,block);
                        
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx,yy-block,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx,yy+block,block,block);
                    offG.drawRect(xx,yy+block*2,block,block);
                }
                    
                if(pattern==3) {                                    /* _ _ _ _ */
                    offG.setColor(Clr.clr[ran]);                    /*|_|_|@|_|*/
                    offG.fillRect(xx+block,yy,block,block);
                    offG.fillRect(xx,yy,block,block);
                    offG.fillRect(xx-block,yy,block,block);
                    offG.fillRect(xx-block*2,yy,block,block);
                            
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx+block,yy,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx-block,yy,block,block);
                    offG.drawRect(xx-block*2,yy,block,block);
                }
                break;
                
            case 1:
                offG.setColor(Clr.clr[ran]);                        /* _ _ */
                offG.fillRect(xx,yy,block,block);                   /*|_|_|*/
                offG.fillRect(xx+block,yy,block,block);             /*|@|_|*/
                offG.fillRect(xx,yy-block,block,block);
                offG.fillRect(xx+block,yy-block,block,block);
                
                offG.setColor(Clr.clr[7]);
                offG.drawRect(xx,yy,block,block);
                offG.drawRect(xx+block,yy,block,block);
                offG.drawRect(xx,yy-block,block,block);
                offG.drawRect(xx+block,yy-block,block,block);
                break;
                
            case 2:
                if(pattern==0) {                                    /*   _ */
                    offG.setColor(Clr.clr[ran]);                    /*  |_|*/
                    offG.fillRect(xx,yy-block,block,block);         /* _|@|*/
                    offG.fillRect(xx,yy,block,block);               /*|_|_|*/
                    offG.fillRect(xx,yy+block,block,block);
                    offG.fillRect(xx-block,yy+block,block,block);
                    
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx,yy-block,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx,yy+block,block,block);
                    offG.drawRect(xx-block,yy+block,block,block);
                }
                
                if(pattern==1) {                                    /* _     */
                    offG.setColor(Clr.clr[ran]);                    /*|_|_ _ */
                    offG.fillRect(xx+block,yy,block,block);         /*|_|@|_|*/
                    offG.fillRect(xx,yy,block,block);
                    offG.fillRect(xx-block,yy,block,block);
                    offG.fillRect(xx-block,yy-block,block,block);
                        
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx+block,yy,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx-block,yy,block,block);
                    offG.drawRect(xx-block,yy-block,block,block);
                }
                
                if(pattern==2) {                                    /* _ _ */
                    offG.setColor(Clr.clr[ran]);                    /*|_|_|*/
                    offG.fillRect(xx,yy-block,block,block);         /*|@|  */
                    offG.fillRect(xx,yy,block,block);               /*|_|  */
                    offG.fillRect(xx,yy+block,block,block);
                    offG.fillRect(xx+block,yy-block,block,block);
                        
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx,yy-block,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx,yy+block,block,block);
                    offG.drawRect(xx+block,yy-block,block,block);
                }
                
                if(pattern==3) {                                    /* _ _ _ */
                    offG.setColor(Clr.clr[ran]);                    /*|_|@|_|*/
                    offG.fillRect(xx-block,yy,block,block);         /*    |_|*/
                    offG.fillRect(xx,yy,block,block);
                    offG.fillRect(xx+block,yy,block,block);
                    offG.fillRect(xx+block,yy+block,block,block);
                        
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx-block,yy,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx+block,yy,block,block);
                    offG.drawRect(xx+block,yy+block,block,block);
                }
                break;
                
            case 3:
                if(pattern==0) {                                    /* _   */
                    offG.setColor(Clr.clr[ran]);                    /*|_|  */
                    offG.fillRect(xx,yy-block,block,block);         /*|@|_ */
                    offG.fillRect(xx,yy,block,block);               /*|_|_|*/
                    offG.fillRect(xx,yy+block,block,block);
                    offG.fillRect(xx+block,yy+block,block,block);
                    
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx,yy-block,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx,yy+block,block,block);
                    offG.drawRect(xx+block,yy+block,block,block);
                }
                
                if(pattern==1) {                                    /* _ _ _ */
                    offG.setColor(Clr.clr[ran]);                    /*|_|@|_|*/
                    offG.fillRect(xx+block,yy,block,block);         /*|_|    */
                    offG.fillRect(xx,yy,block,block);
                    offG.fillRect(xx-block,yy,block,block);
                    offG.fillRect(xx-block,yy+block,block,block);
                        
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx+block,yy,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx-block,yy,block,block);
                    offG.drawRect(xx-block,yy+block,block,block);
                }
                
                if(pattern==2) {                                    /* _ _ */
                    offG.setColor(Clr.clr[ran]);                    /*|_|_|*/
                    offG.fillRect(xx,yy+block,block,block);         /*  |@|*/
                    offG.fillRect(xx,yy,block,block);               /*  |_|*/
                    offG.fillRect(xx,yy-block,block,block);
                    offG.fillRect(xx-block,yy-block,block,block);
                        
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx,yy+block,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx,yy-block,block,block);
                    offG.drawRect(xx-block,yy-block,block,block);
                }
                
                if(pattern==3) {                                    /*     _*/
                    offG.setColor(Clr.clr[ran]);                    /* _ _|_|*/
                    offG.fillRect(xx-block,yy,block,block);         /*|_|@|_|*/
                    offG.fillRect(xx,yy,block,block);
                    offG.fillRect(xx+block,yy,block,block);
                    offG.fillRect(xx+block,yy-block,block,block);
                        
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx-block,yy,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx+block,yy,block,block);
                    offG.drawRect(xx+block,yy-block,block,block);
                }
                break;
                
            case 4:
                if(pattern==0) {                                    /*   _ */
                    offG.setColor(Clr.clr[ran]);                    /* _|_|*/
                    offG.fillRect(xx+block,yy-block,block,block);   /*|@|_|*/
                    offG.fillRect(xx+block,yy,block,block);         /*|_|  */
                    offG.fillRect(xx,yy,block,block);
                    offG.fillRect(xx,yy+block,block,block);
                    
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx+block,yy-block,block,block);
                    offG.drawRect(xx+block,yy,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx,yy+block,block,block);
                }
                
                if(pattern==1) {                                    /* _ _   */
                    offG.setColor(Clr.clr[ran]);                    /*|_|@|_ */
                    offG.fillRect(xx-block,yy,block,block);         /*  |_|_|*/
                    offG.fillRect(xx,yy,block,block);
                    offG.fillRect(xx,yy+block,block,block);
                    offG.fillRect(xx+block,yy+block,block,block);
                        
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx-block,yy,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx,yy+block,block,block);
                    offG.drawRect(xx+block,yy+block,block,block);
                }
                
                if(pattern==2) {                                    /*   _ */
                    offG.setColor(Clr.clr[ran]);                    /* _|_|*/
                    offG.fillRect(xx,yy-block,block,block);         /*|_|@|*/
                    offG.fillRect(xx,yy,block,block);               /*|_|  */
                    offG.fillRect(xx-block,yy,block,block);
                    offG.fillRect(xx-block,yy+block,block,block);
                            
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx,yy-block,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx-block,yy,block,block);
                    offG.drawRect(xx-block,yy+block,block,block);
                }
                    
                if(pattern==3) {                                    /* _ _   */
                    offG.setColor(Clr.clr[ran]);                    /*|_|_|_ */
                    offG.fillRect(xx-block,yy-block,block,block);   /*  |@|_|*/
                    offG.fillRect(xx,yy-block,block,block);
                    offG.fillRect(xx,yy,block,block);
                    offG.fillRect(xx+block,yy,block,block);
                            
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx-block,yy-block,block,block);
                    offG.drawRect(xx,yy-block,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx+block,yy,block,block);
                }
                break;
                
            case 5:
                if(pattern==0) {                                    /* _   */
                    offG.setColor(Clr.clr[ran]);                    /*|_|_ */
                    offG.fillRect(xx-block,yy-block,block,block);   /*|_|@|*/
                    offG.fillRect(xx-block,yy,block,block);         /*  |_|*/
                    offG.fillRect(xx,yy,block,block);
                    offG.fillRect(xx,yy+block,block,block);
                    
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx-block,yy-block,block,block);
                    offG.drawRect(xx-block,yy,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx,yy+block,block,block);
                }
                
                if(pattern==1) {                                    /*   _ _ */
                    offG.setColor(Clr.clr[ran]);                    /* _|_|_|*/
                    offG.fillRect(xx+block,yy-block,block,block);   /*|_|@|  */
                    offG.fillRect(xx,yy-block,block,block);
                    offG.fillRect(xx,yy,block,block);
                    offG.fillRect(xx-block,yy,block,block);
                        
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx+block,yy-block,block,block);
                    offG.drawRect(xx,yy-block,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx-block,yy,block,block);
                }
                
                if(pattern==2) {                                    /* _   */
                    offG.setColor(Clr.clr[ran]);                    /*|_|_ */
                    offG.fillRect(xx,yy-block,block,block);         /*|@|_|*/
                    offG.fillRect(xx,yy,block,block);               /*  |_|*/
                    offG.fillRect(xx+block,yy,block,block);
                    offG.fillRect(xx+block,yy+block,block,block);
                        
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx,yy-block,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx+block,yy,block,block);
                    offG.drawRect(xx+block,yy+block,block,block);
                }
                
                if(pattern==3) {                                    /*   _ _ */
                    offG.setColor(Clr.clr[ran]);                    /* _|@|_|*/
                    offG.fillRect(xx+block,yy,block,block);         /*|_|_|  */
                    offG.fillRect(xx,yy,block,block);
                    offG.fillRect(xx,yy+block,block,block);
                    offG.fillRect(xx-block,yy+block,block,block);
                        
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx+block,yy,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx,yy+block,block,block);
                    offG.drawRect(xx-block,yy+block,block,block);
                }
                break;
            
            case 6:
                if(pattern==0) {                                    /*   _   */
                    offG.setColor(Clr.clr[ran]);                    /* _|_|_ */
                    offG.fillRect(xx-block,yy,block,block);         /*|_|@|_|*/
                    offG.fillRect(xx,yy,block,block);
                    offG.fillRect(xx+block,yy,block,block);
                    offG.fillRect(xx,yy-block,block,block);
                    
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx-block,yy,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx+block,yy,block,block);
                    offG.drawRect(xx,yy-block,block,block);
                }
                
                if(pattern==1) {                                    /* _   */
                    offG.setColor(Clr.clr[ran]);                    /*|_|_ */
                    offG.fillRect(xx,yy-block,block,block);         /*|@|_|*/
                    offG.fillRect(xx,yy,block,block);               /*|_|  */
                    offG.fillRect(xx,yy+block,block,block);
                    offG.fillRect(xx+block,yy,block,block);
                    
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx,yy-block,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx,yy+block,block,block);
                    offG.drawRect(xx+block,yy,block,block);
                }
                
                if(pattern==2) {                                    /* _ _ _ */
                    offG.setColor(Clr.clr[ran]);                    /*|_|@|_|*/
                    offG.fillRect(xx-block,yy,block,block);         /*  |_|  */
                    offG.fillRect(xx,yy,block,block);
                    offG.fillRect(xx+block,yy,block,block);
                    offG.fillRect(xx,yy+block,block,block);
                    
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx-block,yy,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx+block,yy,block,block);
                    offG.drawRect(xx,yy+block,block,block);
                }
                
                if(pattern==3) {                                    /*   _ */
                    offG.setColor(Clr.clr[ran]);                    /* _|_|*/
                    offG.fillRect(xx,yy-block,block,block);         /*|_|@|*/
                    offG.fillRect(xx,yy,block,block);               /*  |_|*/
                    offG.fillRect(xx,yy+block,block,block);
                    offG.fillRect(xx-block,yy,block,block);
                        
                    offG.setColor(Clr.clr[7]);
                    offG.drawRect(xx,yy-block,block,block);
                    offG.drawRect(xx,yy,block,block);
                    offG.drawRect(xx,yy+block,block,block);
                    offG.drawRect(xx-block,yy,block,block);
                }
                break;
        }
    }
}
		

Seigoy.java
/*
 * 作成日: 2004/07/18
 *
 * この生成されたコメントの挿入されるテンプレートを変更するため
 * ウィンドウ > 設定 > Java > コード生成 > コードとコメント
 */
 
/**
 * @author wacharo
 *
 * この生成されたコメントの挿入されるテンプレートを変更するため
 * ウィンドウ > 設定 > Java > コード生成 > コードとコメント
 */
public class Seigyo {
    private static boolean bool;
    
    public static boolean downCheck(int xx,int yy,int block,boolean [][] Status,int [][] colorStatus,int pattern,int ran) {
        
        bool=false;
        
        switch(ran) {
            case 0:
                if(pattern==0) {
                    if(Status[xx/block][yy/block+2]==false) {
                        Status[xx/block][yy/block+1]=false;
                        Status[xx/block][yy/block]=false;
                        Status[xx/block][yy/block-1]=false;
                        Status[xx/block][yy/block-2]=false;
                        bool=true;
                    }
                }
                
                if(pattern==1) {
                    if(!Status[xx/block+2][yy/block+1] || !Status[xx/block+1][yy/block+1] || !Status[xx/block][yy/block+1] || !Status[xx/block-1][yy/block+1]) {
                        Status[xx/block+2][yy/block]=false;
                        Status[xx/block+1][yy/block]=false;
                        Status[xx/block][yy/block]=false;
                        Status[xx/block-1][yy/block]=false;
                        bool=true;
                    }
                }
                
                if(pattern==2) {
                    if(Status[xx/block][yy/block+3]==false) {
                        Status[xx/block][yy/block-1]=false;
                        Status[xx/block][yy/block]=false;
                        Status[xx/block][yy/block+1]=false;
                        Status[xx/block][yy/block+2]=false;
                        bool=true;
                    }
                }
                
                if(pattern==3) {
                    if(!Status[xx/block-2][yy/block+1] || !Status[xx/block-1][yy/block+1] || !Status[xx/block][yy/block+1] || !Status[xx/block+1][yy/block+1]) {
                        Status[xx/block-2][yy/block]=false;
                        Status[xx/block-1][yy/block]=false;
                        Status[xx/block][yy/block]=false;
                        Status[xx/block+1][yy/block]=false;
                        bool=true;
                    }
                }
                break;
            
            case 1:
                if(!Status[xx/block][yy/block+1] || !Status[xx/block+1][yy/block+1]) {
                    Status[xx/block][yy/block]=false;
                    Status[xx/block+1][yy/block]=false;
                    Status[xx/block][yy/block-1]=false;
                    Status[xx/block+1][yy/block-1]=false;
                    
                    colorStatus[xx/block][yy/block]=ran;
                    colorStatus[xx/block+1][yy/block]=ran;
                    colorStatus[xx/block][yy/block-1]=ran;
                    colorStatus[xx/block+1][yy/block-1]=ran;
                    bool=true;
                }
                break;
                
            case 2:
                if(pattern==0) {
                    if(!Status[xx/block][yy/block+2] || !Status[xx/block-1][yy/block+2]) {
                        Status[xx/block][yy/block-1]=false;
                        Status[xx/block][yy/block]=false;
                        Status[xx/block][yy/block+1]=false;
                        Status[xx/block-1][yy/block+1]=false;
                        
                        colorStatus[xx/block][yy/block-1]=ran;
                        colorStatus[xx/block][yy/block]=ran;
                        colorStatus[xx/block][yy/block+1]=ran;
                        colorStatus[xx/block-1][yy/block+1]=ran;
                        bool=true;
                    }
                }
                
                if(pattern==1) {
                    if(!Status[xx/block-1][yy/block+1] || !Status[xx/block][yy/block+1] || !Status[xx/block+1][yy/block+1]) {
                        Status[xx/block-1][yy/block]=false;
                        Status[xx/block][yy/block]=false;
                        Status[xx/block+1][yy/block]=false;
                        Status[xx/block-1][yy/block-1]=false;
                        
                        colorStatus[xx/block-1][yy/block]=ran;
                        colorStatus[xx/block][yy/block]=ran;
                        colorStatus[xx/block+1][yy/block]=ran;
                        colorStatus[xx/block-1][yy/block-1]=ran;
                        bool=true;
                    }
                }
                
                if(pattern==2) {
                    if(!Status[xx/block][yy/block+2] || !Status[xx/block+1][yy/block]) {
                        Status[xx/block][yy/block-1]=false;
                        Status[xx/block][yy/block]=false;
                        Status[xx/block][yy/block+1]=false;
                        Status[xx/block+1][yy/block-1]=false;
                            
                        colorStatus[xx/block][yy/block-1]=ran;
                        colorStatus[xx/block][yy/block]=ran;
                        colorStatus[xx/block][yy/block+1]=ran;
                        colorStatus[xx/block+1][yy/block-1]=ran;
                        bool=true;
                    }
                }
                
                if(pattern==3) {
                    if(!Status[xx/block-1][yy/block+1] || !Status[xx/block][yy/block+1] || !Status[xx/block+1][yy/block+2]) {
                        Status[xx/block-1][yy/block]=false;
                        Status[xx/block][yy/block]=false;
                        Status[xx/block+1][yy/block]=false;
                        Status[xx/block+1][yy/block+1]=false;
                            
                        colorStatus[xx/block-1][yy/block]=ran;
                        colorStatus[xx/block][yy/block]=ran;
                        colorStatus[xx/block+1][yy/block]=ran;
                        colorStatus[xx/block+1][yy/block+1]=ran;
                        bool=true;
                    }
                }
                break;
                
            case 3:
                if(pattern==0) {
                    if(!Status[xx/block][yy/block+2] || !Status[xx/block+1][yy/block+2]) {
                        Status[xx/block][yy/block-1]=false;
                        Status[xx/block][yy/block]=false;
                        Status[xx/block][yy/block+1]=false;
                        Status[xx/block+1][yy/block+1]=false;
                        
                        colorStatus[xx/block][yy/block-1]=ran;
                        colorStatus[xx/block][yy/block]=ran;
                        colorStatus[xx/block][yy/block+1]=ran;
                        colorStatus[xx/block+1][yy/block+1]=ran;
                        bool=true;
                    }
                }
            
                if(pattern==1) {
                    if(!Status[xx/block+1][yy/block+1] || !Status[xx/block][yy/block+1] || !Status[xx/block-1][yy/block+2]) {
                        Status[xx/block-1][yy/block]=false;
                        Status[xx/block][yy/block]=false;
                        Status[xx/block+1][yy/block]=false;
                        Status[xx/block-1][yy/block+1]=false;
                            
                        colorStatus[xx/block-1][yy/block]=ran;
                        colorStatus[xx/block][yy/block]=ran;
                        colorStatus[xx/block+1][yy/block]=ran;
                        colorStatus[xx/block-1][yy/block+1]=ran;
                        bool=true;
                    }
                }
                
                if(pattern==2) {
                    if(!Status[xx/block-1][yy/block] || !Status[xx/block][yy/block+2]) {
                        Status[xx/block][yy/block-1]=false;
                        Status[xx/block][yy/block]=false;
                        Status[xx/block][yy/block+1]=false;
                        Status[xx/block-1][yy/block-1]=false;
                            
                        colorStatus[xx/block][yy/block-1]=ran;
                        colorStatus[xx/block][yy/block]=ran;
                        colorStatus[xx/block][yy/block+1]=ran;
                        colorStatus[xx/block-1][yy/block-1]=ran;
                        bool=true;
                    }
                }
                
                if(pattern==3) {
                    if(!Status[xx/block-1][yy/block+1] || !Status[xx/block][yy/block+1] || !Status[xx/block+1][yy/block+1]) {
                        Status[xx/block-1][yy/block]=false;
                        Status[xx/block][yy/block]=false;
                        Status[xx/block+1][yy/block]=false;
                        Status[xx/block+1][yy/block-1]=false;
                            
                        colorStatus[xx/block-1][yy/block]=ran;
                        colorStatus[xx/block][yy/block]=ran;
                        colorStatus[xx/block+1][yy/block]=ran;
                        colorStatus[xx/block+1][yy/block-1]=ran;
                        bool=true;
                    }
                }
                break;
                

            case 4:
                if(pattern==0) {
                    if(!Status[xx/block][yy/block+2] || !Status[xx/block+1][yy/block+1]) {
                        Status[xx/block][yy/block+1]=false;
                        Status[xx/block][yy/block]=false;
                        Status[xx/block+1][yy/block]=false;
                        Status[xx/block+1][yy/block-1]=false;
                        
                        colorStatus[xx/block][yy/block+1]=ran;
                        colorStatus[xx/block][yy/block]=ran;
                        colorStatus[xx/block+1][yy/block]=ran;
                        colorStatus[xx/block+1][yy/block-1]=ran;
                        bool=true;
                    }
                }
                
            if(pattern==1) {
                if(!Status[xx/block-1][yy/block+1] || !Status[xx/block][yy/block+2] || !Status[xx/block+1][yy/block+2]) {
                    Status[xx/block-1][yy/block]=false;
                    Status[xx/block][yy/block]=false;
                    Status[xx/block][yy/block+1]=false;
                    Status[xx/block+1][yy/block+1]=false;
                        
                    colorStatus[xx/block-1][yy/block]=ran;
                    colorStatus[xx/block][yy/block]=ran;
                    colorStatus[xx/block][yy/block+1]=ran;
                    colorStatus[xx/block+1][yy/block+1]=ran;
                    bool=true;
                }
            }
            
            if(pattern==2) {
                if(!Status[xx/block-1][yy/block+2] || !Status[xx/block][yy/block+1]) {
                    Status[xx/block-1][yy/block+1]=false;
                    Status[xx/block-1][yy/block]=false;
                    Status[xx/block][yy/block]=false;
                    Status[xx/block][yy/block-1]=false;
                        
                    colorStatus[xx/block-1][yy/block+1]=ran;
                    colorStatus[xx/block-1][yy/block]=ran;
                    colorStatus[xx/block][yy/block]=ran;
                    colorStatus[xx/block][yy/block-1]=ran;
                    bool=true;
                }
            }
            
            if(pattern==3) {
                if(!Status[xx/block-1][yy/block] || !Status[xx/block][yy/block+1] || !Status[xx/block+1][yy/block+1]) {
                    Status[xx/block-1][yy/block-1]=false;
                    Status[xx/block][yy/block-1]=false;
                    Status[xx/block][yy/block]=false;
                    Status[xx/block+1][yy/block]=false;
                        
                    colorStatus[xx/block-1][yy/block-1]=ran;
                    colorStatus[xx/block][yy/block-1]=ran;
                    colorStatus[xx/block][yy/block]=ran;
                    colorStatus[xx/block+1][yy/block]=ran;
                    bool=true;
                }
            }
            break;
            
            case 5:
                if(pattern==0) {
                    if(!Status[xx/block-1][yy/block+1] || !Status[xx/block][yy/block+2]) {
                        Status[xx/block-1][yy/block-1]=false;
                        Status[xx/block-1][yy/block]=false;
                        Status[xx/block][yy/block]=false;
                        Status[xx/block][yy/block+1]=false;
                        
                        colorStatus[xx/block-1][yy/block-1]=ran;
                        colorStatus[xx/block-1][yy/block]=ran;
                        colorStatus[xx/block][yy/block]=ran;
                        colorStatus[xx/block][yy/block+1]=ran;
                        bool=true;
                    }
                }
                
            if(pattern==1) {
                if(!Status[xx/block-1][yy/block+1] || !Status[xx/block][yy/block+1] || !Status[xx/block+1][yy/block]) {
                    Status[xx/block-1][yy/block]=false;
                    Status[xx/block][yy/block]=false;
                    Status[xx/block][yy/block-1]=false;
                    Status[xx/block+1][yy/block-1]=false;
                        
                    colorStatus[xx/block-1][yy/block]=ran;
                    colorStatus[xx/block][yy/block]=ran;
                    colorStatus[xx/block][yy/block-1]=ran;
                    colorStatus[xx/block+1][yy/block-1]=ran;
                    bool=true;
                }
            }
            
            if(pattern==2) {
                if(!Status[xx/block][yy/block+1] || !Status[xx/block+1][yy/block+2]) {
                    Status[xx/block][yy/block-1]=false;
                    Status[xx/block][yy/block]=false;
                    Status[xx/block+1][yy/block]=false;
                    Status[xx/block+1][yy/block+1]=false;
                        
                    colorStatus[xx/block][yy/block-1]=ran;
                    colorStatus[xx/block][yy/block]=ran;
                    colorStatus[xx/block+1][yy/block]=ran;
                    colorStatus[xx/block+1][yy/block+1]=ran;
                    bool=true;
                }
            }
            
            if(pattern==3) {
                if(!Status[xx/block-1][yy/block+2] || !Status[xx/block][yy/block+2] || !Status[xx/block+1][yy/block+1]) {
                    Status[xx/block-1][yy/block+1]=false;
                    Status[xx/block][yy/block+1]=false;
                    Status[xx/block][yy/block]=false;
                    Status[xx/block+1][yy/block]=false;
                        
                    colorStatus[xx/block-1][yy/block+1]=ran;
                    colorStatus[xx/block][yy/block+1]=ran;
                    colorStatus[xx/block][yy/block]=ran;
                    colorStatus[xx/block+1][yy/block]=ran;
                    bool=true;
                }
            }
            break;
                
            case 6:
                if(pattern==0) {
                    if(!Status[xx/block-1][yy/block+1] || !Status[xx/block][yy/block+1] || !Status[xx/block+1][yy/block+1]) {
                        Status[xx/block-1][yy/block]=false;
                        Status[xx/block][yy/block]=false;
                        Status[xx/block+1][yy/block]=false;
                        Status[xx/block][yy/block-1]=false;
                        
                        colorStatus[xx/block-1][yy/block]=ran;
                        colorStatus[xx/block][yy/block]=ran;
                        colorStatus[xx/block+1][yy/block]=ran;
                        colorStatus[xx/block][yy/block-1]=ran;
                        bool=true;
                    }
                }
                
                if(pattern==1) {
                    if(!Status[xx/block][yy/block+2] || !Status[xx/block+1][yy/block+1]) {
                        Status[xx/block][yy/block-1]=false;
                        Status[xx/block][yy/block]=false;
                        Status[xx/block][yy/block+1]=false;
                        Status[xx/block+1][yy/block]=false;
                        
                        colorStatus[xx/block][yy/block-1]=ran;
                        colorStatus[xx/block][yy/block]=ran;
                        colorStatus[xx/block][yy/block+1]=ran;
                        colorStatus[xx/block+1][yy/block]=ran;
                        bool=true;
                    }
                }
                
                if(pattern==2) {
                    if(!Status[xx/block-1][yy/block+1] || !Status[xx/block][yy/block+2] || !Status[xx/block+1][yy/block+1]) {
                        Status[xx/block-1][yy/block]=false;
                        Status[xx/block][yy/block]=false;
                        Status[xx/block+1][yy/block]=false;
                        Status[xx/block][yy/block+1]=false;
                            
                        colorStatus[xx/block-1][yy/block]=ran;
                        colorStatus[xx/block][yy/block]=ran;
                        colorStatus[xx/block+1][yy/block]=ran;
                        colorStatus[xx/block][yy/block+1]=ran;
                        bool=true;
                    }
                }
                
                if(pattern==3) {
                    if(!Status[xx/block-1][yy/block+1] || !Status[xx/block][yy/block+2]) {
                        Status[xx/block-1][yy/block]=false;
                        Status[xx/block][yy/block-1]=false;
                        Status[xx/block][yy/block]=false;
                        Status[xx/block][yy/block+1]=false;
                            
                        colorStatus[xx/block-1][yy/block]=ran;
                        colorStatus[xx/block][yy/block-1]=ran;
                        colorStatus[xx/block][yy/block]=ran;
                        colorStatus[xx/block][yy/block+1]=ran;
                        bool=true;
                    }
                }
                break;
        }
        
        return bool;
    }
    
    public static boolean leftCheck(int xx,int yy,int width,int block,boolean Status[][],int pattern,int ran) {
        
        bool=false;
        
        switch(ran) {
            case 0:
                if(pattern==0) {
                    if(xx>=block && Status[xx/block-1][yy/block+1] && Status[xx/block-1][yy/block] && Status[xx/block-1][yy/block-1] && Status[xx/block-1][yy/block-2]) {
                        bool=true;
                    }
                }
                
                if(pattern==1) {
                    if(xx>=block*2 && Status[xx/block-2][yy/block]) {
                        bool=true;
                    }
                }
                
                if(pattern==2) {
                    if(xx>=block && Status[xx/block-1][yy/block-1] && Status[xx/block-1][yy/block] && Status[xx/block-1][yy/block+1] && Status[xx/block-1][yy/block+2]) {
                        bool=true;
                    }
                }
                
                if(pattern==3) {
                    if(xx>=block*3 && Status[xx/block-3][yy/block]) {
                        bool=true;
                    }
                }
                break;
                
            case 1:
                if(xx>=block && Status[xx/block-1][yy/block] && Status[xx/block-1][yy/block-1]) {
                    bool=true;
                }
                break;
                
            case 2:
                if(pattern==0) {
                    if(xx>=block*2 && Status[xx/block-2][yy/block+1] && Status[xx/block-1][yy/block] && Status[xx/block-1][yy/block-1]) {
                        bool=true;
                    }
                }
                
                if(pattern==1) {
                    if(xx>=block*2 && Status[xx/block-2][yy/block] && Status[xx/block-2][yy/block-1]) {
                        bool=true;
                    }
                }
                
                if(pattern==2) {
                    if(xx>=block && Status[xx/block-1][yy/block-1] && Status[xx/block-1][yy/block] && Status[xx/block-1][yy/block+1]) {
                        bool=true;
                    }
                }
                
                if(pattern==3) {
                    if(xx>=block*2 && Status[xx/block-2][yy/block] && Status[xx/block][yy/block+1]) {
                        bool=true;
                    }
                }
                break;
                
            case 3:
                if(pattern==0) {
                    if(xx>=block && Status[xx/block-1][yy/block-1] && Status[xx/block][yy/block] && Status[xx/block][yy/block+1]) {
                        bool=true;
                    }
                }
                
            if(pattern==1) {
                if(xx>=block*2 && Status[xx/block-2][yy/block] && Status[xx/block-2][yy/block+1]) {
                    bool=true;
                }
            }
            
            if(pattern==2) {
                if(xx>=block*2 && Status[xx/block-2][yy/block-1] && Status[xx/block-1][yy/block] && Status[xx/block-1][yy/block+1]) {
                    bool=true;
                }
            }
            
            if(pattern==3) {
                if(xx>=block*2 && Status[xx/block-2][yy/block] && Status[xx/block][yy/block-1]) {
                    bool=true;
                }
            }
            break;
            
            case 4:
                if(pattern==0) {
                    if(xx>=block && Status[xx/block-1][yy/block+1] && Status[xx/block-1][yy/block] && Status[xx/block][yy/block-1]) {
                        bool=true;
                    }
                }
                
            if(pattern==1) {
                if(xx>=block*2 && Status[xx/block-2][yy/block] && Status[xx/block-1][yy/block+1]) {
                    bool=true;
                }
            }
            
            if(pattern==2) {
                if(xx>=block*2 && Status[xx/block-1][yy/block-1] && Status[xx/block-2][yy/block] && Status[xx/block-2][yy/block+1]) {
                    bool=true;
                }
            }
            
            if(pattern==3) {
                if(xx>=block*2 && Status[xx/block-2][yy/block-1] && Status[xx/block-1][yy/block]) {
                    bool=true;
                }
            }
            break;
            
            case 5:
                if(pattern==0) {
                    if(xx>=block*2 && Status[xx/block-2][yy/block-1] && Status[xx/block-2][yy/block] && Status[xx/block-1][yy/block+1]) {
                        bool=true;
                    }
                }
                
            if(pattern==1) {
                if(xx>=block*2 && Status[xx/block-2][yy/block] && Status[xx/block-1][yy/block-1]) {
                    bool=true;
                }
            }
            
            if(pattern==2) {
                if(xx>=block && Status[xx/block-1][yy/block-1] && Status[xx/block-1][yy/block] && Status[xx/block][yy/block+1]) {
                    bool=true;
                }
            }
            
            if(pattern==3) {
                if(xx>=block*2 && Status[xx/block-1][yy/block] && Status[xx/block-2][yy/block+1]) {
                    bool=true;
                }
            }
            break;
                
            case 6:
                if(pattern==0) {
                    if(xx>=block*2 && Status[xx/block-2][yy/block] && Status[xx/block-1][yy/block-1]) {
                        bool=true;
                    }
                }
                
                if(pattern==1) {
                    if(xx>=block && Status[xx/block-1][yy/block-1] && Status[xx/block-1][yy/block] && Status[xx/block-1][yy/block-1]) {
                        bool=true;
                    }
                }
                
                if(pattern==2) {
                    if(xx>=block*2 && Status[xx/block-2][yy/block] && Status[xx/block-1][yy/block+1]) {
                        bool=true;
                    }
                }
                
                if(pattern==3) {
                    if(xx>=block*2 && Status[xx/block-1][yy/block-1] && Status[xx/block-2][yy/block] && Status[xx/block-1][yy/block+1]) {
                        bool=true;
                    }
                }
                break;
            }
        
        return bool;
    }
    
    public static boolean rightCheck(int xx,int yy,int width,int block,boolean Status[][],int pattern,int ran) {
        
        bool=false;
        
        switch(ran) {
            case 0:
                if(pattern==0) {
                    if(xx<width-block && Status[xx/block+1][yy/block+1] && Status[xx/block+1][yy/block] && Status[xx/block+1][yy/block-1] && Status[xx/block+1][yy/block-2]) {
                        bool=true;
                    }
                }
                
                if(pattern==1) {
                    if(xx<width-block*3 && Status[xx/block+3][yy/block]) {
                        bool=true;
                    }
                }
                
                if(pattern==2) {
                    if(xx<width-block && Status[xx/block+1][yy/block-1] && Status[xx/block+1][yy/block] && Status[xx/block+1][yy/block+1] && Status[xx/block+1][yy/block+2]) {
                        bool=true;
                    }
                }
                
                if(pattern==3) {
                    if(xx<width-block*2 && Status[xx/block+2][yy/block]) {
                        bool=true;
                    }
                }
                break;
                
            case 1:
                if(xx<width-block*2 && Status[xx/block+2][yy/block] && Status[xx/block+2][yy/block-1]) {
                    bool=true;
                }
                break;
                
            case 2:
                if(pattern==0) {
                    if(xx<width-block && Status[xx/block+1][yy/block-1] && Status[xx/block+1][yy/block] && Status[xx/block+1][yy/block+1]) {
                        bool=true;
                    }
                }
                
                if(pattern==1) {
                    if(xx<width-block*2 && Status[xx/block][yy/block-1] && Status[xx/block+2][yy/block]) {
                        bool=true;
                    }
                }
                
                if(pattern==2) {
                    if(xx<width-block*2 && Status[xx/block+2][yy/block-1] && Status[xx/block+1][yy/block] && Status[xx/block+1][yy/block+1]) {
                        bool=true;
                    }
                }
                
                if(pattern==3) {
                    if(xx<width-block*2 && Status[xx/block+2][yy/block+1] && Status[xx/block+2][yy/block]) {
                        bool=true;
                    }
                }
                break;
                
            case 3:
                if(pattern==0) {
                    if(xx<width-block*2 && Status[xx/block+1][yy/block-1] && Status[xx/block+1][yy/block] && Status[xx/block+2][yy/block+1]) {
                        bool=true;
                    }
                }
                
                if(pattern==1) {
                    if(xx<width-block*2 && Status[xx/block+2][yy/block] && Status[xx/block][yy/block+1]) {
                        bool=true;
                    }
                }
                
                if(pattern==2) {
                    if(xx<width-block  && Status[xx/block+1][yy/block-1] && Status[xx/block+1][yy/block]&& Status[xx/block+1][yy/block+1]) {
                        bool=true;
                    }
                }
                
                if(pattern==3) {
                    if(xx<width-block*2 && Status[xx/block+2][yy/block] && Status[xx/block+2][yy/block-1]) {
                        bool=true;
                    }
                }
                break;
                
            case 4:
                if(pattern==0) {
                    if(xx<width-block*2 && Status[xx/block+2][yy/block-1] && Status[xx/block+2][yy/block] && Status[xx/block+1][yy/block+1]) {
                        bool=true;
                    }
                }
                
                if(pattern==1) {
                    if(xx<width-block*2 && Status[xx/block+1][yy/block] && Status[xx/block+2][yy/block+1]) {
                        bool=true;
                    }
                }
                
                if(pattern==2) {
                    if(xx<width-block && Status[xx/block+1][yy/block-1] && Status[xx/block+1][yy/block] && Status[xx/block][yy/block+1]) {
                        bool=true;
                    }
                }
                
                if(pattern==3) {
                    if(xx<width-block*2 && Status[xx/block+1][yy/block-1] && Status[xx/block+2][yy/block]) {
                        bool=true;
                    }
                }
                break;
            
            case 5:
                if(pattern==0) {
                    if(xx<width-block && Status[xx/block][yy/block-1] && Status[xx/block+1][yy/block] && Status[xx/block+1][yy/block+1]) {
                        bool=true;
                    }
                }
                
                if(pattern==1) {
                    if(xx<width-block*2 && Status[xx/block+2][yy/block-1] && Status[xx/block+1][yy/block]) {
                        bool=true;
                    }
                }
                
                if(pattern==2) {
                    if(xx<width-block*2 && Status[xx/block+1][yy/block-1] && Status[xx/block+2][yy/block] && Status[xx/block+2][yy/block+1]) {
                        bool=true;
                    }
                }
                
                if(pattern==3) {
                    if(xx<width-block*2 && Status[xx/block+2][yy/block] && Status[xx/block+1][yy/block+1]) {
                        bool=true;
                    }
                }
                break;
                
            case 6:
                if(pattern==0) {
                    if(xx<width-block*2 && Status[xx/block+2][yy/block] && Status[xx/block+1][yy/block-1]) {
                        bool=true;
                    }
                }
                
                if(pattern==1) {
                    if(xx<width-block*2 && Status[xx/block+1][yy/block-1] && Status[xx/block+2][yy/block] && Status[xx/block+1][yy/block+1]) {
                        bool=true;
                    }
                }
                
                if(pattern==2) {
                    if(xx<width-block*2 && Status[xx/block+2][yy/block] && Status[xx/block+1][yy/block+1]) {
                        bool=true;
                    }
                }
                
                if(pattern==3) {
                    if(xx<width-block && Status[xx/block+1][yy/block-1] && Status[xx/block+1][yy/block] && Status[xx/block+1][yy/block+1]) {
                        bool=true;
                    }
                }
        }
        
        return bool;
    }
    
    public static boolean rightTurnCheck(int xx,int yy,int width,int block,boolean Status[][],int pattern,int ran) {
        
        bool=false;
        
        switch(ran) {
            
            case 0:
                if(pattern==0) {
                    if(xx>=block && xx<width-block*2) {
                        for(int i=1;i<3;i++) {
                            for(int j=0;j<3;j++) {
                                if(!Status[xx/block+i][yy/block-j]) {
                                    return bool; 
                                }
                            }
                        }
                        if(!Status[xx/block-1][yy/block] || !Status[xx/block-1][yy/block-1]) {
                            return bool;
                        }
                        
                        bool=true;
                    }
                }
                
                if(pattern==1) {
                    for(int i=0;i<3;i++) {
                        for(int j=1;j<3;j++) {
                            if(!Status[xx/block+i][yy/block+j]) {
                                return bool;
                            }
                        }
                    }
                    if(!Status[xx/block][yy/block-1] || !Status[xx/block-1][yy/block-1]) {
                        return bool;
                    }
                    
                    bool=true;
                }
                
                if(pattern==2) {
                    if(xx>=block*2 && xx<width-block) {
                        for(int i=1;i<3;i++) {
                            for(int j=0;j<3;j++) {
                                if(!Status[xx/block-i][yy/block+j]) {
                                    return bool; 
                                }
                            }
                        }
                        if(!Status[xx/block+1][yy/block] || !Status[xx/block+1][yy/block+1]) {
                            return bool;
                        }
                        
                        bool=true;
                    }
                }
                
                if(pattern==3) {
                    for(int i=0;i<3;i++) {
                        for(int j=1;j<3;j++) {
                            if(!Status[xx/block-i][yy/block+j]) {
                                return bool;
                            }
                        }
                    }
                    if(!Status[xx/block][yy/block+1] || !Status[xx/block+1][yy/block+1]) {
                        return bool;
                    }
                    
                    bool=true;
                }
                
                break;
                
            case 1:
                
                bool=true;
                break;
                
            case 2:
                
                if(pattern==0) {
                    if(xx<width-block) {
                        for(int i=0;i<2;i++) {
                            if(!Status[xx/block+1][yy/block-i] || !Status[xx/block-1][yy/block-i]){
                                return bool;
                            }
                        }
                        bool=true;
                    }
                }

                if(pattern==1) {
                    for(int i=0;i<2;i++) {
                        if(!Status[xx/block+i][yy/block+1] || !Status[xx/block+i][yy/block-1]) {
                            return bool;
                        }
                    }
                    bool=true;
                }

                if(pattern==2) {
                    if(xx>=block) {
                        for(int i=0;i<2;i++) {
                            if(!Status[xx/block+1][yy/block+i] || !Status[xx/block-1][yy/block+i]){
                                return bool;
                            }
                        }
                        bool=true;
                    }
                }

                if(pattern==3) {
                    for(int i=0;i<2;i++) {
                        if(!Status[xx/block-i][yy/block+1] || !Status[xx/block-i][yy/block-1]) {
                            return bool;
                        }
                    }
                    bool=true;
                }
                
                break;
                
            case 3:
                
                if(pattern==0 ||pattern==2) {
                    if(xx>=block && xx<width-block) {
                        for(int i=0;i<2;i++) {
                            if(!Status[xx/block+1][yy/block-i] || !Status[xx/block-1][yy/block+i]){
                                return bool;
                            }
                        }
                        bool=true;
                    }
                }

                if(pattern==1 || pattern==3) {
                    for(int i=0;i<2;i++) {
                        if(!Status[xx/block+i][yy/block+1] || !Status[xx/block-i][yy/block-1]) {
                            return bool;
                        }
                    }
                    bool=true;
                }
                
                break;
                
            case 4:

                if(pattern==0) {
                    if(xx>=block) {
                        if(Status[xx/block+1][yy/block+1] && Status[xx/block-1][yy/block] && Status[xx/block-1][yy/block+1]) {
                            bool=true;
                        }
                    }
                }

                if(pattern==1) {
                    if(Status[xx/block][yy/block-1] && Status[xx/block-1][yy/block-1] && Status[xx/block-1][yy/block+1]) {
                        bool=true;
                    }
                }

                if(pattern==2) {
                    if(xx<width-block) {
                        if(Status[xx/block+1][yy/block+1] && Status[xx/block+1][yy/block] && Status[xx/block-1][yy/block-1]) {
                            bool=true;
                        }
                    }
                }

                if(pattern==3) {
                    if(Status[xx/block][yy/block+1] && Status[xx/block+1][yy/block+1] && Status[xx/block+1][yy/block-1]) {
                        bool=true;
                    }
                }
                break;
                
            case 5:

                if(pattern==0) {
                    if(xx<width-block) {
                        if(Status[xx/block+1][yy/block] && Status[xx/block+1][yy/block-1] && Status[xx/block][yy/block-1] && Status[xx/block-1][yy/block+1]) {
                            bool=true;
                        }
                    }
                }

                if(pattern==1) {
                    if(Status[xx/block+1][yy/block] && Status[xx/block+1][yy/block+1] && Status[xx/block][yy/block+1] && Status[xx/block-1][yy/block-1]) {
                        bool=true;
                    }
                }

                if(pattern==2) {
                    if(xx>=block) {
                        if(Status[xx/block-1][yy/block] && Status[xx/block-1][yy/block+1] && Status[xx/block][yy/block+1] && Status[xx/block+1][yy/block-1]) {
                            bool=true;
                        }
                    }
                }

                if(pattern==3) {
                    if(Status[xx/block-1][yy/block] && Status[xx/block-1][yy/block-1] && Status[xx/block][yy/block-1] && Status[xx/block+1][yy/block+1]) {
                        bool=true;
                    }
                }
                break;
                
            case 6:

                if(pattern==0) {
                    if(Status[xx/block+1][yy/block+1] && Status[xx/block+1][yy/block-1] && Status[xx/block][yy/block+1] && Status[xx/block-1][yy/block-1]) {
                        bool=true;
                    }
                }

                if(pattern==1) {
                    if(xx>=block) {
                        if(Status[xx/block+1][yy/block+1] && Status[xx/block+1][yy/block-1] && Status[xx/block-1][yy/block] && Status[xx/block-1][yy/block+1]) {
                            bool=true;
                        }
                    }
                }

                if(pattern==2) {
                    if(Status[xx/block+1][yy/block+1] && Status[xx/block][yy/block-1] && Status[xx/block-1][yy/block+1] && Status[xx/block-1][yy/block-1]) {
                        bool=true;
                    }
                }

                if(pattern==3) {
                    if(xx<width-block) {
                        if(Status[xx/block+1][yy/block] && Status[xx/block+1][yy/block-1] && Status[xx/block-1][yy/block+1] && Status[xx/block-1][yy/block-1]) {
                            bool=true;
                        }
                    }
                }
                
                break;
        }
        
        return bool;
    }
}
		

Delete.java
/*
 * 作成日: 2004/07/27
 *
 * この生成されたコメントの挿入されるテンプレートを変更するため
 * ウィンドウ > 設定 > Java > コード生成 > コードとコメント
 */

/**
 * @author wacharo
 *
 * この生成されたコメントの挿入されるテンプレートを変更するため
 * ウィンドウ > 設定 > Java > コード生成 > コードとコメント
 */
public class Delete {
    
    static int deleteCount = 0;
    static int deleteScore = 0;
    
    public static void delete(boolean[][] Status,int[][] colorStatus,int x,int y) {
        int count = 0;
        int bonus = 0;
        
        for(int s=0;s<4;s++) {
        loop:    for(int j=0;j<y;j++) {
                    for(int i=0;i<x;i++) {
                            if(Status[i][j]) {
                                continue loop;
                            }
                            if(i==x-1) {
                                for(int n=j;n>0;n--) {
                                    for(int m=0;m<x;m++) {
                                        Status[m][n] = Status[m][n-1];
                                        colorStatus[m][n] = colorStatus[m][n-1];
                                    }
                                }
                                count++;
                            }
                    }
                    
                }
        }
        if(count==4) {
            bonus=6;
        }
        deleteScore += count+bonus;
        deleteCount += count;
    }

}
		

Clr.java
import java.awt.*;

public class Clr {
    	static Color[] clr = {Color.red, Color.yellow, Color.orange, Color.pink, Color.magenta, Color.blue, Color.green, Color.black};
}
		

top

20749