Package games.stendhal.client.sprite

Examples of games.stendhal.client.sprite.SpriteStore


   * @param map
   *            The map to populate.
   */
  @Override
  protected void buildSprites(IEntity entity, final Map<Object, Sprite> map) {
    final SpriteStore store = SpriteStore.get();
    final Sprite tiles = store.getSprite(translate(entity.getType()));

    map.put(STATE_CLOSED, store.getTile(tiles, 0, 0,
        IGameScreen.SIZE_UNIT_PIXELS, IGameScreen.SIZE_UNIT_PIXELS));
    map.put(STATE_OPEN, store.getTile(tiles, 0,
        IGameScreen.SIZE_UNIT_PIXELS, IGameScreen.SIZE_UNIT_PIXELS,
        IGameScreen.SIZE_UNIT_PIXELS));
  }
View Full Code Here


   * @param map
   *            The map to populate.
   */
  @Override
  protected void buildSprites(IEntity entity, final Map<Object, Sprite> map) {
    final SpriteStore store = SpriteStore.get();
    final Sprite tiles = store.getSprite(translate(entity.getType()));

    final int theight = tiles.getHeight();
    int i = 0;

    for (int y = 0; y < theight; y += IGameScreen.SIZE_UNIT_PIXELS) {
      map.put(Integer.valueOf(i++), store.getTile(tiles, 0, y,
          IGameScreen.SIZE_UNIT_PIXELS,
          IGameScreen.SIZE_UNIT_PIXELS));
    }
  }
View Full Code Here

    size = new Dimension(TILE_SIZE, height);
    setPreferredSize(size);
    setMinimumSize(size);
    setMaximumSize(size);

    final SpriteStore store = SpriteStore.get();

    for (int i = 0; i < frames; i++) {
      sprite[i] = store.getTile(baseSprite, i * TILE_SIZE, yOffset, TILE_SIZE, height);
    }
  }
View Full Code Here

   * Create a new karma indicator.
   */
  public KarmaIndicator() {
    instance = this;
    setVisible(false);
    final SpriteStore store = SpriteStore.get();
    image = store.getSprite(IMAGE_FILE_NAME);
   
    // We don't draw the background
    setOpaque(false);
  }
View Full Code Here

    if (clazz == null) {
      LOGGER.warn("No entity class set");
      clazz = "grain_field";
    }

    final SpriteStore store = SpriteStore.get();
    final Sprite tiles = store.getSprite(translate(clazz.replace(" ", "_")));

    states = ((GrainField) entity).getMaximumRipeness() + 1;

    final int tileSetHeight = tiles.getHeight();
    final int imageHeight = tileSetHeight / states;
    if (tileSetHeight % states != 0) {
      LOGGER.warn("Inconsistent image height in "
          + translate(clazz.replace(" ", "_")) + ": image height "
          + tileSetHeight + " with " + states + " states.");
    }

    int i = 0;
    for (int y = 0; y < tileSetHeight; y += imageHeight) {
      map.put(Integer.valueOf(i++), store.getTile(tiles, 0, y, width,
          imageHeight));
    }
   
    calculateOffset(entity, width, imageHeight);
  }
View Full Code Here

   *
   * @return A sprite.
   */
  protected Sprite createWalkSprite(final Sprite tiles, final int y,
      final int width, final int height) {
    final SpriteStore store = SpriteStore.get();

    final Sprite[] frames = new Sprite[4];

    int x = 0;
    frames[0] = store.getTile(tiles, x, y, width, height);

    x += width;
    frames[1] = store.getTile(tiles, x, y, width, height);

    x += width;
    frames[2] = store.getTile(tiles, x, y, width, height);

    frames[3] = frames[1];

    return new AnimatedSprite(frames, 100, false);
  }
View Full Code Here

   *
   * @return A tile sprite containing all animation images.
   */
  @Override
  protected Sprite getAnimationSprite() {
    final SpriteStore store = SpriteStore.get();

    try {
      final int code = ((RPEntity) entity).getOutfit();

      if (code != RPEntity.OUTFIT_UNSET) {
        return OutfitStore.get().getOutfit(code);
      } else {
        // This NPC's outfit is read from a single file.
        return store.getSprite(translate("npc/"
            + entity.getEntityClass()));
      }
    } catch (final Exception e) {
      logger.error("Cannot build animations", e);
      return store.getSprite(translate(entity.getEntityClass()));
    }
  }
View Full Code Here

   * @param map
   *            The map to populate.
   */
  @Override
  protected void buildSprites(IEntity entity, final Map<Object, Sprite> map) {
    final SpriteStore store = SpriteStore.get();
    final Sprite tiles = store.getSprite("data/sprites/combat/blood_red.png");

    final int theight = tiles.getHeight();
    int i = 0;

    for (int y = 0; y < theight; y += IGameScreen.SIZE_UNIT_PIXELS) {
      map.put(Integer.valueOf(i++), store.getTile(tiles, 0, y,
          IGameScreen.SIZE_UNIT_PIXELS,
          IGameScreen.SIZE_UNIT_PIXELS));
    }
  }
View Full Code Here

  // Entity2DView
  //

  @Override
  protected void buildRepresentation(IEntity entity) {
    final SpriteStore store = SpriteStore.get();
    Sprite sprite;
    if (entity.getType().equals("useable_entity")) {
      if (entity.getName() == null) {
        sprite = store.getSprite(translate("signs/transparent"));
      } else {
        sprite = store.getSprite(translate("useable/" + getClassResourcePath() + "/" + entity.getName()));
      }
    } else {
      // compatiblity with 0.86 server
      sprite = store.getSprite(translate("useable/source/" + entity.getType()));
    }

    /*
     * Entities are [currently] always 1x1. Extra columns are animation.
     * Extra rows are ignored.
     */
    final int imageWidth = sprite.getWidth();
    final int width = Math.max((int) entity.getWidth(), 1);
    final int height = Math.max((int) entity.getHeight(), 1);
    int frames = imageWidth / IGameScreen.SIZE_UNIT_PIXELS / width;
   
    // Just use the normal sprite if there are no animation frames
    int state = ((UseableEntity) entity).getState();
    if (frames > 1) {
      sprite = store.getAnimatedSprite(sprite,
          0, state * IGameScreen.SIZE_UNIT_PIXELS * height,
          imageWidth / IGameScreen.SIZE_UNIT_PIXELS / width,
          IGameScreen.SIZE_UNIT_PIXELS * width,
          IGameScreen.SIZE_UNIT_PIXELS * height,
          100);
    } else {
      sprite = store.getTile(sprite,
          0, state * IGameScreen.SIZE_UNIT_PIXELS * height,
          IGameScreen.SIZE_UNIT_PIXELS * width,
          IGameScreen.SIZE_UNIT_PIXELS * height);
    }

 
View Full Code Here

   * pixels).
   */
  @Override
  protected void buildSprites(final Map<Object, Sprite> map,
      final Sprite tiles, final int width, final int height) {
    final SpriteStore store = SpriteStore.get();

    final Sprite right = store.getTile(tiles, 0, 0, width, height);
    final Sprite left = store.getTile(tiles, 0, height, width, height);

    map.put(Direction.RIGHT, right);
    map.put(Direction.LEFT, left);
    map.put(Direction.UP, right);
    map.put(Direction.DOWN, left);
View Full Code Here

TOP

Related Classes of games.stendhal.client.sprite.SpriteStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.