VX 스크립트

#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/    ◆ 범용 게이지 묘화 - KGC_GenericGauge ◆ VX ◆
#_/    ◇ Last update : 2009/08/18 ◇
#_/----------------------------------------------------------------------------
#_/  범용적인 게이지 묘화 기능을 제공합니다.
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

#==============================================================================
# ★ 커스터마이즈 항목 - Customize BEGIN ★
#==============================================================================

module KGC
module GenericGauge
  # ◆ 게이지 화상
  #  "Graphics/System" 로부터 읽어들인다.
  HP_IMAGE  = "GaugeHP"   # HP
  MP_IMAGE  = "GaugeMP"   # MP
  EXP_IMAGE = "GaugeEXP"  # EXP

  # ◆ 게이지 위치 보정 [x, y]
  HP_OFFSET  = [-23, -2]  # HP
  MP_OFFSET  = [-23, -2]  # MP
  EXP_OFFSET = [-23, -2]  # EXP

  # ◆ 게이지장 보정
  HP_LENGTH  = -4  # HP
  MP_LENGTH  = -4  # MP
  EXP_LENGTH = -4  # EXP

  # ◆ 게이지의 기울기 각도
  #  -89  89 로 지정.
  HP_SLOPE  = 30  # HP
  MP_SLOPE  = 30  # MP
  EXP_SLOPE = 30  # EXP
end
end

#==============================================================================
# ☆ 커스터마이즈 항목 종료 - Customize END ☆
#==============================================================================

$imported = {} if $imported == nil
$imported["GenericGauge"] = true

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Bitmap
#==============================================================================

unless $imported["BitmapExtension"]
class Bitmap
  #--------------------------------------------------------------------------
  # ○평행 사변형 전송
  #--------------------------------------------------------------------------
  def skew_blt(x, y, src_bitmap, src_rect, slope, opacity = 255)
    slope = [[slope, -90].max, 90].min
    sh    = src_rect.height
    off  = sh / Math.tan(Math::PI * (90 - slope.abs) / 180.0)
    if slope >= 0
      dx   = x + off.to_i
      diff = -off / sh
    else
      dx   = x
      diff = off / sh
    end
    rect = Rect.new(src_rect.x, src_rect.y, src_rect.width, 1)

    sh.times { |i|
      blt(dx + (diff * i).round, y + i, src_bitmap, rect, opacity)
      rect.y += 1
    }
  end
end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # 0차의 레벨의 경험치 취득
  #--------------------------------------------------------------------------
  def next_exp
    return @exp_list[@level+1]
  end
  #--------------------------------------------------------------------------
  # 0차의 레벨의 차분 경험치 취득
  #--------------------------------------------------------------------------
  def next_diff_exp
    return (@exp_list[@level+1] - @exp_list[@level])
  end
  #--------------------------------------------------------------------------
  # 0차의 레벨까지의 경험치 취득
  #--------------------------------------------------------------------------
  def next_rest_exp
    return (@exp_list[@level+1] - @exp)
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Window_Base
#==============================================================================

