Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Main;
- import java.awt.*;
- import java.io.*;
- import java.util.*;
- import javax.swing.*;
- public class Background {
- private BufferedReader br;
- private String map[][];
- private Image path,wall1,wall2;
- public Background(){
- ImageIcon img= new ImageIcon(".//map//0.png");
- path = img.getImage();
- img= new ImageIcon(".//map//1.png");
- wall1 = img.getImage();
- img= new ImageIcon(".//map//2.png");
- wall2 = img.getImage();
- map = new String[17][13];
- openFile();
- readFile();
- closeFile();
- }
- public Image getPath(){
- return path;
- }
- public Image getWall1(){
- return wall1;
- }
- public Image getWall2(){
- return wall2;
- }
- public String getMap(int x,int y) {
- return map[x][y];
- }
- public void openFile() {
- try {
- br=new BufferedReader(new FileReader("./map/map.txt"));
- }
- catch(Exception e) {
- System.out.println("Error Loading File!!!!");
- e.printStackTrace();
- }
- }
- public void readFile() {
- String line;
- int index = 0;
- try {
- while((line = br.readLine() ) != null){
- String neco[] = line.split("-");
- for(int i=0; i<17; i++){
- map[i][index]=neco[i];
- }
- index++;
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- public void closeFile() {
- try {
- br.close();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement