-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorldLoad.java
More file actions
39 lines (34 loc) · 1.04 KB
/
WorldLoad.java
File metadata and controls
39 lines (34 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import processing.core.PImage;
import java.util.Map;
import java.util.Scanner;
public final class WorldLoad
{
private static final int PROPERTY_KEY = 0;
private static final String BGND_KEY = "background";
private static final int BGND_NUM_PROPERTIES = 4;
private static final int BGND_NAME = 1;
private static final int BGND_COL = 2;
private static final int BGND_ROW = 3;
private WorldLoad() {}
public static void load(Scanner in, WorldModel world,
ImageStore imageStore, Map<String, PropertyParser> parsers)
{
while (in.hasNextLine())
{
processLine(in.nextLine(), world, imageStore, parsers);
}
}
private static void processLine(String line, WorldModel world,
ImageStore imageStore, Map<String, PropertyParser> parsers)
{
String[] properties = line.split("\\s");
if (properties.length > 0)
{
PropertyParser parser = parsers.get(properties[PROPERTY_KEY]);
if (parser != null)
{
parser.parse(properties);
}
}
}
}