Efect blur.
Página 1 de 1
Efect blur.
efeito tipo Matrix,ou melhor Effect Blur.
creditos :Chaosg1 (RMXP.org)
ver pagina original em
script
creditos :Chaosg1 (RMXP.org)
ver pagina original em
- Spoiler:
- http://www.reinorpg.com/forum/index.php?topic=1280.0
- Spoiler:
- adicionar o blur no jogador, bote $game_player.add_blur(quantidade), para adicionar em algum evento, bote $game_map.events[id do evento].add_blur(quantidade).
script
- Spoiler:
- #==============================================================================
# ** Effect Blur
#
# Author: Chaosg1
# Version: 1.0 A
# Date: 2007.01.21
#------------------------------------------------------------------------------
# This sprite is used to display a blur effect in the character.It observes the
# Game_Character class and automatically changes sprite conditions.
#==============================================================================
class Effect_Blur
#--------------------------------------------------------------------------
# * Object Initialization
# size : size (Integer or Float)
# character : character (Game_Character)
#--------------------------------------------------------------------------
def initialize(character,size,sizes =0)
@dispose = false
@old_x = 0
@old_y = 0
@viewport = $scene.spriteset.viewport1
@sprites = {}
@move_time = 0
@character = character
@size = size
@sizes = sizes
@index = size - 1
@index_holder = @index
@last_index = 0
@laster = false
for i in 0...@size
@sprites[i] = Sprite_Blur.new(@viewport, character)
@sprites[i].x = @character.screen_x
@sprites[i].y = @character.screen_y
end
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
return if @dispose == true
return if @sprites.nil?
a = false
b = false
#Checks Map Size
width = $game_map.width
height = $game_map.height
if @character.moving?
@laster = true
@index += 1
@index = 1 if @sprites[@index-1] == nil
if @character.x > 9 and @character.x < width - 9 and @character.direction == 6
a = true
@sprites[@index-1].x = @character.screen_x - 10
for i in @sprites.values
next if i == @sprites[@index-1]
i.x -=10
end
@sprites[@index-1].z = 1
end
if @character.x > 9 and @character.x < width - 9 and @character.direction == 4
a = true
@sprites[@index-1].x = @character.screen_x + 10
for i in @sprites.values
next if i == @sprites[@index-1]
i.x +=10
end
@sprites[@index-1].z = 1
end
if @character.y > 7 and @character.y < height - 7 and @character.direction == 2
b = true
@sprites[@index-1].y = @character.screen_y - 10
for i in @sprites.values
next if i == @sprites[@index-1]
i.y -=10
end
@sprites[@index-1].z = 1
end
if @character.y > 7 and @character.y < height - 7 and @character.direction == 8
b = true
@sprites[@index-1].y = @character.screen_y + 10
for i in @sprites.values
next if i == @sprites[@index-1]
i.y +=10
end
@sprites[@index-1].z = 1000
end
case @character.direction
when 4
@sprites[@index-1].x = @character.screen_x + @sizes if a == false
@sprites[@index-1].y = @character.screen_y if b == false
@sprites[@index-1].update
@sprites[@index-1].z = 1
when 6
@sprites[@index-1].x = @character.screen_x - @sizes if a == false
@sprites[@index-1].y = @character.screen_y if b == false
@sprites[@index-1].update
@sprites[@index-1].z = 1
when 8
@sprites[@index-1].x = @character.screen_x if a == false
@sprites[@index-1].y = @character.screen_y + @sizes if b == false
@sprites[@index-1].update
@sprites[@index-1].z = 1000
when 2
@sprites[@index-1].x = @character.screen_x if a == false
@sprites[@index-1].y = @character.screen_y - @sizes if b == false
@sprites[@index-1].update
@sprites[@index-1].z = 1
end
@last_index = @index
for i in @sprites.values
i.opacity = distance(i,@character) * 0.3
end
else
@last_index = 1 if @sprites[@last_index-1] == nil
@sprites[@last_index-1].opacity = 0
@sprites[@last_index-1].x = @character.screen_x
@sprites[@last_index-1].y = @character.screen_y
@last_index += 1
end
end
#--------------------------------------------------------------------------
# * Distance
# Object : Object ( Events, Player, windows, etc)
# Target : Object ( Events, Player, windows, etc)
#--------------------------------------------------------------------------
def distance(object,target)
distancex = (object.x - target.x)**2
distancey = (object.y - target.y)**2
return distance = Math.sqrt(distancex + distancey)
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
@dispose = true
return if @sprites.nil?
for i in @sprites.values
next if i == nil
i.dispose
end
end
end
#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
# This sprite is used to display the character.It observes the Game_Character
# class and automatically changes sprite conditions.
#==============================================================================
class Sprite_Blur < RPG::Sprite
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :character # character
#--------------------------------------------------------------------------
# * Object Initialization
# viewport : viewport
# character : character (Game_Character)
#--------------------------------------------------------------------------
def initialize(viewport, character = nil)
super(viewport)
@character = character
update
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# If tile ID, file name, or hue are different from current ones
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
# Remember tile ID, file name, and hue
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
# If tile ID value is valid
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
# If tile ID value is invalid
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
@cw = bitmap.width / 4
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
end
end
#Updates Position
# Set visible situation
self.visible = (not @character.transparent)
# If graphic is character
if @tile_id == 0
# Set rectangular transfer
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
# Set opacity level, blend method, and bush depth
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
# Animation
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs map screen processing.
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :spriteset
alias cg1_blur_scene_map_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
$scene_map = self
cg1_blur_scene_map_initialize
end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc.
# It's used within the Scene_Map class.
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :viewport1, :character_sprites
end
#==============================================================================
# ** Game_character
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc.
# It's used within the Scene_Map class.
#==============================================================================
class Game_Character
def add_blur(size)
@blur = Effect_Blur.new(self,size)
end
alias cg1_update update
def update
@blur.update if not @blur.nil?
cg1_update
end
end
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos
|
|