设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2864|回复: 1
打印 上一主题 下一主题

[已经解决] 图片绘制角色HP.MP.TP的脚本中的修改

[复制链接]

Lv1.梦旅人

梦石
0
星屑
146
在线时间
231 小时
注册时间
2011-8-7
帖子
11
跳转到指定楼层
1
发表于 2013-6-3 08:50:44 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
用图片绘制角色HP.MP.TP的脚本中,怎样改让图片以正常方式显示,而不是平行四边形。求解
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/    ◆ Draw Generic Gauge - KMS_GenericGauge ◆ VX Ace ◆
#_/    ◇ Last update : 2012/01/15 (TOMY@Kamesoft) ◇
#_/    ◇ Website: http://ytomy.sakura.ne.jp/
#_/    ◇ Translated by Mr. Bubble ◇
#_/----------------------------------------------------------------------------
#_/  Provides groundwork code for simple image-based gauges.
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#  This script provides groundwork code for simple gauge graphics based
#  off images placed in the Graphics/System folder. By default, this script
#  provides gauges for HP, MP, TP, and EXP.
#
#  Scripters can utilize their own Generic Gauge for their
#  own use. See the "Notes to Scripters" section below the customization
#  section.
#----------------------------------------------------------------------------
#  !! WARNING !!
#  If an error pops up saying "wrong number of arguments",
#  please post in the topic you got this script in and ask for a
#  compatibility patch with the other custom script you're trying to
#  use.
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

#==============================================================================
# ★ BEGIN Setting ★
#==============================================================================

module KMS_GenericGauge
  # * Gauge File Names
  #   Images must be placed in the "Graphics/System" folder of your project
  HP_IMAGE  = "GaugeHP"   # HP
  MP_IMAGE  = "GaugeMP"   # MP
  TP_IMAGE  = "GaugeTP"   # TP
  EXP_IMAGE = "GaugeEXP"  # EXP

  # * Gauge Position Offset [x, y]
  HP_OFFSET  = [-23, -2]  # HP
  MP_OFFSET  = [-23, -2]  # MP
  TP_OFFSET  = [-23, -2]  # TP
  EXP_OFFSET = [-23, -2]  # EXP

  # * Gauge Length Adjustment
  HP_LENGTH  = -4  # HP
  MP_LENGTH  = -4  # MP
  TP_LENGTH  = -4  # TP
  EXP_LENGTH = -4  # EXP

  # * Gauge Slope
  #   Must be between -89 ~ 89 degrees
  HP_SLOPE  = 30  # HP
  MP_SLOPE  = 30  # MP
  TP_SLOPE  = 30  # TP
  EXP_SLOPE = 30  # EXP
end

#==============================================================================
# ☆ END Setting ☆
#==============================================================================

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

# *****************************************************************************

  #--------------------------------------------------------------------------
  # Notes to Scripters
  #--------------------------------------------------------------------------
  # Drawing your own custom gauge within a window can be done by using a single
  # method:
  #
  #   draw_gauge(file, x, y, width, rate, offset, len_offset,
  #     slope, gauge_type = :normal)
  #
  # ++ Draw Generic Gauge Arguments
  #     file       : Gauge image filename
  #     x, y       : x, y draw coordinates
  #     width      : Gauge width
  #     rate       : Gauge fill ratio (0.0 ~ 1.0)
  #     offset     : Gauge coordinate adjustment [x, y]
  #     len_offset : Length Adjustment
  #     slope      : Gauge slope degree (-89~89)
  #     gauge_type : Gauge type ( :normal , :decrease , :increase )
  #--------------------------------------------------------------------------
  # gauge_type determines how the gauge fills depending on the current
  # value of the gauge.
  #--------------------------------------------------------------------------
  # This script overwrites Window_Base#draw_gauge and adds 2 extra args
  # which will cause compatibility issues with other scripts that uses
  # the default draw_gauge method and args.
  #--------------------------------------------------------------------------

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

unless $kms_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.round
      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
  #--------------------------------------------------------------------------
  # ○ 現在のレベルから次のレベルまでの全必要経験値取得
  #--------------------------------------------------------------------------
  def next_level_exp_full
    return next_level_exp - current_level_exp
  end
  #--------------------------------------------------------------------------
  # ○ 次のレベルまでの残り経験値取得
  #--------------------------------------------------------------------------
  def next_level_exp_rest
    return next_level_exp - exp
  end
  #--------------------------------------------------------------------------
  # ○ 次のレベルまでの経験値取得率取得
  #--------------------------------------------------------------------------
  def exp_rate
    diff = [next_level_exp_full, 1].max
    rest = [next_level_exp_rest, 1].max
    return (diff - rest) * 1.0 / diff
  end
