Permanent
Creation

RPGツクールXP/VX用のRGSS素材です。
一部英語版対応です。 (A few materials can be used for English RPG MAKER XP/VX.)
競合率はルファーの独断と偏見なのでたまにハズレます。


#==============================================================================
# ■ 矩形加減算ライブラリ
#------------------------------------------------------------------------------
#  Rect + Rect で、それぞれの座標の和とサイズの和を計算できるようにします。
# (C) ルファー
# WebSite  https://tkoolerlufar.pages.dev/
#==============================================================================

=begin
  =対応RGSS
  1 2 3

  =他の素材との競合の可能性
  !.. ほとんどありません

  =RPGツクールXPでの導入方法
  最上部に新セクションを作成して、このプログラムをそこにコピーする

  =更新履歴
  2013/03/26 リセットすると処理が重くなるバグを修正
  2012/04/05 公開

  =新規定義しているメソッド
  Rect#+ (エイリアスなし)
  Rect#- (エイリアスなし)
=end

class Rect
  #--------------------------------------------------------------------------
  # ○ 加算
  #--------------------------------------------------------------------------
  def +(other)
    unless other.is_a?(self.class)
      raise TypeError,
        "#{other.class} can't be coerced into #{self.class}", caller
    end
    self.class.new(
      self.x      + other.x,
      self.y      + other.y,
      self.width  + other.width,
      self.height + other.height)
  end
  #--------------------------------------------------------------------------
  # ○ 減算
  #--------------------------------------------------------------------------
  def -(other)
    unless other.is_a?(self.class)
      raise TypeError,
        "#{other.class} can't be coerced into #{self.class}", caller
    end
    self.class.new(
      self.x      - other.x,
      self.y      - other.y,
      self.width  - other.width,
      self.height - other.height)
  end
end

戻る