class Window_Base < Window
  @@__gauge_buf = Bitmap.new(320, 24)
  #--------------------------------------------------------------------------
  # ○게이지 묘화
  #     file       : 게이지 화상 파일명
  #     x          : 묘화처 X 좌표
  #     y          : 묘화처 Y 좌표
  #     width      : 폭
  #     value      : 현재가
  #     limit      : 상한치
  #     offset     : 좌표 조정 [x, y]
  #     len_offset : 길이 조정
  #     slope      : 기울기
  #--------------------------------------------------------------------------
  def draw_gauge(file, x, y, width, value, limit, offset, len_offset, slope)
    img    = Cache.system(file)
    x     += offset[0]
    y     += offset[1]
    width += len_offset
    draw_gauge_base(img, x, y, width, slope)
    gw = width * value / limit
    draw_gauge_bar(img, x, y, width, gw, slope)
  end
  #--------------------------------------------------------------------------
  # ○게이지 베이스 묘화
  #     img   : 게이지 화상
  #     x     : 묘화처 X 좌표
  #     y     : 묘화처 Y 좌표
  #     width : 폭
  #     slope : 기울기
  #--------------------------------------------------------------------------
  def draw_gauge_base(img, x, y, width, slope)
    rect = Rect.new(0, 0, 24, 24)
    if slope != 0
      self.contents.skew_blt(x, y, img, rect, slope)
      rect.x = 96
      self.contents.skew_blt(x + width + 24, y, img, rect, slope)

      rect.x     = 24
      rect.width = 72
      dest_rect = Rect.new(0, 0, width, 24)
      @@__gauge_buf.clear
      @@__gauge_buf.stretch_blt(dest_rect, img, rect)
      self.contents.skew_blt(x + 24, y, @@__gauge_buf, dest_rect, slope)
    else
      self.contents.blt(x, y, img, rect)
      rect.x = 96
      self.contents.blt(x + width + 24, y, img, rect)
      rect.x     = 24
      rect.width = 72
      dest_rect = Rect.new(x + 24, y, width, 24)
      self.contents.stretch_blt(dest_rect, img, rect)
    end
  end
  #--------------------------------------------------------------------------
  # ○게이지 내부 묘화
  #     img   : 게이지 화상
  #     x     : 묘화처 X 좌표
  #     y     : 묘화처 Y 좌표
  #     width : 전체폭
  #     gw    : 내부폭
  #     slope : 기울기
  #--------------------------------------------------------------------------
  def draw_gauge_bar(img, x, y, width, gw, slope)
    rect = Rect.new(0, 24, 72, 24)
    dest_rect = Rect.new(0, 0, width, 24)
    @@__gauge_buf.clear
    @@__gauge_buf.stretch_blt(dest_rect, img, rect)
    dest_rect.width = gw
    if slope != 0
      self.contents.skew_blt(x + 24, y, @@__gauge_buf, dest_rect, slope)
    else
      self.contents.blt(x + 24, y, @@__gauge_buf, dest_rect)
    end
  end
  #--------------------------------------------------------------------------
  # ● HP 게이지의 묘화
  #     actor : 액터
  #     x     : 묘화처 X 좌표
  #     y     : 묘화처 Y 좌표
  #     width : 폭
  #--------------------------------------------------------------------------
  def draw_actor_hp_gauge(actor, x, y, width = 120)
    draw_gauge(KGC::GenericGauge::HP_IMAGE,
      x, y, width, actor.hp, actor.maxhp,
      KGC::GenericGauge::HP_OFFSET,
      KGC::GenericGauge::HP_LENGTH,
      KGC::GenericGauge::HP_SLOPE)
  end
  #--------------------------------------------------------------------------
  # ● MP 게이지의 묘화
  #     actor : 액터
  #     x     : 묘화처 X 좌표
  #     y     : 묘화처 Y 좌표
  #     width : 폭
  #--------------------------------------------------------------------------
  def draw_actor_mp_gauge(actor, x, y, width = 120)
    draw_gauge(KGC::GenericGauge::MP_IMAGE,
      x, y, width, actor.mp, [actor.maxmp, 1].max,
      KGC::GenericGauge::MP_OFFSET,
      KGC::GenericGauge::MP_LENGTH,
      KGC::GenericGauge::MP_SLOPE)
  end
  #--------------------------------------------------------------------------
  # ○ Exp 의 묘화
  #     actor : 액터
  #     x     : 묘화처 X 좌표
  #     y     : 묘화처 Y 좌표
  #     width : 폭
  #--------------------------------------------------------------------------
  def draw_actor_exp(actor, x, y, width = 180)
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, width, WLH, actor.exp_s, 2)
  end
#--------------------------------------------------------------------------
  # ○ NextExp 의 묘화
  #     actor : 액터
  #     x     : 묘화처 X 좌표
  #     y     : 묘화처 Y 좌표
  #     width : 폭
  #--------------------------------------------------------------------------
  def draw_actor_next_exp(actor, x, y, width = 180)
    draw_actor_exp_gauge(actor, x, y, width)

    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, width, WLH, actor.next_rest_exp_s, 2)
  end
  #--------------------------------------------------------------------------
  # ○ Exp 게이지의 묘화
  #     actor : 액터
  #     x     : 묘화처 X 좌표
  #     y     : 묘화처 Y 좌표
  #     width : 폭
  #--------------------------------------------------------------------------
  def draw_actor_exp_gauge(actor, x, y, width = 180)
    diff = [actor.next_diff_exp, 1].max
    rest = [actor.next_rest_exp, 1].max
    draw_gauge(KGC::GenericGauge::EXP_IMAGE,
      x, y, width, diff - rest, diff,
      KGC::GenericGauge::EXP_OFFSET,
      KGC::GenericGauge::EXP_LENGTH,
      KGC::GenericGauge::EXP_SLOPE)
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Window_Status
#==============================================================================

class Window_Status < Window_Base
  #--------------------------------------------------------------------------
  # ● 경험치 정보의 묘화
  #     x : 묘화처 X 좌표
  #     y : 묘화처 Y 좌표
  #--------------------------------------------------------------------------
  def draw_exp_info(x, y)
    s_next = sprintf(Vocab::ExpNext, Vocab::level)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y + WLH * 0, 180, WLH, Vocab::ExpTotal)
    self.contents.draw_text(x, y + WLH * 2, 180, WLH, s_next)
    draw_actor_exp(@actor, x, y + WLH * 1)
    draw_actor_next_exp(@actor, x, y + WLH * 3)
  end
