rebf-gaiden/Scripts/_.54.rb
2025-04-26 17:06:34 -05:00

82 lines
No EOL
1.9 KiB
Ruby

#
# ピクチャ息遣い
# ひきも記さんのスクリプトを改変
# http://hikimoki.sakura.ne.jp/
#
# pictuer_breath_on([5,6], 150)みたいな形でイベントコマンドのスクリプトから。
# 5,6 は対象とするピクチャ番号
# 150はスピード、小さいほど遅い(100~300くらいが限度)
#
# pictuer_breath_off([1])とかで解除。
#
# イベントコマンドのスクリプト
class Game_Interpreter
def pictuer_breath_on(ary , speed)
for p_id in ary
screen.pictures[p_id].breath = "on"
screen.pictures[p_id].breath_speed = speed
end
end
def pictuer_breath_off(ary)
for p_id in ary
screen.pictures[p_id].breath = "off"
end
end
end
#
class Game_Picture
attr_accessor :breath
attr_accessor :breath_speed
alias init_breath_basic init_basic
def init_basic
init_breath_basic
@breath = ""
@breath_speed = 0
end
end
#
class Sprite_Picture < Sprite
alias breath_initialize initialize
def initialize(viewport, picture)
@zoom_max = nil
@zoom_count = nil
@breath = false
breath_initialize(viewport, picture)
end
alias breath_before_update update
def update
breath_before_update
breath_check
breath_update
end
def breath_check
if @picture.breath == "on"
@zoom_max = @picture.breath_speed
@zoom_count = 0
@picture.breath = ""
@breath = true
end
if @picture.breath == "off"
@picture.breath = ""
@breath = false
end
end
def breath_update
if @breath
@zoom_count += 1
if @zoom_count == @zoom_max
@zoom_count = 0
end
f = Math.sin(Math::PI * @zoom_count / (@zoom_max / 2))
self.zoom_y += f * 0.010 + 0.010
self.y -= (self.height * (1.0 - self.zoom_y) / 2).ceil
self.zoom_x += f * 0
# self.x += (self.width * (1.0 - self.zoom_x)).ceil
end
end
end