Example #1
0
  @Override
  public void init(GameContainer gc) throws SlickException {

    // Load the resources
    ResourceManager manager = ResourceManager.getInstance();
    manager.addResourceLoader(ImageLoader.getInstance());
    manager.addResourceLoader(ColorLoader.getInstance());
    manager.fromXML("wizardgame.xml");

    CitySetting setting = new CitySetting();
    setting.setWidth(10000);
    setting.setHeight(10000);

    world = new TileWorld("TileWorld", gc, setting);

    Camera camera = world.getCamera();

    camera.addComponent(new WorldBoundComponent(world));
    camera.addComponent(new CameraMovementComponent());

    cursorTorch = new Torch(0, 0, world);
    world.addWorldEntity(cursorTorch);

    // Add some houses
    for (int i = 0; i < 300; i++) {
      House house = new House(world);
      house.setGlobalPosition(
          (float) (Math.random() * world.getWidth()), (float) (Math.random() * world.getHeight()));
      world.addWorldEntity(house);
      Light light =
          new Light(
              (int) (Math.random() * world.getWidth()),
              (int) (Math.random() * world.getHeight()),
              650,
              new Color(50, 120, 255),
              world);
      world.addWorldEntity(light);
    }
  }