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
70 기타 말풍선 그림 바꾸기 6 file 허걱 2009.08.15 3562
69 기타 거리계산 스크립트 (XP가능) 7 file 허걱 2009.08.16 2848
68 기타 확장 에러 메시지 13 file 허걱 2009.08.17 2497
67 기타 스크립트로 커먼 이벤트 실행 [수정] 3 허걱 2009.08.17 2311
» 기타 범용 게이지 묘화 - KGC 14 file 카르와푸딩의아틀리에 2009.08.19 3476
65 기타 앞에있는 이벤트 아이디 찾기 6 허걱 2009.08.21 2091
64 기타 클리어 횟수 기록하기 8 file 허걱 2009.08.22 2729
63 기타 커스텀 페이지 스크립트 9 file 달표범 2009.09.07 3140
62 기타 KGC패시브 스크립트 30 카르와푸딩의아틀리에 2009.10.07 3551
61 기타 사이드뷰배틀에서 찌르기 공격 가능하게(Upgrade!) 6 078656577er 2009.10.15 2838
60 기타 Crissaegrim 농장시스템 한글화 28 file 도심 2009.12.22 3606
59 기타 화면에 그림 그리는 스크립트 21 file 강진수 2010.02.27 2961
58 기타 아이콘 캐릭터 17 file 허걱 2010.02.28 4225
57 기타 카지노 슬롯머신 15 file 아방스가 짱 2010.02.28 3023
56 기타 (이거 정말 좋군요) 말이나 용을 탈수있게 하는 스크립트. 31 file 아방스가 짱 2010.02.28 4261
55 기타 통합 스크립트(좋은 마우스 스크립트 좋은거),KGC좋은거 새로운 거 스크립트 세이브 스크립트 좋은거!~~~~~ 14 알피지GM 2010.03.07 3829
54 기타 낚시 스크립트~(낚시대로 하는 낚시가 아니라 사람을 낚는 낚시 스크립트) 14 file ~AYARSB~ 2010.03.18 3630
53 기타 화폐단위 구분해 주는 스크립트 38 file 허걱 2010.04.13 3652
52 기타 땅파기 18 file 비극ㆍ 2010.04.19 3013
51 기타 스크린샷 기능 14 비극ㆍ 2010.04.19 2090
Board Pagination Prev 1 2 3 4 5 6 7 Next
/ 7