EOS 2  1.1.0
Einfache Objektbasierte Sprache
LabyrinthBauen.java
gehe zur Dokumentation dieser Datei
1 package examples;
2 
3 import java.io.FileOutputStream;
4 
5 import de.lathanda.eos.base.MutableColor;
6 import de.lathanda.eos.base.util.Direction;
7 import de.lathanda.eos.game.tools.Labyrinth;
8 import de.lathanda.eos.robot.World;
9 import de.lathanda.eos.robot.exceptions.RobotException;
10 
11 
12 public class LabyrinthBauen {
13  private static final int WIDTH = 20;
14  private static final int HEIGHT = 20;
15  private static final int SEED = 42;
16  private static final MutableColor WALL = MutableColor.DARK_GRAY;
17  private static final String FILENAME = "labyrinth.eow";
18  public static void main(String[] args) {
19  Labyrinth laby = new Labyrinth(2*WIDTH+1, 2*HEIGHT+1);
20  World world = new World();
21  world.toggleEntrance(0, 0, 0, Direction.EAST);
22  world.toggleEntrance(1, 1, 0, Direction.NORTH);
23  laby.createLabyrinth(SEED);
24  try {
25  for(int x = 0; x < 2*WIDTH+1; x++) {
26  for(int y = 0; y < 2*HEIGHT+1; y++) {
27  if (laby.getCell(x, y) == Labyrinth.WALL) {
28  world.setStoneColor(WALL);
29  world.setRock(x, y, 0);
30  world.setRock(x, y, 1);
31  world.setRock(x, y, 2);
32  }
33  }
34  }
35  world.setMark(2*WIDTH-1, 2*HEIGHT-1, MutableColor.YELLOW);
36  } catch (RobotException e) {
37  }
38  try (FileOutputStream file = new FileOutputStream(FILENAME)){
39  world.save(file);
40  } catch (Exception e) {
41  System.out.println("Speichern gescheitert wegen "+e.getMessage());
42  }
43  }
44 }
static final MutableColor YELLOW
static final MutableColor DARK_GRAY
Klasse für Zufallslabyrinthe.
Definition: Labyrinth.java:24
void setStoneColor(MutableColor c)
Definition: World.java:606
void setMark(int x, int y, MutableColor c)
Definition: World.java:599
void save(OutputStream targetStream)
Definition: World.java:335
void setRock(int x, int y, int z)
Definition: World.java:588
void toggleEntrance(int x, int y, int z, Direction d)
Definition: World.java:526
static void main(String[] args)
Impressum