end

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

class Window_Base < Window
  #--------------------------------------------------------------------------
  # ○ 定数
  #--------------------------------------------------------------------------
  # ゲージ転送元座標 [x, y]
  GAUGE_SRC_POS = {
    :normal   => [ 0, 24],
    :decrease => [ 0, 48],
    :increase => [72, 48],
  }
  #--------------------------------------------------------------------------
  # ○ クラス変数
  #--------------------------------------------------------------------------
  @@__gauge_buf = Bitmap.new(320, 24)
  #--------------------------------------------------------------------------
  # ○ ゲージ描画
  #     file       : ゲージ画像ファイル名
  #     x, y       : 描画先 X, Y 座標
  #     width      : 幅
  #     ratio      : 割合
  #     offset     : 座標調整 [x, y]
  #     len_offset : 長さ調整
  #     slope      : 傾き
  #     gauge_type : ゲージタイプ
  #--------------------------------------------------------------------------
  def draw_gauge(file, x, y, width, ratio, offset, len_offset, slope,
                 gauge_type = :normal)
    img    = Cache.system(file)
    x     += offset[0]
    y     += offset[1]
    width += len_offset
    draw_gauge_base(img, x, y, width, slope)
    gw = (width * ratio).to_i
    draw_gauge_bar(img, x, y, width, gw, slope, GAUGE_SRC_POS[gauge_type])
  end
  #--------------------------------------------------------------------------
  # ○ ゲージベース描画
  #     img   : ゲージ画像
  #     x, y  : 描画先 X, Y 座標
  #     width : 幅
  #     slope : 傾き
  #--------------------------------------------------------------------------
  def draw_gauge_base(img, x, y, width, slope)
    rect = Rect.new(0, 0, 24, 24)
    if slope != 0
      contents.skew_blt(x, y, img, rect, slope)
      rect.x = 96
      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)
      contents.skew_blt(x + 24, y, @@__gauge_buf, dest_rect, slope)
    else
      contents.blt(x, y, img, rect)
      rect.x = 96
      contents.blt(x + width + 24, y, img, rect)
      rect.x     = 24
      rect.width = 72
      dest_rect = Rect.new(x + 24, y, width, 24)
      contents.stretch_blt(dest_rect, img, rect)
    end
  end
  #--------------------------------------------------------------------------
  # ○ ゲージ内部描画
  #     img     : ゲージ画像
  #     x, y    : 描画先 X, Y 座標
  #     width   : 全体幅
  #     gw      : 内部幅
  #     slope   : 傾き
  #     src_pos : 転送元座標 [x, y]
  #     start   : 開始位置
  #--------------------------------------------------------------------------
  def draw_gauge_bar(img, x, y, width, gw, slope, src_pos, start = 0)
    rect = Rect.new(src_pos[0], src_pos[1], 72, 24)
    dest_rect = Rect.new(0, 0, width, 24)
    @@__gauge_buf.clear
    @@__gauge_buf.stretch_blt(dest_rect, img, rect)
    dest_rect.x     = start
    dest_rect.width = gw
    x += start
    if slope != 0
      contents.skew_blt(x + 24, y, @@__gauge_buf, dest_rect, slope)
    else
      contents.blt(x + 24, y, @@__gauge_buf, dest_rect)
    end
  end
  #--------------------------------------------------------------------------
  # ● HP の描画
  #--------------------------------------------------------------------------
  def draw_actor_hp(actor, x, y, width = 124)
    draw_actor_hp_gauge(actor, x, y, width)
    change_color(system_color)
    draw_text(x, y, 60, line_height, Vocab::hp_a)
    draw_current_and_max_values(x, y, width, actor.hp, actor.mhp,
      hp_color(actor), normal_color)
  end
  #--------------------------------------------------------------------------
  # ● MP の描画
  #--------------------------------------------------------------------------
  def draw_actor_mp(actor, x, y, width = 124)
    draw_actor_mp_gauge(actor, x, y, width)
    change_color(system_color)
    draw_text(x, y, 60, line_height, Vocab::mp_a)
    draw_current_and_max_values(x, y, width, actor.mp, actor.mmp,
      mp_color(actor), normal_color)
  end
  #--------------------------------------------------------------------------
  # ● TP の描画
  #--------------------------------------------------------------------------
  def draw_actor_tp(actor, x, y, width = 124)
    draw_actor_tp_gauge(actor, x, y, width)
    change_color(system_color)
    draw_text(x, y, 60, line_height, Vocab::tp_a)
    change_color(tp_color(actor))
    draw_text(x + width - 42, y, 42, line_height, actor.tp.to_i, 2)
  end
  #--------------------------------------------------------------------------
  # ○ HP ゲージの描画
  #     actor : アクター
  #     x, y  : 描画先 X, Y 座標
  #     width : 幅
  #--------------------------------------------------------------------------
  def draw_actor_hp_gauge(actor, x, y, width = 120)
    draw_gauge(KMS_GenericGauge::HP_IMAGE,
      x, y, width, actor.hp_rate,
      KMS_GenericGauge::HP_OFFSET,
      KMS_GenericGauge::HP_LENGTH,
      KMS_GenericGauge::HP_SLOPE
    )
  end
  #--------------------------------------------------------------------------
  # ○ MP ゲージの描画
  #     actor : アクター
  #     x, y  : 描画先 X, Y 座標
  #     width : 幅
  #--------------------------------------------------------------------------
  def draw_actor_mp_gauge(actor, x, y, width = 120)
    draw_gauge(KMS_GenericGauge::MP_IMAGE,
      x, y, width, actor.mp_rate,
      KMS_GenericGauge::MP_OFFSET,
      KMS_GenericGauge::MP_LENGTH,
      KMS_GenericGauge::MP_SLOPE
    )
  end
  #--------------------------------------------------------------------------
  # ○ TP ゲージの描画
  #     actor : アクター
  #     x, y  : 描画先 X, Y 座標
  #     width : 幅
  #--------------------------------------------------------------------------
  def draw_actor_tp_gauge(actor, x, y, width = 120)
    draw_gauge(KMS_GenericGauge::TP_IMAGE,
      x, y, width, actor.tp_rate,
      KMS_GenericGauge::TP_OFFSET,
      KMS_GenericGauge::TP_LENGTH,
      KMS_GenericGauge::TP_SLOPE
    )
  end
  #--------------------------------------------------------------------------
  # ○ Exp の描画
  #     actor : アクター
  #     x, y  : 描画先 X, Y 座標
  #     width : 幅
  #--------------------------------------------------------------------------
  def draw_actor_exp(actor, x, y, width = 200)
    str = actor.max_level? ? "-------" : actor.exp
    change_color(normal_color)
    draw_text(x, y, width, line_height, str, 2)
  end
  #--------------------------------------------------------------------------
  # ○ NextExp の描画
  #     actor : アクター
  #     x, y  : 描画先 X, Y 座標
  #     width : 幅
  #--------------------------------------------------------------------------
  def draw_actor_next_exp(actor, x, y, width = 200)
    draw_actor_exp_gauge(actor, x, y, width)
    change_color(system_color)
    draw_text(x, y, 80, line_height, "Next")
    str = actor.max_level? ? "-------" : actor.next_level_exp_rest
    change_color(normal_color)
    draw_text(x, y, width, line_height, str, 2)
  end
  #--------------------------------------------------------------------------
  # ○ Exp ゲージの描画
  #     actor : アクター
  #     x, y  : 描画先 X, Y 座標
  #     width : 幅
  #--------------------------------------------------------------------------
  def draw_actor_exp_gauge(actor, x, y, width = 180)
    draw_gauge(KMS_GenericGauge::EXP_IMAGE,
      x, y, width, actor.exp_rate,
      KMS_GenericGauge::EXP_OFFSET,
      KMS_GenericGauge::EXP_LENGTH,
      KMS_GenericGauge::EXP_SLOPE
    )
  end
end

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

class Window_Status < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 経験値情報の描画
  #--------------------------------------------------------------------------
  def draw_exp_info(x, y)
    s_next = sprintf(Vocab::ExpNext, Vocab::level)
    change_color(system_color)
    draw_text(x, y + line_height * 0, 180, line_height, Vocab::ExpTotal)
    draw_text(x, y + line_height * 2, 180, line_height, s_next)
    change_color(normal_color)
    draw_actor_exp(     @actor, x, y + line_height * 1)
    draw_actor_next_exp(@actor, x, y + line_height * 3)
  end
end
应该是修改100行之下吧.脚本盲表示鸭梨很大。PS.第一次发帖.有错误请原谅

Lv1.梦旅人

梦石
0
星屑
146
在线时间
231 小时
注册时间
2011-8-7
帖子
11
2
 楼主| 发表于 2013-6-3 10:21:35 | 只看该作者
我去.我真是真是太2了...
用翻译器找到了
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-18 16:40

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表