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
377 전투 커먼이벤트 컷인 스크립트 15 허걱 2009.08.23 3399
376 기타 클리어 횟수 기록하기 8 file 허걱 2009.08.22 2729
375 기타 앞에있는 이벤트 아이디 찾기 6 허걱 2009.08.21 2091
374 제작도구 Icon Preview Window by Woratana 8 file 허걱 2009.08.20 2890
373 HUD 아이콘 그리기 7 file 허걱 2009.08.20 4441
372 이동 및 탈것 Paper Mario Walk 7 file 카르와푸딩의아틀리에 2009.08.19 2697
371 전투 Spirits System 정령 장착?이라고해야되나; 26 file 카르와푸딩의아틀리에 2009.08.19 3869
370 맵/타일 추가 맵칩 사용 - 공개 34 file 허걱 2009.08.19 6491
369 이동 및 탈것 Rei Advanced Movement System 8 file 카르와푸딩의아틀리에 2009.08.19 2624
368 오디오 사운드테스트 스크립트 13 file 카르와푸딩의아틀리에 2009.08.19 2106
» 기타 범용 게이지 묘화 - KGC 14 file 카르와푸딩의아틀리에 2009.08.19 3476
366 메뉴 확장 스테이터스 화면 - KGC 23 file 카르와푸딩의아틀리에 2009.08.19 5057
365 스킬 DQ특기풍스킬 - KGC 4 카르와푸딩의아틀리에 2009.08.19 3288
364 기타 스크립트로 커먼 이벤트 실행 [수정] 3 허걱 2009.08.17 2311
363 기타 확장 에러 메시지 13 file 허걱 2009.08.17 2497
362 기타 거리계산 스크립트 (XP가능) 7 file 허걱 2009.08.16 2848
361 기타 말풍선 그림 바꾸기 6 file 허걱 2009.08.15 3561
360 메시지 [완성]RPG Maker VX용 한글 조사 자동결정 10 file 시릴캣 2009.08.13 4598
359 타이틀/게임오버 타이틀 공지 37 file 허걱 2009.08.10 4748
358 기타 글씨표시 스크립트 32 file 허걱 2009.08.10 4421
Board Pagination Prev 1 ... 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ... 32 Next
/ 32