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

📄 animatedelete.java

📁 一个已经实现的连连看小游戏的源码
💻 JAVA
字号:
// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   AnimateDelete.java

package kyodai.map;

import java.awt.Point;
import java.io.PrintStream;
import javax.swing.JButton;
import kyodai.Kyodai;

public class AnimateDelete
    implements Runnable
{

    public AnimateDelete(JButton dots[])
    {
        array = new int[44];
        count = 0;
        AnimateDelete _tmp = this;
        dots = dots;
        array = new int[0];
    }

    public AnimateDelete(int direct, Point a, Point b)
    {
        array = new int[44];
        count = 0;
        initArray();
        calcTwoPoint(direct, a, b);
        start();
    }

    public AnimateDelete(int direct, Point a, Point b, Point c)
    {
        array = new int[44];
        count = 0;
        initArray();
        if(direct == 1)
        {
            calcTwoPoint(1, a, b);
            count--;
            calcTwoPoint(0, b, c);
        } else
        {
            calcTwoPoint(0, a, b);
            count--;
            calcTwoPoint(1, b, c);
        }
        start();
    }

    public AnimateDelete(int direct, Point a, Point b, Point c, Point d)
    {
        array = new int[44];
        count = 0;
        initArray();
        if(direct == 1)
        {
            calcTwoPoint(1, a, b);
            count--;
            calcTwoPoint(0, b, c);
            count--;
            calcTwoPoint(1, c, d);
        } else
        {
            calcTwoPoint(0, a, b);
            count--;
            calcTwoPoint(1, b, c);
            count--;
            calcTwoPoint(0, c, d);
        }
        start();
    }

    private void calcTwoPoint(int direct, Point a, Point b)
    {
        int offset = 0;
        if(direct == 1)
        {
            if(a.y > b.y)
            {
                for(int y = a.y; y >= b.y; y--)
                {
                    offset = a.x * 17 + y;
                    array[count] = offset;
                    count++;
                }

            } else
            {
                for(int y = a.y; y <= b.y; y++)
                {
                    offset = a.x * 17 + y;
                    array[count] = offset;
                    count++;
                }

            }
        } else
        if(a.x > b.x)
        {
            for(int x = a.x; x >= b.x; x--)
            {
                offset = x * 17 + a.y;
                array[count] = offset;
                count++;
            }

        } else
        {
            for(int x = a.x; x <= b.x; x++)
            {
                offset = x * 17 + a.y;
                array[count] = offset;
                count++;
            }

        }
    }

    public void setSpeed(int speed)
    {
        delay = speed * 10;
    }

    private void initArray()
    {
        if(array == null || array.length == 0)
            return;
        for(int i = 0; i < array.length; i++)
            array[i] = -1;

    }

    public void test()
    {
        if(array == null || array.length == 0)
            return;
        for(int i = 0; i < array.length; i++)
            if(array[i] != -1)
                message("[" + array[i] + "]  ");

        System.out.println();
    }

    public void start()
    {
        thread = new Thread(this);
        thread.start();
    }

    public void run()
    {
        if(count < 2)
            return;
        Thread currentThread = Thread.currentThread();
        for(boolean animate = true; thread == currentThread && animate; animate = false)
        {
            for(int i = 1; i < count - 1; i++)
            {
                dots[array[i]].setEnabled(true);
                dots[array[i]].setIcon(Kyodai.GuideIcon);
                try
                {
                    Thread _tmp = thread;
                    Thread.sleep(delay);
                }
                catch(InterruptedException ex) { }
            }

            for(int i = 1; i < count - 1; i++)
            {
                dots[array[i]].setIcon(null);
                dots[array[i]].setEnabled(false);
                try
                {
                    Thread _tmp1 = thread;
                    Thread.sleep(delay);
                }
                catch(InterruptedException ex) { }
            }

            dots[array[0]].setIcon(null);
            dots[array[0]].setEnabled(false);
            dots[array[count - 1]].setIcon(null);
            dots[array[count - 1]].setEnabled(false);
        }

        stop();
    }

    public void stop()
    {
        if(thread != null)
            thread = null;
    }

    void message(String str)
    {
        System.out.println(str);
    }

    static JButton dots[];
    static long delay = 20L;
    int array[];
    private int count;
    private volatile Thread thread;

}

⌨️ 快捷键说明

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