end

 

 

-------------------------사용법------------------------------------------------------------------------------------------------------------------

# ◆ 게이지 화상
#  "Graphics/System" 로부터 읽어들인다.
HP_IMAGE  = "GaugeHP"   # HP
MP_IMAGE  = "GaugeMP"   # MP
EXP_IMAGE = "GaugeEXP"  # EXP
각 게이지 화상의 파일명을 지정합니다.
화상은 "Graphics/System" 에 보존해 주세요.

--------------------------------------------------------------------------------

# ◆ 게이지 위치 보정 [x, y]
HP_OFFSET  = [-23, -2]  # HP
MP_OFFSET  = [-23, -2]  # MP
EXP_OFFSET = [-23, -2]  # EXP
게이지의 묘화 위치를 어느 정도 늦추는지를 지정합니다.
게이지 화상을 변경했을 때는, 이쪽을 조정해 주세요.

--------------------------------------------------------------------------------

# ◆ 게이지장 보정
HP_LENGTH  = -4  # HP
MP_LENGTH  = -4  # MP
EXP_LENGTH = -4  # EXP
게이지의 길이를 어느 정도 늘리는지를 지정합니다.
게이지 화상을 변경했을 때는, 이쪽을 조정해 주세요.

--------------------------------------------------------------------------------

# ◆ 게이지의 기울기 각도
HP_SLOPE  = 30  # HP
MP_SLOPE  = 30  # MP
EXP_SLOPE = 30  # EXP
게이지 화상의 기울기 각도를 89  -89의 범위에서 지정합니다.
각도는 윗방향을 0으로서 우측이 플러스, 좌측이 마이너스가 됩니다.
플러스의 경우는 게이지 하단, 마이너스의 경우는 게이지 상단이 묘화시의 기준 위치가 됩니다.

HPGaugeHP.png

MPGaugeMP.png

EXPGaugeEXP.png

   generic_gauge01.jpg

TAG •

Who's 카르와푸딩의아틀리에

profile

엘카르디아 제작자 (현재 MV로 리메이크중)

유튜브

https://www.youtube.com/channel/UCMwirNTR-pOEzJNB0jL3y_g

트위터

https://twitter.com/karsis98

블로그

https://blog.naver.com/karsis98

Comment '14'

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 3 습작 2012.12.24 5398
50 기타 디스크 체인져 VX!! (업데이트..) 30 file Tofuman 2008.12.02 3168
49 기타 [자작]게임 실행시 파일 체크 프로그램. 또는 파일 실행기. 16 file NightWind AYARSB 2010.05.20 3193
48 기타 <중수이상>RPG VX의 대표적 참조값 6 까까까 2009.05.31 3236
47 기타 [kcg] 슬립 데미지 상세화 19 BoneheadedAlien 2009.02.22 3242
46 기타 라이트 이펙트 스크립트 12 file 아방스 2009.02.07 3262
45 기타 KGC파라미터배분 2 (VX전용) 20 file 카르와푸딩의아틀리에 2009.07.21 3269
44 기타 높이(층)를 설정하는 스크립트 11 file 카르와푸딩의아틀리에 2009.07.01 3343
» 기타 범용 게이지 묘화 - KGC 14 file 카르와푸딩의아틀리에 2009.08.19 3476
42 기타 Staff Roll 13 file 허걱 2009.01.31 3523
41 기타 경험치, HP, MP 백분율계산 (실시간) 8 file 허걱 2009.08.01 3540
40 기타 KGC패시브 스크립트 30 카르와푸딩의아틀리에 2009.10.07 3551
39 기타 데이터베이스 자체 제한 해체 스크립트 [Database Limit Breaker] 13 file 할렘 2009.02.07 3562
38 기타 말풍선 그림 바꾸기 6 file 허걱 2009.08.15 3565
37 기타 [KGC]한계돌파 9 방콕족의생활 2008.06.13 3599
36 기타 Crissaegrim 농장시스템 한글화 28 file 도심 2009.12.22 3606
35 기타 멥 이름 띄우기 10 신규회원 2012.02.24 3626
34 기타 낚시 스크립트~(낚시대로 하는 낚시가 아니라 사람을 낚는 낚시 스크립트) 14 file ~AYARSB~ 2010.03.18 3630
33 기타 화폐단위 구분해 주는 스크립트 38 file 허걱 2010.04.13 3652
32 기타 미니게임테트리스 스크립트 ㅋㅋㅋ 27 file 카르와푸딩의아틀리에 2009.06.30 3689
31 기타 레벨업 이펙트... 20 비극ㆍ 2010.04.19 3768
Board Pagination Prev 1 2 3 4 5 6 7 Next
/ 7