import java.applet.Applet;
import java.awt.*;
import java.awt.image.*;

public class CPuzzle extends Applet
{
	private CPuzzleElement 	m_Element[];	// Array der 9 PuzzelTeile.
	private CPuzzleField 	m_PuzzleField;	// Die Flaeche des Puzzels.

	public void init()
	{
		Image img[] = new Image[9];
		m_Element = new CPuzzleElement[9];
		MediaTracker tracker; // überwacht das Laden des Bildes
		tracker = new MediaTracker(this);
		for(int i = 0; i < 9; i++)
		{		
			img[i] = getImage(getCodeBase(), "puzzlejava-"+i+".gif");
			tracker.addImage(img[i], 0);
		}
		try
		{
			tracker.waitForID(0);
		}
		catch (InterruptedException e)
		{
			System.err.println("Error: "+e);
		}
		for(int j = 0; j < 9; j++)
		{
			m_Element[j] = new CPuzzleElement(img[j]);
			showStatus("Grafik initialisieren " +(j *12.5) +" %");
		}
		showStatus("Nun spielen!!");
		m_PuzzleField = new CPuzzleField(new Dimension(450, 450),m_Element);
		add("Center", m_PuzzleField);
		add("South", new CMergeButton("merge", m_PuzzleField));
	}

	public void start()
	{
		m_PuzzleField.repaint();
	}

	public String getAppletInfo()
	{
		return "This Applet was written by\n" +
			"Mirko Mumberg";
	}
}