package com.stj.views;
import java.awt.Color;
import java.awt.Graphics2D;
import java.util.Random;
/*
 潜艇发射的鱼雷击中战舰后爆炸的效果对象,原理:绘制多个从小到大然后从大到小的圆显示爆炸效果
 */
public class Blast implements Runnable
{
	private int X;  
	private int Y;
	private int[] r = {2,3,5,8,12,15,18,20,25,30,33,25,17,15,13,9,5}; //圆的半径集合
	private int   step = 0; //集合中圆的位置标记
	private boolean flag = false;
	
	public Blast(int x,int y)
	{
		this.X = x;
		this.Y = y;
	}
	
	
	
	public void drawBlast(Graphics2D g)
	{
		Random random =new Random();
		int    c = random.nextInt(2);
		if(c == 0)
		{
			g.setColor( Color.RED);
		}
		else if(c == 1)
		{
			g.setColor(Color.ORANGE);
		}
		
		if(this.step < r.length)
		{
			//System.out.println("draw");
			//g.setColor(Color.gray);
			g.fillOval(this.X, this.Y, this.r[this.step], this.r[this.step]);
			//step ++;
		}
		
	
	}
		public void run() 
		{
			while(!this.flag)
			{
				step ++;
				//System.out.println(step);
				try {
					Thread.sleep(10);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				if(this.step == r.length)
				{
					this.flag = true;
				}
			}
			
		}
		public int getX() {
			return X;
		}
		public void setX(int x) {
			X = x;
		}
		public int getY() {
			return Y;
		}
		public void setY(int y) {
			Y = y;
		}
		public boolean isFlag() {
			return flag;
		}
		public void setFlag(boolean flag) {
			this.flag = flag;
		}
		
		
}
最近下载更多
                
                2890892945     LV2
                2023年12月26日
            
            
        
                huangzy     LV12
                2023年4月6日
            
            
        
                1839855274     LV1
                2021年12月21日
            
            
        
                wjl0529     LV3
                2021年12月21日
            
            
        
                咕噜咕噜啦la     LV9
                2021年12月18日
            
            
        
                选了了     LV7
                2021年12月15日
            
            
        
                MyList     LV1
                2021年12月10日
            
            
        
                tangjj7260     LV18
                2021年10月26日
            
            
        
                焦油怪     LV1
                2021年9月30日
            
            
        
                小白小怪     LV10
                2021年6月19日
            
            
        
最近浏览更多
                
                2890892945     LV2
                2023年12月26日
            
            
        
                yellee    
                2023年10月23日
            
            
                    暂无贡献等级
            
        
                yerwiu     LV10
                2023年7月30日
            
            
        
                y1214435276     LV9
                2023年7月11日
            
            
        
                17683946472     LV9
                2023年6月8日
            
            
        
                huangzy     LV12
                2023年4月6日
            
            
        
                bin2337     LV4
                2023年3月30日
            
            
        
                小学虎QAQ    
                2022年12月9日
            
            
                    暂无贡献等级
            
        
                13373265420     LV1
                2022年12月8日
            
            
        
                取名字好麻烦     LV5
                2022年10月30日
            
            
        
                
                
                