Javadoc, small bugfix in levels.xml
[AntiTD.git] / src / se / umu / cs / dit06ajnajs / AntiTD.java
blob4b71d77f6984aa3a6cf04496072cea65fbcef84a
1 package se.umu.cs.dit06ajnajs;
3 import java.io.File;
4 import java.io.IOException;
5 import java.net.URL;
6 import java.util.List;
7 import java.util.logging.Logger;
8 import org.jdom.JDOMException;
10 import se.umu.cs.dit06ajnajs.level.Level;
11 import se.umu.cs.dit06ajnajs.util.LevelsXMLParser;
13 /**
14 * AntiTD loads either the default levels.xml file or a specified file
15 * containing XML-information describing the levels to play. XML-information is
16 * parsed and a List containing the resulted Levels are feeded to a newly
17 * created ATDController.
19 * @author Anton Johansson, dit06ajn@cs.umu.se
20 * @version 1.0
22 public class AntiTD {
23 // The square size to use in the game, should be the same size as the images
24 // used for MapSquares.
25 public static final int SQUARE_SIZE = 45;
27 // An URL pointing to the default levels.xml file.
28 private static final URL DEFAULT_LEVELS_XML
29 = AntiTD.class.getResource("/resources/levels.xml");
31 /**
32 * Starts the game, parses and validates an XML-file containing Level
33 * information. Creates a new ATDController.
35 * @param args if an argument is given this is used as a reference to an
36 * XML-file which should contain Level information. If no argument is given
37 * a default XML-file is used.
39 public static void main(String[] args) {
40 Logger.getLogger("AntiTD").setLevel(java.util.logging.Level.OFF);
42 try {
43 List<Level> levels;
45 if (args.length == 1) {
46 levels = LevelsXMLParser.parse(new File(args[0]));
47 } else {
48 levels = LevelsXMLParser.parse(DEFAULT_LEVELS_XML);
50 new ATDController(levels);
51 } catch (IOException e) {
52 System.err.println("Couldn't find specified file, argument should "
53 + "point to an XML-file containing level information");
54 System.exit(-1);
55 } catch (JDOMException e) {
56 System.err.println("Error parsing XML-file containing level information: ");
57 System.err.println(e.getMessage());
58 System.exit(-1);