import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.lang.Math;
/**
 * Write a description of class Fire here.
 * 
 * @author Jonathan Lutz
 * @version (a version number or a date)
 */
public class Fire extends Element
{
    public static String[] firestring = {"Fire-Skins/Feuer1.png","Fire-Skins/Feuer2.png" ,"Fire-Skins/Feuer3.png","Fire-Skins/Feuer4.png","Fire-Skins/Feuer5.png","Fire-Skins/Feuer6.png"};
    GreenfootSound fire = new GreenfootSound("fire2.mp3");
    double distance;
    
    /**
     * Act - do whatever the Fire wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        if (Welt.pause != true)
        {
            move(firestring, true, 32,32);
        }
        double d = (Linch.Xcoord-getX())*(Linch.Xcoord-getX())+(Linch.Ycoord-getY())*(Linch.Ycoord-getY());
        distance = 0.5 * Math.sqrt(d);
        if (distance > (100))
        {
            distance = (100);
        }
        int volume = 100-(int)Math.round(distance);
        fire.setVolume(volume);
    }    

    public Fire()
    {
        GreenfootImage img = new GreenfootImage("Fire-Skins/Feuer1.png");
        setImage(img);
        fire.playLoop();
        fire.setVolume(0);
    }
}
