예제 #1
0
  /**
   * Takes the map data are returns a Texture that can be drawn from a sprite.
   *
   * @param width How wide in pixels you want the returned Texture to be.
   * @param height How high in pixels you want the returned Texture to be.
   * @return a Texture that is width x height big that can then be drawn to the screen
   * @throws TextureCreationException
   */
  ConstTexture drawMap() {
    int currentSlot = 0;
    screen.clear();
    for (int x = 0; x < XSize; x++) {
      for (int y = 0; y < YSize; y++) {
        currentTile.setPosition(x * 16, y * 16);
        currentTile.setTexture(textures.tiles.get(textureMap.get(currentSlot)));
        screen.draw(currentTile);
        currentSlot++;
      }
    }
    screen.display();

    return screen.getTexture();
  }
예제 #2
0
  /**
   * Constructs an empty map, using texts as textures for the map. Use Map.loadMap or loadMapFile to
   * set map data.
   *
   * @param texts A TextureArray that the map will use for textures.
   */
  public Map(TextureArray texts) {
    textures = texts;

    try {
      screen.create(DSZ.tileWidth * 16, DSZ.tileHeight * 16);
    } catch (TextureCreationException e) {
      e.printStackTrace();
    }
  }