package com.stj.views;
import java.awt.*;
import javax.swing.ImageIcon;
public class Bumb implements Runnable
{
	private WarShip ship;
	private int  beginX;
	private int  beginY;
	private int  width = 5;
	private int  height = 15;
	public  boolean flag = false;
	private  MyPanel panel;
	private Image image;
	
	public Bumb(MyPanel p,WarShip ship)
	{
		this.beginX= ship.getBeginX()+20;
		this.beginY = ship.getBeginY()+20;
		this.panel = p;
		this.ship  = ship;
		image = Toolkit.getDefaultToolkit().getImage("imgs/炸弹.png");
		image = new ImageIcon(image).getImage();
		this.width = image.getWidth(panel);
		this.height = image.getHeight(panel);
		//System.out.println("bumb width:"+this.width);
		//System.out.println("bumb height:"+this.height);
		
	}
	public void run() 
	{
		
		
			while(!flag)
			{
				this.moveDown();
				
				
				if(this.panel.isStop() == true)
				{
						synchronized(MyPanel.subLock)
						{
							try
							{
								MyPanel.subLock.wait();
							}
							catch(Exception e)
							{
								e.printStackTrace();
								this.flag = true;
							}
						}
					
				}
				
			
				try
				{
					Thread.sleep(10);
				}
				catch(Exception event)
				{
					event.printStackTrace();
					this.flag = true;
				}
			}
		}
	
		
	
	
	
	public void drawBumb(Graphics2D g)
	{
		//g.setColor(Color.BLACK);
		//g.fillOval(this.beginX, this.beginY, this.radius, this.radius);
		g.drawImage(image, this.beginX, this.beginY,  this.panel);
		
	}
	
	public void moveDown()
	{
		
		this.beginY += 1;
		if(this.beginY > (this.panel.getHeight() - this.height / 2))
		{
			flag = true;
		}
		//this.panel.repaint();
	}
	
	
	public WarShip getShip() {
		return ship;
	}
	public void setShip(WarShip ship) {
		this.ship = ship;
	}
	public int getBeginX() {
		return beginX;
	}
	public void setBeginX(int beginX) {
		this.beginX = beginX;
	}
	public int getBeginY() {
		return beginY;
	}
	public void setBeginY(int beginY) {
		this.beginY = beginY;
	}
	public int getWidth() {
		return width;
	}
	public void setWidth(int width) {
		this.width = width;
	}
	public int getHeight() {
		return height;
	}
	public void setHeight(int height) {
		this.height = height;
	}
}
最近下载更多
                
                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日
            
            
        
                
                
                