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 기타 배틀신에서 곡 넘기기 2 rukan 2009.07.02 1757
» 기타 범용 게이지 묘화 - KGC 14 file 카르와푸딩의아틀리에 2009.08.19 3476
48 기타 블랙잭, 룰렛, 포커 스크립트 종합 9 file 도심 2010.08.22 2643
47 기타 블록 미니게임 11 file 사람이라면? 2010.08.15 2269
46 기타 빛 이펙트 71 file DEVIL<Li Patanis Roni Kraudus> 2008.06.06 5861
45 기타 사이드뷰배틀에서 찌르기 공격 가능하게(Upgrade!) 6 078656577er 2009.10.15 2838
44 기타 설명하기 힘든 스크립트 (스크린샷 확인) 10 file 사람이라면? 2010.08.16 3818
43 기타 세이브 포인트 2 비극ㆍ 2010.04.19 2518
42 기타 스크린샷 기능 14 비극ㆍ 2010.04.19 2090
41 기타 스크립트강좌 4 아하!잘봤어요. 2009.05.04 2158
40 기타 스크립트로 커먼 이벤트 실행 [수정] 3 허걱 2009.08.17 2311
39 기타 시야범위 스크립트 18 file 좀비사냥꾼 2009.03.19 4047
38 기타 시야범위 스크립트 22 file 카르와푸딩의아틀리에 2009.06.30 4025
37 기타 심플 마우스 시스템 1.5 애드온 11 file RMdude 2009.02.11 4325
36 기타 아이디를 띄우기 20 12345678 2011.11.07 4626
35 기타 아이콘 캐릭터 17 file 허걱 2010.02.28 4225
34 기타 아키루냥님 요청 스크립트(자작) 4 file Last H 2009.02.22 2754
33 기타 앞에있는 이벤트 아이디 찾기 6 허걱 2009.08.21 2091
32 기타 액터선택지제작 간편화 스크립트 7 Evangelista 2009.02.26 4082
31 기타 여러스크립트(목적은 포인트) 12 file 인생은 힘들다. 2011.08.26 3087
Board Pagination Prev 1 2 3 4 5 6 7 Next
/ 7