import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.io.File;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.IOException;

/**
 * Write a description of class Writer here.
 * 
 * @author Felix Pfeffer
 * @version 1.0
 */
public class Writer extends Actor
{
    int[][] akt_map = new int[(int)TeD_World.NY][(int)TeD_World.NX];
    
    
    
    public void getMap(int map[][])
    {
        for(int i = 0; i < TeD_World.NY ; ++i)
        {
            for(int j = 0; j < TeD_World.NX ; ++j)
            {   
                akt_map[i][j] = map[i][j];
            }
        }
    }
     /**
     * druckt Maps aufs Spielfeld
     */
    public void printMap(int mapnummer)
    {
        
        
        try 
        {
            File file;
            file = new File("maps/map"+mapnummer+".txt");
            FileWriter writer = new FileWriter(file ,false);
            BufferedWriter bwriter;
            bwriter = new BufferedWriter(writer);
       
           
       
            for(int i = 0; i < TeD_World.NY ; ++i)
            {
                for(int j = 0; j < TeD_World.NX ; ++j)
                {   
                    if(akt_map[i][j] < 10)
                    {
                        bwriter.write("0"+akt_map[i][j]+" ");
                    }
                    else
                    {
                        bwriter.write(akt_map[i][j]+" ");
                    }
                }
                 bwriter.write(System.getProperty("line.separator"));
            }
           
            bwriter.flush();
            bwriter.close();
        } 
        catch (IOException e) 
        {
            e.printStackTrace();
        }
        
    }
}
