import java.applet.Applet;
import java.awt.*;
import java.awt.image.*;

public class film extends Applet implements Runnable
{
    Thread ourThread;
    Graphics GR;
    String text;
    int AccountOfSentences=3;
    int y_pos;
    int alt;
    String fullSentence;
    int x_pos;
    source sentence[] = new source[AccountOfSentences];;

    public void paint(Graphics g)
    {
        setBackground(Color.black);
        g.setColor(Color.black);
        g.fillRect(0,0,200,100);
    }


    public void init()
    {
        GR= getGraphics();
        GR.setColor (Color.blue);
        sentence[0] = new source("I'm proud ");
        sentence[1] = new source("to welcome you ");
        sentence[2] = new source("to Thoro's Homepage!");
    }

    public void start()
    {
        if (ourThread == null)
        {
            ourThread = new Thread(this);
            ourThread.start ();
        }
    }
    public void stop ()
    {
        if (ourThread != null)
        {
            ourThread.stop();
            ourThread = null;
        }
    }




    public void run()
    {
    for(;;)
    {
       GR.clearRect(0,0,200,100);
       x_pos=50;
       for(int x=0; x<AccountOfSentences; x++)//growing
       {
        for(int i=5; i<20; i++)
        {
            try
            {
                Thread.sleep (20);
            }
            catch (InterruptedException except){}
            GR.setColor(Color.black);
            GR.drawString(sentence[x].getText(), x_pos,50);
            GR.setColor(Color.blue);

            Font f = new Font ("Schrift", Font.PLAIN, i);
            GR.setFont(f);
            GR.drawString(sentence[x].getText(), x_pos,50);
        }
            try
            {
                Thread.sleep (700);
            }
            catch (InterruptedException except){}

            GR.setColor(Color.black);
            GR.drawString(sentence[x].getText(), x_pos,50);
            GR.setColor(Color.blue);

            x_pos = x_pos - 20;

    }
    x_pos = 50;
    y_pos = 30;
    Font f = new Font ("Script", Font.ITALIC, 19);
    GR.setFont(f);
    for(int i=0; i<AccountOfSentences; i++)//moving from left to middle
    {
        for (int n=-150; n<x_pos;)
        {
            n = n +5;
            GR.drawString(sentence[i].getText(), n, y_pos);
            try
            {
                Thread.sleep (20);
            }
            catch (InterruptedException except){}
            if (n < x_pos)
            {
                GR.setColor(Color.black);
                GR.drawString(sentence[i].getText(), n, y_pos);
                GR.setColor(Color.blue);
            }

        }
        y_pos = y_pos + 30;
        x_pos = x_pos - 23;

    }

            try
            {
                Thread.sleep (1000);
            }
            catch (InterruptedException except){}




    Font f2 = new Font ("Script", Font.BOLD, 19);
    GR.setFont(f2);
    GR.clearRect(0,0,200,100);
    for (int n=210; n>-600;)//scrolling from right to left
    {   n = n -5;
        fullSentence=sentence[0].getText() + sentence[1].getText() + sentence[2].getText();
        GR.drawString(fullSentence, n, 50);
        try
        {
            Thread.sleep (30);
        }
        catch (InterruptedException except){}
        GR.setColor(Color.black);
        GR.drawString(fullSentence, n, 50);
        GR.setColor(Color.blue);


    }

    for(double i=1; i<6; i++)
    {
        x_pos = 50;
        y_pos = 30;
        GR.clearRect(0,0,200,100);

        if ((i/2) != 1 && (i/2) != 2)
        {
           for(int x=0; x<AccountOfSentences; x++)//red blinking
            {
                GR.setColor(Color.red);
                Font f3 = new Font ("Schrift", Font.BOLD, 18);
                GR.setFont(f3);

                GR.drawString(sentence[x].getText(), x_pos, y_pos);
                x_pos = x_pos - 23;
                y_pos = y_pos + 30;
            }
            try
            {
                Thread.sleep (1000);
            }
            catch (InterruptedException except){}
        }
        else
        {
            try
            {
                Thread.sleep (300);
            }
            catch (InterruptedException except){}
        }


    }

    GR.setColor(Color.blue);

    }

    }


}

class source
{
    public source(String s)
    {
        inhalt = s;
    }

    public String getText()
    {
        return inhalt;
    }

    public String inhalt;
}