=begin
RGSS3
★ 光拡散エフェクト ★
光が広がったり、集まったり、降ったりします。
天候と似た使い方を想定しています。
イベントコマンドのスクリプトから起動させてください。
● コマンド一覧 ●==================================================
start_effect(type)
--------------------------------------------------------------------
光拡散エフェクトを開始します。
引数の値によってエフェクトの種類が決定します
1 => 中心から発散
2 => 中心へ収束
3 => 中央上部から下へ
4 => 上部全体から下へ
5 => 右上から左下へ
21 => 不規則な螺旋を描いて上昇
22 => ゆらゆらと上昇
23 => 規則正しい螺旋を描いて上昇
31 => 雪
====================================================================
end_effect
--------------------------------------------------------------------
エフェクトの終了。画面上のエフェクトをすべて一気に開放します。
====================================================================
end_effect_fade
--------------------------------------------------------------------
エフェクトの終了。画面上のエフェクトを少しづつ開放します。
====================================================================
ver1.11
Last Update : 2012/03/24
02/22 : 「特殊エフェクト - タイトル表示プラグイン」併用時、
: ニューゲーム選択時にスプライトが解放されない不具合を修正
----------------------2019--------------------------
03/24 : 雪エフェクトの追加
----------------------2012--------------------------
12/17 : RGSS2からの移植
----------------------2011--------------------------
ろかん [url]http://kaisou-ryouiki.sakura.ne.jp/[/url]
=end
$rsi ||= {}
$rsi["光拡散エフェクト"] = true
module Reffect
@@span = false
def initialize(viewport)
@sp = [0, 0] # 初期座標
@ma = [0.0, 0.0] # 移動角度(ラジアン)
@rd = 0.0 # 初期座標からの半径
super(viewport)
self.blend_type = 1
@@span ^= true
end
def width
Graphics.width
end
def height
Graphics.height
end
def zoom=(value)
self.zoom_x = self.zoom_y = value
end
def setGraphic(filename)
self.bitmap = Cache.system(filename)
self.ox = self.bitmap.width / 2
self.oy = self.bitmap.height / 2
end
def setStartPosition(typeX, typeY)
case typeX
when 0 # ランダム
@sp[0] = rand(width + 100) - 50
when 1 # 画面外(左)
@sp[0] = -30
when 2 # 中央
@sp[0] = width / 2
when 3 # 画面外(右)
@sp[0] = width + 30
end
case typeY
when 0 # ランダム
@sp[1] = rand(height + 50) - 25
when 1 # 画面外(上)
@sp[1] = -30
when 2 # 中央
@sp[1] = height / 2
when 3 # 画面外(下)
@sp[1] = height + 30
end
self.x = @sp[0]
self.y = @sp[1]
end
def setMoveAngle(ax, ay = ax)
@ma[0] = Math.cos(ax * 0.01)
@ma[1] = Math.sin(ay * 0.01)
end
def getX
@sp[0] + @rd * @ma[0]
end
def getY
@sp[1] + @rd * @ma[1]
end
def getZoom
(@rd * @ma[1] / width / 1.5 + 0.8) * (self.opacity / 200.0)
end
end
class Game_Temp
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :r_effect_sprites # 特殊効果スプライト群
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias r_effect_initialize initialize
def initialize
r_effect_initialize
@r_effect_sprites = $game_temp ? $game_temp.r_effect_sprites : []
end
#--------------------------------------------------------------------------
# ● 特殊効果スプライトの解放
#--------------------------------------------------------------------------
def dispose_r_effect
@r_effect_sprites.each{|sprite| sprite.dispose}
@r_effect_sprites = []
end
end
class Game_System
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :r_effect_type # 特殊効果の種類
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias r_effect_initialize initialize
def initialize
r_effect_initialize
@r_effect_type = 0
end
#--------------------------------------------------------------------------
# ● 特殊効果の開始
#--------------------------------------------------------------------------
def start_effect(type)
$game_temp.dispose_r_effect if @r_effect_type != type
@r_effect_type = type
end
#--------------------------------------------------------------------------
# ● 特殊効果の終了(瞬時)
#--------------------------------------------------------------------------
def end_effect
$game_temp.dispose_r_effect
@r_effect_type = 0
end
#--------------------------------------------------------------------------
# ● 特殊効果の終了(フェード)
#--------------------------------------------------------------------------
def end_effect_fade
@r_effect_type = 0
end
end
class Game_Interpreter
#--------------------------------------------------------------------------
# ● 特殊効果の開始
#--------------------------------------------------------------------------
def start_effect(type)
$game_system.start_effect(type)
end
#--------------------------------------------------------------------------
# ● 特殊効果の終了(瞬時)
#--------------------------------------------------------------------------
def end_effect
$game_system.end_effect
end
#--------------------------------------------------------------------------
# ● 特殊効果の終了(フェード)
#--------------------------------------------------------------------------
def end_effect_fade
$game_system.end_effect_fade
end
end
class Sprite_Reffect_Diffusion < Sprite
#--------------------------------------------------------------------------
# ● インクルード Reffect
#--------------------------------------------------------------------------
include Reffect
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(viewport)
super(viewport)
case $game_system.r_effect_type
when 1
@rd = rand(width / 3).to_f
@moveSpeed = rand(50).next * 0.01 + 0.5
@existCount = rand(100) + 80
setStartPosition(2, 2)
setMoveAngle(rand(2 * Math::PI * 100))
setGraphic("RE_001")
when 2
@rd = rand(width / 3).to_f + 30.0
@moveSpeed = rand(50).next * -0.01 - 0.5
@existCount = rand(100) + 90
setStartPosition(2, 2)
setMoveAngle(rand(2 * Math::PI * 100))
setGraphic("RE_001")
when 3
@rd = rand(width / 2).to_f
@moveSpeed = rand(50).next * 0.01 + 0.5
@existCount = rand(100) + 80
setStartPosition(2, 1)
setMoveAngle(rand(2 * Math::PI * 100), rand(Math::PI * 100))
setGraphic("RE_001")
when 4
@rd = rand(width / 2).to_f
@moveSpeed = rand(50).next * 0.01 + 0.5
@existCount = rand(100) + 80
setStartPosition(0, 1)
setMoveAngle(rand(2 * Math::PI * 100), rand(Math::PI * 100))
setGraphic("RE_001")
when 5
@rd = rand(width / 2).to_f
@moveSpeed = rand(50).next * 0.01 + 0.5
@existCount = rand(100) + 120
setStartPosition(3, 1)
setMoveAngle(rand(Math::PI * 100) + 90, rand(Math::PI * 100))
setGraphic("RE_001")
end
@maxOpacity = rand(160) + 40
self.opacity = 1
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
if self.opacity.zero?
dispose
$game_temp.r_effect_sprites.delete(self)
else
@existCount -= 1
@rd = [@rd + @moveSpeed, 0.0].max
self.x = getX
self.y = getY
self.zoom = getZoom
self.opacity = [self.opacity + (@existCount > 0 ? 1 : -1), @maxOpacity].min
end
end
end
class Sprite_Reffect_Spiral < Sprite
#--------------------------------------------------------------------------
# ● インクルード Reffect
#--------------------------------------------------------------------------
include Reffect
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(viewport)
super(viewport)
case $game_system.r_effect_type
when 21
@rd = rand(200).next.to_f
@moveSpeed = 5.0 - @rd / 50.0
@nextAngle = rand(360).to_f
@collapseSpeed = 1
setStartPosition(2, 3)
setGraphic("RE_002")
when 22
@rd = rand(40).next.to_f
@moveSpeed = rand(100).next * 0.01 + 1.0
@nextAngle = rand(360).to_f
@collapseSpeed = rand(3).zero? ? 2 : 1
setStartPosition(0, 3)
setGraphic("RE_002")
when 23
@rd = 180
@moveSpeed = 1.7
@nextAngle = @@span ? 0.0 : 180.0
@collapseSpeed = 0
setStartPosition(2, 3)
setGraphic("RE_002")
end
@floteY = self.y.to_f
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
if self.y <= -self.oy || self.opacity.zero?
dispose
$game_temp.r_effect_sprites.delete(self)
else
@nextAngle += [@moveSpeed, 2].min
@nextAngle = 0.0 if @nextAngle >= 360
setMoveAngle(@nextAngle * 1.74533)
self.x = getX
self.y = (@floteY -= @moveSpeed).round
self.zoom = getZoom
self.opacity -= @collapseSpeed
end
end
end
class Sprite_Reffect_Snow < Sprite
#--------------------------------------------------------------------------
# ● インクルード Reffect
#--------------------------------------------------------------------------
include Reffect
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(viewport)
super(viewport)
setStartPosition(0, 1)
setGraphic("RE_003")
case rand(100)
when 0..49
self.zoom = (3 + rand(2)) / 10.0
when 50..89
self.zoom = (6 + rand(2)) / 10.0
when 90..99
self.zoom = (9 + rand(2)) / 10.0
end
self.z = self.zoom_x * 10
@moveSpeed = self.zoom_x * 1.6
@floteY = self.y.to_f
@rd = rand(10).next.to_f
@nextAngle = rand(360).to_f
@existCount = 1500
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
if self.y > height || self.opacity.zero?
dispose
$game_temp.r_effect_sprites.delete(self)
else
@existCount -= 3
@nextAngle += [@moveSpeed, 2].min
@nextAngle = 0.0 if @nextAngle >= 360
setMoveAngle(@nextAngle * 1.74533)
self.x = getX
self.y = (@floteY += @moveSpeed).round
self.opacity = @existCount
end
end
end
class Spriteset_Map
@@re_add_count = 0
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
alias r_effect_dispose dispose
def dispose
r_effect_dispose
$game_temp.dispose_r_effect
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
alias r_effect_update update
def update
r_effect_update
update_r_effect
end
#--------------------------------------------------------------------------
# ● 特殊エフェクトの更新
#--------------------------------------------------------------------------
def update_r_effect
unless $game_system.r_effect_type.zero?
if @@re_add_count.zero?
case $game_system.r_effect_type
when 1..10
sprite = Sprite_Reffect_Diffusion.new(@viewport3)
@@re_add_count = 10
when 21..30
sprite = Sprite_Reffect_Spiral.new(@viewport3)
@@re_add_count = 10
when 31..40
sprite = Sprite_Reffect_Snow.new(@viewport3)
@@re_add_count = 20
end
$game_temp.r_effect_sprites << sprite
end
@@re_add_count -= 1
end
$game_temp.r_effect_sprites.each{|sprite| sprite.update}
end
end