Exemple #1
0
/**
 * \brief Draws the entity on the map.
 *
 * This is a redefinition of MapEntity::draw_on_map() to also draw the twinkling star
 * which has a special position.
 */
void Crystal::draw_on_map() {

  if (!is_drawn()) {
    return;
  }

  // draw the crystal
  MapEntity::draw_on_map();

  // draw the star
  if (is_drawn()) {
    get_map().draw_sprite(*star_sprite, get_top_left_x() + star_xy.get_x(), get_top_left_y() + star_xy.get_y());
  }
}
Exemple #2
0
/**
 * @brief Draws the entity on the map.
 */
void Hookshot::draw_on_map() {

  static const int nb_links = 7;
  static const Rectangle dxy[] = {
    Rectangle(16, -5),
    Rectangle(0, -13),
    Rectangle(-16, -5),
    Rectangle(0, 7)
  };

  if (!is_drawn()) {
    return;
  }

  MapEntity::draw_on_map();

  // also draw the links
  int direction = get_sprite().get_current_direction();
  int x1 = get_hero().get_x() + dxy[direction].get_x();
  int y1 = get_hero().get_y() + dxy[direction].get_y();
  int x2 = get_x();
  int y2 = get_y() - 5;

  Rectangle link_xy;
  for (int i = 0; i < nb_links; i++) {
    link_xy.set_x(x1 + (x2 - x1) * i / nb_links);
    link_xy.set_y(y1 + (y2 - y1) * i / nb_links);
    get_map().draw_sprite(link_sprite, link_xy);
  }
}
/**
 * \brief Draws the entity on the map.
 */
void ShopTreasure::draw_on_map() {

  if (!is_drawn()) {
    return;
  }

  const SurfacePtr& map_surface = get_map().get_visible_surface();
  int x = get_x();
  int y = get_y();

  // draw the treasure
  const Rectangle& camera_position = get_map().get_camera_position();
  treasure.draw(map_surface,
      x + 16 - camera_position.get_x(),
      y + 13 - camera_position.get_y()
  );

  // also draw the price
  price_digits.draw(map_surface,
      x + 12 - camera_position.get_x(),
      y + 21 - camera_position.get_y());
  rupee_icon_sprite->draw(map_surface,
      x - camera_position.get_x(),
      y + 22 - camera_position.get_y());
}
Exemple #4
0
/**
 * \brief Draws the entity on the map.
 */
void Hookshot::draw_on_map() {

  static constexpr int nb_links = 7;
  static constexpr Point dxy[] = {
    {  16,  -5 },
    {   0, -13 },
    { -16,  -5 },
    {   0,   7 }
  };

  if (!is_drawn()) {
    return;
  }

  MapEntity::draw_on_map();

  // also draw the links
  int direction = get_sprite().get_current_direction();
  int x1 = get_hero().get_x() + dxy[direction].x;
  int y1 = get_hero().get_y() + dxy[direction].y;
  int x2 = get_x();
  int y2 = get_y() - 5;

  Point link_xy;
  for (int i = 0; i < nb_links; i++) {
    link_xy.x = x1 + (x2 - x1) * i / nb_links;
    link_xy.y = y1 + (y2 - y1) * i / nb_links;
    get_map().draw_sprite(*link_sprite, link_xy);
  }
}
Exemple #5
0
/**
 * \brief Draws the entity on the map.
 */
void Enemy::draw_on_map() {

  if (!is_drawn()) {
    return;
  }

  get_lua_context().enemy_on_pre_draw(*this);
  Detector::draw_on_map();
  get_lua_context().enemy_on_post_draw(*this);
}
Exemple #6
0
/**
 * @brief Draws the entity on the map.
 */
void Door::draw_on_map() {

  if (!is_drawn()) {
    return;
  }

  if (has_sprite() && !is_open()) {
    Detector::draw_on_map();
  }
}
Exemple #7
0
/**
 * \brief Draws the tile on the map.
 */
void Tile::draw_on_map() {

  if (!is_drawn()) {
    return;
  }

  // Note that the tiles are also optimized for drawing.
  // This function is called at each frame only if the tile is in an
  // animated region. Otherwise, tiles are drawn once when loading the map.
  draw(get_map().get_visible_surface(), get_map().get_camera_position());
}
Exemple #8
0
/**
 * \brief Draws the pickable item on the map.
 *
 * This is a redefinition of MapEntity::draw_on_map
 * to draw the shadow independently of the item movement.
 */
void Pickable::draw_on_map() {

  if (!is_drawn()) {
    return;
  }

  // draw the shadow
  if (shadow_sprite != nullptr) {
    get_map().draw_sprite(*shadow_sprite, shadow_xy);
  }

  // draw the sprite
  Detector::draw_on_map();
}
Exemple #9
0
/**
 * \brief Draws the pickable item on the map.
 *
 * This is a redefinition of MapEntity::draw_on_map
 * to draw the shadow independently of the item movement.
 */
void Pickable::draw_on_map() {

    if (!is_drawn()) {
        return;
    }

    // draw the shadow
    if (shadow_sprite != NULL) {
        get_map().draw_sprite(*shadow_sprite, shadow_xy.get_x(), shadow_xy.get_y());
    }

    // draw the sprite
    MapEntity::draw_on_map();
}
Exemple #10
0
/**
 * \brief Draws the tile on the map.
 */
void DynamicTile::draw_on_map() {

  if (!is_drawn()) {
    return;
  }

  const Rectangle& camera_position = get_map().get_camera_position();
  Rectangle dst(0, 0);

  Rectangle dst_position(get_top_left_x() - camera_position.get_x(),
      get_top_left_y() - camera_position.get_y(),
      get_width(), get_height());

  tile_pattern.fill_surface(get_map().get_visible_surface(), dst_position,
      get_map().get_tileset(), camera_position);
}
Exemple #11
0
/**
 * \brief Draws the carried item on the map.
 *
 * This is a redefinition of Entity::draw_on_map()
 * to draw the shadow independently of the item movement.
 */
void CarriedItem::draw_on_map() {

  if (!is_drawn()) {
    return;
  }

  if (!is_throwing) {
    // draw the sprite normally
    Entity::draw_on_map();
  }
  else {
    // when the item is being thrown, draw the shadow and the item separately
    // TODO: this could probably be simplified by using a JumpMovement
    get_map().draw_sprite(*shadow_sprite, get_xy());
    get_map().draw_sprite(get_sprite(), get_x(), get_y() - item_height);
  }
}
Exemple #12
0
/**
 * \brief Draws the entity on the map.
 *
 * This is a redefinition of MapEntity::draw_on_map to repeat the block pattern.
 */
void CrystalBlock::draw_on_map() {

  if (!is_drawn()) {
    return;
  }

  Sprite& sprite = get_sprite();

  int x1 = get_top_left_x();
  int y1 = get_top_left_y();
  int x2 = x1 + get_width();
  int y2 = y1 + get_height();

  for (int y = y1; y < y2; y += 16) {
    for (int x = x1; x < x2; x += 16) {
      get_map().draw_sprite(sprite, x, y);
    }
  }
}