Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mazegui;
- import java.awt.Image;
- import java.util.Scanner;
- import java.io.*;
- import javax.swing.ImageIcon;
- public class Map {
- private Scanner m;
- private String Map[] = new String[14];
- private Image grass,
- wall;
- public Map () {
- ImageIcon img = new ImageIcon("/Users/nikolaj_fl/Desktop/Builder/grass.png");
- grass = img.getImage();
- img = new ImageIcon("/Users/nikolaj_fl/Desktop/Builder/wall.png");
- wall = img.getImage();
- openFile();
- readFile();
- closeFile();
- }
- public Image getGrass(){
- return grass;
- }
- public Image getWall(){
- return wall;
- }
- public String getMap (int x, int y){
- String index = Map[y].substring(x, x + 1);
- return index;
- }
- public void openFile(){
- try {
- m = new Scanner(new File("/Users/nikolaj_fl/Desktop/Builder/map.txt"));
- }catch(Exception e){
- System.out.println("error loading map");
- }
- }
- public void readFile(){
- while(m.hasNext()){
- for(int i = 0; i < 14; i++){
- Map[i] = m.next();
- }
- }
- }
- public void closeFile(){
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement