Skip to content
Permalink
1f157298c4
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
55 lines (46 sloc) 1.13 KB
package level;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;
import entities.Entity;
import level.tiles.Tile;
// Creates and manages the level when the game is running.
public class LevelHandler {
private Tile[][] tiles;
private List<Entity> entities;
private int width;
private int height;
private String levelName;
private String levelPath;
public LevelHandler(String levelPath) {
if (levelPath != null) {
this.levelPath = levelPath;
this.loadLevelFromFile();
}
}
// TODO: Change this to use and XML file instead of a text file
private void loadLevelFromFile() {
try {
FileReader fileReader = new FileReader(levelPath);
BufferedReader bufferedReader = new BufferedReader(fileReader);
levelName = bufferedReader.readLine();
bufferedReader.close();
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
public void tick() {
for (Tile[] tileArray : tiles) {
for (Tile t : tileArray) {
t.tick();
}
}
for (Entity e : entities) {
e.tick();
}
}
public String getLevelName() {
return levelName;
}
}