Particle Engine v2 [RPG Maker XP]
Publicado em 7 de dezembro de 2015.Particle Engine é um engine de partículas para o RPG Maker XP desenvolvido pelo Near Fantastica baseada no Particle Engine desenvolvido pelo PinkMan.
Basicamente, ele permite belos efeitos de partículas serem apresentados no seu projeto ou jogo desenvolvido neste maker, como na cachoeira exibida na screenshot abaixo:
Screenshot

Utilização
É recomendado baixar a demo para ver como tudo funciona, além de pegar os recursos necessários prontos também.
O Particle Engine v2 precisa do Standart Development Kit e, o seu código (abaixo) deve ficar abaixo deste e acima do Main:
#==============================================================================
# ** Particle Engine
#==============================================================================
# Near Fantastica
# Version 2
# 04.01.06
#==============================================================================
# Based on the Particle Engine designed by PinkMan
#==============================================================================
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log("Particle Engine", "Near Fantastica", 2, "04.01.06")
#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state("Particle Engine") == true
class Particle_Engine
#--------------------------------------------------------------------------
def initialize(viewport)
@viewport = viewport
@effect = []
end
#--------------------------------------------------------------------------
def add_effect(event)
type = SDK.event_comment_input(event, 1, "Particle Engine Type")
return if type.nil?
case type[0].downcase
# PinkMan's Effects
when "fire"
@effect[event.id] = Particle_Engine::Fire.new(event,@viewport)
when "smoke"
@effect[event.id] = Particle_Engine::Smoke.new(event,@viewport)
when "teleport"
@effect[event.id] = Particle_Engine::Teleport.new(event,@viewport)
when "spirit"
@effect[event.id] = Particle_Engine::Spirit.new(event,@viewport)
when "explosion"
@effect[event.id] = Particle_Engine::Explosion.new(event,@viewport)
when "aura"
@effect[event.id] = Particle_Engine::Aura.new(event,@viewport)
# BlueScope's Effects
when "soot"
@effect[event.id] = Particle_Engine::Soot.new(event,@viewport)
when "sootsmoke"
@effect[event.id] = Particle_Engine::SootSmoke.new(event,@viewport)
when "rocket"
@effect[event.id] = Particle_Engine::Rocket.new(event,@viewport)
when "fixteleport"
@effect[event.id] = Particle_Engine::FixedTeleport.new(event,@viewport)
when "smokescreen"
@effect[event.id] = Particle_Engine::Smokescreen.new(event,@viewport)
when "flare"
@effect[event.id] = Particle_Engine::Flare.new(event,@viewport)
when "splash"
@effect[event.id] = Particle_Engine::Splash.new(event,@viewport)
end
end
#--------------------------------------------------------------------------
def remove_effect(event)
return if @effect[event.id].nil?
@effect[event.id].dispose
@effect.delete_at(event.id)
end
#--------------------------------------------------------------------------
def update
for particle in @effect
next if particle.nil?
particle.update
end
end
#--------------------------------------------------------------------------
def dispose
for particle in @effect
next if particle.nil?
particle.dispose
end
@effect = []
end
#===========================================================================
class Particle_Engine::Fire
#------------------------------------------------------------------------
def initialize(event, viewport)
@event = event
@xoffset = -5 # offset for the x
@yoffset = -13 # offset for the y
@leftright = 0 # This is made to help the "fire" effect
@maxparticless = 20 # Wouldnt suggest going any higher then 478
@hue = 40 # Starting hue color
@slowdown = 0.5 # This will slow down the particless
@ytop = 0 # Top half of the screen pixel
@ybottom = 480 # Screen Height
@xleft = 0 # First pixel to the left
@xright = 640 # Screen Width
@xgravity = 0.5 # Gravity for x axis (goes by tens)
@ygravity = 0.10 # Gravity for y axis (goes by tens)
@particles = []
@opacity = []
@startingx = event.screen_x + @xoffset
@startingy = event.screen_y + @yoffset
@screen_x = @event.screen_x
@screen_y = @event.screen_y
for i in 0...@maxparticless
@particles[i] = Sprite.new(viewport)
@particles[i].bitmap = RPG::Cache.fog("particle", @hue)
@particles[i].blend_type = 1
@particles[i].y = @startingy
@particles[i].x = @startingx
@particles[i].z = @event.screen_z
@opacity[i] = 250
end
end
#------------------------------------------------------------------------
def update
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
offsetx = @event.screen_x - @screen_x
@screen_x = @event.screen_x
offsety = @event.screen_y - @screen_y
@screen_y = @event.screen_y
for i in 0...@maxparticless
@particles[i].z = @event.screen_z
if @particles[i].y <= @ytop
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x <= @xleft
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].y >= @ybottom
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x >= @xright
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @fade == 0
if @opacity[i] <= 0
@opacity[i] = @originalopacity
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
else
if @opacity[i] <= 0
@opacity[i] = 250
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
end
if @randomhue == 1
if @hue == 360
@hue = 0
end
@hue = @hue + 0.5
@particles[i].bitmap = RPG::Cache.fog("particle", @hue)
end
@opacity[i] = @opacity[i] - rand(30)
@leftright = rand(2)
if @leftright == 1
@particles[i].x = (@particles[i].x - (@xgravity / @slowdown)) + offsetx
else
@particles[i].x = (@particles[i].x + (@xgravity / @slowdown)) + offsetx
end
@particles[i].y = (@particles[i].y - (@ygravity / @slowdown)) + offsety
@particles[i].opacity = @opacity[i]
end
end
#------------------------------------------------------------------------
def dispose
for particle in @particles
particle.dispose
end
@particles = []
end
end
#===========================================================================
class Particle_Engine::Smoke
#------------------------------------------------------------------------
def initialize(event, viewport)
@event = event
@leftright = 0 # This is made to help the "fire" effect
@fade = 0 # Opacity wont change at all 0 = yes, 1 = no
@originalopacity = 80 # this will only work if the one above is 0
@maxparticless = 20 # Wouldnt suggest going any higher then 478
@hue = 0 # Starting hue color
@slowdown = 0.5 # This will slow down the particless
@ytop = 0 # Top half of the screen pixel
@ybottom = 480 # Screen Height
@xleft = 0 # First pixel to the left
@xright = 640 # Screen Width
@xgravity = 0.5 # Gravity for x axis (goes by tens)
@ygravity = 0.10 # Gravity for y axis (goes by tens)
@xoffset = -5 # offset for the x
@yoffset = -15 # offset for the y
@particles = []
@opacity = []
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
@screen_x = @event.screen_x
@screen_y = @event.screen_y
for i in 0...@maxparticless
@particles[i] = Sprite.new(viewport)
@particles[i].bitmap = RPG::Cache.fog("smoke", @hue)
@particles[i].blend_type = 1
@particles[i].y = @startingy
@particles[i].x = @startingx
@particles[i].z = @event.screen_z
@opacity[i] = 100
end
end
#------------------------------------------------------------------------
def update
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
offsetx = @event.screen_x - @screen_x
@screen_x = @event.screen_x
offsety = @event.screen_y - @screen_y
@screen_y = @event.screen_y
for i in 0...@maxparticless
@particles[i].z = @event.screen_z
if @particles[i].y <= @ytop
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x <= @xleft
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].y >= @ybottom
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x >= @xright
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @fade == 0
if @opacity[i] <= 0
@opacity[i] = @originalopacity
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
else
if @opacity[i] <= 0
@opacity[i] = 250
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
end
if @randomhue == 1
if @hue == 360
@hue = 0
end
@hue = @hue + 0.5
@particles[i].bitmap = RPG::Cache.fog("smoke", @hue)
end
@opacity[i] = @opacity[i] - rand(5)
@leftright = rand(2)
if @leftright == 1
@particles[i].x = (@particles[i].x - (@xgravity / @slowdown)) + offsetx
else
@particles[i].x = (@particles[i].x + (@xgravity / @slowdown)) + offsetx
end
@particles[i].y = (@particles[i].y - (@ygravity / @slowdown)) + offsety
@particles[i].opacity = @opacity[i]
end
end
#------------------------------------------------------------------------
def dispose
for particle in @particles
particle.dispose
end
@particles = []
end
end
#===========================================================================
class Particle_Engine::Teleport
#------------------------------------------------------------------------
def initialize(event, viewport)
@event = event
@randomhue = 1 # should the hue change ranomly 0 no 1 yes
@leftright = 0 # This is made to help the "fire" effect
@maxparticless = 10 # Wouldnt suggest going any higher then 478
@hue = 40 # Starting hue color
@slowdown = 0.5 # This will slow down the particless
@ytop = 0 # Top half of the screen pixel
@ybottom = 480 # Screen Height
@xleft = 0 # First pixel to the left
@xright = 640 # Screen Width
@xgravity = 0.5 # Gravity for x axis (goes by tens)
@ygravity = 0.10 # Gravity for y axis (goes by tens)
@xoffset = -8 # offset for the x
@yoffset = -15 # offset for the y
@particles = []
@opacity = []
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
@screen_x = @event.screen_x
@screen_y = @event.screen_y
for i in 0...@maxparticless
@particles[i] = Sprite.new(viewport)
@particles[i].bitmap = RPG::Cache.fog("portal", @hue)
@particles[i].blend_type = 1
@particles[i].y = @startingy
@particles[i].x = @startingx
@particles[i].z = @event.screen_z
@opacity[i] = 250
end
end
#------------------------------------------------------------------------
def update
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
offsetx = @event.screen_x - @screen_x
@screen_x = @event.screen_x
offsety = @event.screen_y - @screen_y
@screen_y = @event.screen_y
for i in 0...@maxparticless
@particles[i].z = @event.screen_z
if @particles[i].y <= @ytop
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x <= @xleft
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].y >= @ybottom
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x >= @xright
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @fade == 0
if @opacity[i] <= 0
@opacity[i] = @originalopacity
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
else
if @opacity[i] <= 0
@opacity[i] = 250
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
end
if @randomhue == 1
if @hue == 360
@hue = 0
end
@hue = @hue + 0.5
@particles[i].bitmap = RPG::Cache.fog("portal", @hue)
else
end
@opacity[i] = @opacity[i] - rand(20)
@leftright = rand(2)
@particles[i].x = @particles[i].x + offsetx
@particles[i].y = @particles[i].y - 3 + offsety
@particles[i].opacity = @opacity[i]
end
end
#------------------------------------------------------------------------
def dispose
for particle in @particles
particle.dispose
end
@particles = []
end
end
#===========================================================================
class Particle_Engine::Spirit
#------------------------------------------------------------------------
def initialize(event, viewport)
@event = event
@randomhue = 1 # should the hue change ranomly 0 no 1 yes
@leftright = 0 # This is made to help the "fire" effect
@maxparticless = 20 # Wouldnt suggest going any higher then 478
@hue = 40 # Starting hue color
@slowdown = 0.5 # This will slow down the particless, change it to whatever.
@ytop = 0 # Top half of the screen pixel
@ybottom = 480 # Screen Height
@xleft = 0 # First pixel to the left
@xright = 640 # Screen Width
@xgravity = 0.5 # Gravity for x axis (goes by tens)
@ygravity = 0.10 # Gravity for y axis (goes by tens)
@xoffset = -5 # offset for the x
@yoffset = -13 # offset for the y
@particles = []
@opacity = []
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
for i in 0...@maxparticless
@particles[i] = Sprite.new(viewport)
@particles[i].bitmap = RPG::Cache.fog("particle", @hue)
@particles[i].blend_type = 1
@particles[i].y = @startingy
@particles[i].x = @startingx
@particles[i].z = @event.screen_z
@opacity[i] = 250
end
end
#------------------------------------------------------------------------
def update
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
for i in 0...@maxparticless
@particles[i].z = @event.screen_z
if @particles[i].y <= @ytop
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x <= @xleft
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].y >= @ybottom
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x >= @xright
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @fade == 0
if @opacity[i] <= 0
@opacity[i] = @originalopacity
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
else
if @opacity[i] <= 0
@opacity[i] = 250
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
end
if @randomhue == 1
if @hue == 360
@hue = 0
end
@hue = @hue + 0.5
@particles[i].bitmap = RPG::Cache.fog("particle", @hue)
else
end
@opacity[i] = @opacity[i] - rand(30)
@leftright = rand(2)
if @leftright == 1
@particles[i].x = (@particles[i].x - (@xgravity / @slowdown))
else
@particles[i].x = (@particles[i].x + (@xgravity / @slowdown))
end
@particles[i].y = (@particles[i].y - (@ygravity / @slowdown))
@particles[i].opacity = @opacity[i]
end
end
#------------------------------------------------------------------------
def dispose
for particle in @particles
particle.dispose
end
@particles = []
end
end
#===========================================================================
class Particle_Engine::Explosion
#------------------------------------------------------------------------
def initialize(event, viewport)
@event = event
@randomhue = 0 # should the hue change ranomly 0 no 1 yes
@leftright = 0 # This is made to help the "fire" effect
@maxparticless = 20 # Wouldnt suggest going any higher then 478
@hue = 0 # Starting hue color
@slowdown = 0.5 # This will slow down the particles
@ytop = 0 # Top half of the screen pixel
@ybottom = 480 # Screen Height
@xleft = 0 # First pixel to the left
@xright = 640 # Screen Width
@xgravity = 0.5 # Gravity for x axis (goes by tens)
@ygravity = 0.10 # Gravity for y axis (goes by tens)
@xoffset = -5 # offset for the x
@yoffset = -13 # offset for the y
@particles = []
@opacity = []
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
@screen_x = @event.screen_x
@screen_y = @event.screen_y
for i in 0...@maxparticless
@particles[i] = Sprite.new(viewport)
@particles[i].bitmap = RPG::Cache.fog("explosion", @hue)
@particles[i].blend_type = 1
@particles[i].y = @startingy
@particles[i].x = @startingx
@particles[i].z = @event.screen_z
@opacity[i] = 250
end
end
#------------------------------------------------------------------------
def update
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
offsetx = @event.screen_x - @screen_x
@screen_x = @event.screen_x
offsety = @event.screen_y - @screen_y
@screen_y = @event.screen_y
for i in 0...@maxparticless
@particles[i].z = @event.screen_z
if @particles[i].y <= @ytop
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x <= @xleft
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].y >= @ybottom
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x >= @xright
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @fade == 0
if @opacity[i] <= 0
@opacity[i] = @originalopacity
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
else
if @opacity[i] <= 0
@opacity[i] = 250
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
end
if @randomhue == 1
if @hue == 360
@hue = 0
end
@hue = @hue + 0.5
@particles[i].bitmap = RPG::Cache.fog("particle", @hue)
else
end
@opacity[i] = @opacity[i] - rand(30)
@leftright = rand(2)
if @leftright == 1
@particles[i].x = (@particles[i].x - (@xgravity / @slowdown)) + offsetx
else
@particles[i].x = (@particles[i].x + (@xgravity / @slowdown)) + offsetx
end
@particles[i].y = (@particles[i].y - (@ygravity / @slowdown)) + offsety
@particles[i].opacity = @opacity[i]
end
end
#------------------------------------------------------------------------
def dispose
for particle in @particles
particle.dispose
end
@particles = []
end
end
#===========================================================================
class Particle_Engine::Aura
#------------------------------------------------------------------------
def initialize(event, viewport)
@event = event
@s = 0 # Just a variable to save the math
@randomhue = 0 # Should the hue change ranomly 0 no 1 yes
@leftright = 0 # This is made to help the "fire" effect
@maxparticless = 20 # Wouldnt suggest going any higher then 478
@particles = [] # This just hold all of the sprites
@hue = 0 # Starting hue color
@slowdown = 0.5 # This will slow down the particless
@ytop = 0 # Top half of the screen pixel
@ybottom = 480 # Screen Height
@xleft = 0 # First pixel to the left
@xright = 640 # Screen Width
@xgravity = 0.5 # Gravity for x axis (goes by tens)
@ygravity = 0.10 # Gravity for y axis (goes by tens)
@opacity = [] # This is the opacity for every particles
@xoffset = -5 # offset for the x
@yoffset = -13 # offset for the y
@particles = []
@opacity = []
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
@screen_x = @event.screen_x
@screen_y = @event.screen_y
for i in 0...@maxparticless
@particles[i] = Sprite.new(viewport)
@particles[i].bitmap = RPG::Cache.fog("particle", @hue)
@particles[i].blend_type = 1
@particles[i].y = @startingy
@particles[i].x = @startingx
@particles[i].z = @event.screen_z
@opacity[i] = 250
end
end
#------------------------------------------------------------------------
def update
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
offsetx = @event.screen_x - @screen_x
@screen_x = @event.screen_x
offsety = @event.screen_y - @screen_y
@screen_y = @event.screen_y
for i in 0...@maxparticless
@particles[i].z = @event.screen_z
if @particles[i].y <= @ytop
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x <= @xleft
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].y >= @ybottom
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x >= @xright
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @fade == 0
if @opacity[i] <= 0
@opacity[i] = @originalopacity
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
else
if @opacity[i] <= 0
@opacity[i] = 250
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
end
if @randomhue == 1
if @hue == 360
@hue = 0
end
@hue = @hue + 0.5
@particles[i].bitmap = RPG::Cache.fog("particle", @hue)
else
end
@opacity[i] = @opacity[i] - rand(30)
@leftright = rand(2)
if @leftright == 1
@particles[i].x = (@particles[i].x - 2) + offsetx
@particles[i].y = (@particles[i].y - 2) + offsety
else
@particles[i].x = (@particles[i].x + 2) + offsetx
@particles[i].y = (@particles[i].y - 2) + offsety
end
#@particles[i].angle = @particles[i].angle + 1
@particles[i].opacity = @opacity[i]
end
end
#------------------------------------------------------------------------
def dispose
for particle in @particles
particle.dispose
end
@particles = []
end
end
#===========================================================================
class Particle_Engine::Soot # by BlueScope
#------------------------------------------------------------------------
# A soot effect for use on smokestaches or campfires.
#------------------------------------------------------------------------
def initialize(event, viewport)
@event = event
@leftright = 0 # This is made to help the "fire" effect
@fade = 0 # Opacity wont change at all 0 = yes, 1 = no
@originalopacity = 80 # this will only work if the one above is 0
@maxparticless = 20 # Wouldnt suggest going any higher then 478
@hue = 0 # Starting hue color
@slowdown = 0.5 # This will slow down the particless
@ytop = 0 # Top half of the screen pixel
@ybottom = 480 # Screen Height
@xleft = 0 # First pixel to the left
@xright = 640 # Screen Width
@xgravity = 0.5 # Gravity for x axis (goes by tens)
@ygravity = 0.10 # Gravity for y axis (goes by tens)
@xoffset = -5 # offset for the x
@yoffset = -15 # offset for the y
@particles = []
@opacity = []
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
@screen_x = @event.screen_x
@screen_y = @event.screen_y
for i in 0...@maxparticless
@particles[i] = Sprite.new(viewport)
@particles[i].bitmap = RPG::Cache.fog("smoke", @hue)
@particles[i].blend_type = 2
@particles[i].y = @startingy
@particles[i].x = @startingx
@particles[i].z = @event.screen_z
@opacity[i] = 100
end
end
#------------------------------------------------------------------------
def update
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
offsetx = @event.screen_x - @screen_x
@screen_x = @event.screen_x
offsety = @event.screen_y - @screen_y
@screen_y = @event.screen_y
for i in 0...@maxparticless
@particles[i].z = @event.screen_z
if @particles[i].y <= @ytop
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x <= @xleft
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].y >= @ybottom
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x >= @xright
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @fade == 0
if @opacity[i] <= 0
@opacity[i] = @originalopacity
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
else
if @opacity[i] <= 0
@opacity[i] = 250
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
end
if @randomhue == 1
if @hue == 360
@hue = 0
end
@hue = @hue + 0.5
@particles[i].bitmap = RPG::Cache.fog("smoke", @hue)
end
@opacity[i] = @opacity[i] - rand(5)
@leftright = rand(2)
if @leftright == 1
@particles[i].x = (@particles[i].x - (@xgravity / @slowdown)) + offsetx
else
@particles[i].x = (@particles[i].x + (@xgravity / @slowdown)) + offsetx
end
@particles[i].y = (@particles[i].y - (@ygravity / @slowdown)) + offsety
@particles[i].opacity = @opacity[i]
end
end
#------------------------------------------------------------------------
def dispose
for particle in @particles
particle.dispose
end
@particles = []
end
end
#===========================================================================
class Particle_Engine::SootSmoke # by BlueScope
#------------------------------------------------------------------------
# The mixed smoke and soot effect for use on putted-out campfires.
#------------------------------------------------------------------------
def initialize(event, viewport)
@event = event
@leftright = 0 # This is made to help the "fire" effect
@fade = 0 # Opacity wont change at all 0 = yes, 1 = no
@originalopacity = 80 # this will only work if the one above is 0
@maxparticless = 30 # Wouldnt suggest going any higher then 478
@hue = 0 # Starting hue color
@slowdown = 0.5 # This will slow down the particless
@ytop = 0 # Top half of the screen pixel
@ybottom = 480 # Screen Height
@xleft = 0 # First pixel to the left
@xright = 640 # Screen Width
@xgravity = 0.5 # Gravity for x axis (goes by tens)
@ygravity = 0.10 # Gravity for y axis (goes by tens)
@xoffset = -5 # offset for the x
@yoffset = -15 # offset for the y
@particles = []
@opacity = []
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
@screen_x = @event.screen_x
@screen_y = @event.screen_y
for i in 0...@maxparticless
@particles[i] = Sprite.new(viewport)
@particles[i].bitmap = RPG::Cache.fog("smoke", @hue)
if rand(6) < 3
@particles[i].blend_type = 1
else
@particles[i].blend_type = 2
end
@particles[i].y = @startingy
@particles[i].x = @startingx
@particles[i].z = @event.screen_z
@opacity[i] = 100
end
end
#------------------------------------------------------------------------
def update
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
offsetx = @event.screen_x - @screen_x
@screen_x = @event.screen_x
offsety = @event.screen_y - @screen_y
@screen_y = @event.screen_y
for i in 0...@maxparticless
@particles[i].z = @event.screen_z
if @particles[i].y <= @ytop
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x <= @xleft
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].y >= @ybottom
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x >= @xright
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @fade == 0
if @opacity[i] <= 0
@opacity[i] = @originalopacity
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
else
if @opacity[i] <= 0
@opacity[i] = 250
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
end
if @randomhue == 1
if @hue == 360
@hue = 0
end
@hue = @hue + 0.5
@particles[i].bitmap = RPG::Cache.fog("smoke", @hue)
else
end
@opacity[i] = @opacity[i] - rand(5)
@leftright = rand(2)
if @leftright == 1
@particles[i].x = (@particles[i].x - (@xgravity / @slowdown)) + offsetx
else
@particles[i].x = (@particles[i].x + (@xgravity / @slowdown)) + offsetx
end
@particles[i].y = (@particles[i].y - (@ygravity / @slowdown)) + offsety
@particles[i].opacity = @opacity[i]
end
end
#------------------------------------------------------------------------
def dispose
for particle in @particles
particle.dispose
end
@particles = []
end
end
#===========================================================================
class Particle_Engine::Rocket # by BlueScope
#------------------------------------------------------------------------
# A trail for fast moving objects with a smoke output (like rockets)
#------------------------------------------------------------------------
def initialize(event, viewport)
@event = event
@leftright = 0 # This is made to help the "fire" effect
@fade = 0 # Opacity wont change at all 0 = yes, 1 = no
@originalopacity = 80 # this will only work if the one above is 0
@maxparticless = 60 # Wouldnt suggest going any higher then 478
@hue = 0 # Starting hue color
@slowdown = 0.5 # This will slow down the particless
@ytop = 0 # Top half of the screen pixel
@ybottom = 480 # Screen Height
@xleft = 0 # First pixel to the left
@xright = 640 # Screen Width
@xgravity = 0.5 # Gravity for x axis (goes by tens)
@ygravity = 0.10 # Gravity for y axis (goes by tens)
@xoffset = -5 # offset for the x
@yoffset = -15 # offset for the y
@particles = []
@opacity = []
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
for i in 0...@maxparticless
@particles[i] = Sprite.new(viewport)
@particles[i].bitmap = RPG::Cache.fog("smoke", @hue)
@particles[i].blend_type = 1
@particles[i].y = @startingy
@particles[i].x = @startingx
@particles[i].z = @event.screen_z - 1
@opacity[i] = 100
end
end
#------------------------------------------------------------------------
def update
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
for i in 0...@maxparticless
@particles[i].z = @event.screen_z - 1
if @particles[i].y <= @ytop
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x <= @xleft
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].y >= @ybottom
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x >= @xright
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @fade == 0
if @opacity[i] <= 0
@opacity[i] = @originalopacity
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
else
if @opacity[i] <= 0
@opacity[i] = 250
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
end
if @randomhue == 1
if @hue == 360
@hue = 0
end
@hue = @hue + 0.5
@particles[i].bitmap = RPG::Cache.fog("smoke", @hue)
end
@opacity[i] = @opacity[i] - rand(5)
@leftright = rand(2)
if @leftright == 1
@particles[i].x = (@particles[i].x - (@xgravity / @slowdown))
else
@particles[i].x = (@particles[i].x + (@xgravity / @slowdown))
end
#@particles[i].y = (@particles[i].y - (@ygravity / @slowdown))
@particles[i].opacity = @opacity[i]
end
end
#------------------------------------------------------------------------
def dispose
for particle in @particles
particle.dispose
end
@particles = []
end
end
#===========================================================================
class Particle_Engine::FixedTeleport # by BlueScope
#------------------------------------------------------------------------
# The fixed teleport effect
#------------------------------------------------------------------------
def initialize(event, viewport)
@event = event
@randomhue = 1 # should the hue change ranomly 0 no 1 yes
@leftright = 0 # This is made to help the "fire" effect
@maxparticless = 10 # Wouldnt suggest going any higher then 478
@hue = 40 # Starting hue color
@slowdown = 0.5 # This will slow down the particless
@ytop = -480 # Top half of the screen pixel
@ybottom = 480 # Screen Height
@xleft = 0 # First pixel to the left
@xright = 640 # Screen Width
@xgravity = 0.5 # Gravity for x axis (goes by tens)
@ygravity = 0.10 # Gravity for y axis (goes by tens)
@xoffset = -8 # offset for the x
@yoffset = -15 # offset for the y
@particles = []
@opacity = []
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
@screen_x = @event.screen_x
@screen_y = @event.screen_y
for i in 0...@maxparticless
@particles[i] = Sprite.new(viewport)
@particles[i].bitmap = RPG::Cache.fog("portal", @hue)
@particles[i].blend_type = 1
@particles[i].y = @startingy
@particles[i].x = @startingx
@particles[i].z = @event.screen_z
@opacity[i] = 250
end
end
#------------------------------------------------------------------------
def update
@startingx = @event.screen_x + @xoffset - 16
@startingy = @event.screen_y + @yoffset - 16
offsetx = @event.screen_x - @screen_x
@screen_x = @event.screen_x
offsety = @event.screen_y - @screen_y
@screen_y = @event.screen_y
for i in 0...@maxparticless
@particles[i].z = @event.screen_z
if @particles[i].y <= @ytop
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x <= @xleft
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].y >= @ybottom
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x >= @xright
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @fade == 0
if @opacity[i] <= 0
@opacity[i] = @originalopacity
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
else
if @opacity[i] <= 0
@opacity[i] = 250
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
end
if @randomhue == 1
if @hue == 360
@hue = 0
end
@hue = @hue + 0.5
@particles[i].bitmap = RPG::Cache.fog("wideportal", @hue)
else
end
@opacity[i] = @opacity[i] - rand(20)
@leftright = rand(2)
@particles[i].x = @particles[i].x + offsetx
@particles[i].y = @particles[i].y - 3 + offsety
@particles[i].opacity = @opacity[i]
end
end
#------------------------------------------------------------------------
def dispose
for particle in @particles
particle.dispose
end
@particles = []
end
end
#===========================================================================
class Particle_Engine::Smokescreen # by BlueScope
#------------------------------------------------------------------------
# A smokescreen like caused through smoke grenades
#------------------------------------------------------------------------
def initialize(event, viewport)
@event = event
@leftright = 0 # This is made to help the "fire" effect
@fade = 0 # Opacity wont change at all 0 = yes, 1 = no
@originalopacity = 80 # this will only work if the one above is 0
@maxparticless = 450 # Wouldnt suggest going any higher then 478
@hue = 0 # Starting hue color
@slowdown = 0.2 # This will slow down the particless
@ytop = 0 # Top half of the screen pixel
@ybottom = 480 # Screen Height
@xleft = 0 # First pixel to the left
@xright = 640 # Screen Width
@xgravity = 0.8 # Gravity for x axis (goes by tens)
@ygravity = 0.8 # Gravity for y axis (goes by tens)
@xoffset = -5 # offset for the x
@yoffset = -15 # offset for the y
@particles = []
@opacity = []
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
@screen_x = @event.screen_x
@screen_y = @event.screen_y
for i in 0...@maxparticless
@particles[i] = Sprite.new(viewport)
@leftright = rand(3)
if @leftright < 1
@particles[i].bitmap = RPG::Cache.fog("explosionsmoke", @hue)
@opacity[i] = 1
else
@particles[i].bitmap = RPG::Cache.fog("smoke", @hue)
@opacity[i] = 100
end
@particles[i].blend_type = 1
@particles[i].y = @startingy
@particles[i].x = @startingx
@particles[i].z = @event.screen_z
end
end
#------------------------------------------------------------------------
def update
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
offsetx = @event.screen_x - @screen_x
@screen_x = @event.screen_x
offsety = @event.screen_y - @screen_y
@screen_y = @event.screen_y
for i in 0...@maxparticless
@particles[i].z = @event.screen_z
if @particles[i].y <= @ytop
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x <= @xleft
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].y >= @ybottom
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x >= @xright
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @fade == 0
if @opacity[i] <= 0
@opacity[i] = @originalopacity
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
else
if @opacity[i] <= 0
@opacity[i] = 250
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
end
if @randomhue == 1
if @hue == 360
@hue = 0
end
@hue = @hue + 0.5
@leftright = rand(3)
if @leftright > 1
@particles[i].bitmap = RPG::Cache.fog("smoke", @hue)
else
@particles[i].bitmap = RPG::Cache.fog("explosionsmoke", @hue)
end
end
@opacity[i] = @opacity[i] - rand(5)
multiple = 1.7
@leftright = rand(2)
if @leftright == 1
@particles[i].x = (@particles[i].x - (@xgravity * multiple) / @slowdown) + offsetx
else
@particles[i].x = (@particles[i].x + (@xgravity * multiple) / @slowdown) + offsetx
end
@leftright = rand(2)
if @leftright == 1
@particles[i].y = (@particles[i].y - (@ygravity * multiple) / @slowdown) + offsety
else
@particles[i].y = (@particles[i].y + (@ygravity * multiple) / @slowdown) + offsety
end
@particles[i].opacity = @opacity[i]
end
end
#------------------------------------------------------------------------
def dispose
for particle in @particles
particle.dispose
end
@particles = []
end
end
#===========================================================================
class Particle_Engine::Flare # by BlueScope
#------------------------------------------------------------------------
# A flare effect to lay over magic objects
#------------------------------------------------------------------------
def initialize(event, viewport)
@event = event
@s = 0 # Just a variable to save the math
@randomhue = 0 # Should the hue change randomly 0 no 1 yes
@leftright = 0 # This is made to help the "fire" effect
@maxparticless = 30 # Wouldnt suggest going any higher then 478
@particles = [] # This just hold all of the sprites
@hue = 10 # Starting hue color
@slowdown = 0.5 # This will slow down the particless
@ytop = 0 # Top half of the screen pixel
@ybottom = 480 # Screen Height
@xleft = 0 # First pixel to the left
@xright = 640 # Screen Width
@xgravity = 0.5 # Gravity for x axis (goes by tens)
@ygravity = 0.50 # Gravity for y axis (goes by tens)
@opacity = [] # This is the opacity for every particles
@xoffset = -5 # offset for the x
@yoffset = -12 # offset for the y
@particles = []
@opacity = []
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
@screen_x = @event.screen_x
@screen_y = @event.screen_y
for i in 0...@maxparticless
@particles[i] = Sprite.new(viewport)
@particles[i].bitmap = RPG::Cache.fog("particle", @hue)
@particles[i].blend_type = 1
@particles[i].y = @startingy
@particles[i].x = @startingx
@particles[i].z = @event.screen_z
@opacity[i] = 255
end
end
#------------------------------------------------------------------------
def update
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
offsetx = @event.screen_x - @screen_x
@screen_x = @event.screen_x
offsety = @event.screen_y - @screen_y
@screen_y = @event.screen_y
for i in 0...@maxparticless
@particles[i].z = @event.screen_z
if @particles[i].y <= @ytop
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x <= @xleft
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].y >= @ybottom
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x >= @xright
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @fade == 0
if @opacity[i] <= 0
@opacity[i] = @originalopacity
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
else
if @opacity[i] <= 0
@opacity[i] = 250
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
end
if @randomhue == 1
if @hue == 360
@hue = 0
end
@hue = @hue + 0.5
@particles[i].bitmap = RPG::Cache.fog("particle", @hue)
else
end
@opacity[i] = @opacity[i] - rand(30)
@leftright = rand(2)
if @leftright == 1
@particles[i].x = (@particles[i].x - 2) + offsetx
@particles[i].y = (@particles[i].y - 2) + offsety
else
@particles[i].x = (@particles[i].x + 2) + offsetx
@particles[i].y = (@particles[i].y - 2) + offsety
end
#@particles[i].angle = @particles[i].angle + 1
@particles[i].opacity = @opacity[i]
end
end
#------------------------------------------------------------------------
def dispose
for particle in @particles
particle.dispose
end
@particles = []
end
end
#===========================================================================
class Particle_Engine::Splash # by BlueScope
#------------------------------------------------------------------------
# This is a waterfall mist effect (use it at the lowest waterfall tile)
#------------------------------------------------------------------------
def initialize(event, viewport)
@event = event
@s = 0 # Just a variable to save the math
@randomhue = 0 # Should the hue change randomly 0 no 1 yes
@leftright = 0 # This is made to help the "fire" effect
@maxparticless = 30 # Wouldnt suggest going any higher then 478
@particles = [] # This just hold all of the sprites
@hue = 255 # Starting hue color
@slowdown = 0.5 # This will slow down the particless
@ytop = 0 # Top half of the screen pixel
@ybottom = 480 # Screen Height
@xleft = 0 # First pixel to the left
@xright = 640 # Screen Width
@xgravity = 0.5 # Gravity for x axis (goes by tens)
@ygravity = 0.50 # Gravity for y axis (goes by tens)
@opacity = [] # This is the opacity for every particles
@xoffset = -5 # offset for the x
@yoffset = -12 # offset for the y
@particles = []
@opacity = []
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
@screen_x = @event.screen_x
@screen_y = @event.screen_y
for i in 0...@maxparticless
@particles[i] = Sprite.new(viewport)
@particles[i].bitmap = RPG::Cache.fog("smoke", @hue)
@particles[i].blend_type = 1
@particles[i].y = @startingy
@particles[i].x = @startingx
@particles[i].z = @event.screen_z
@opacity[i] = 255
end
end
#------------------------------------------------------------------------
def update
@startingx = @event.screen_x + @xoffset
@startingy = @event.screen_y + @yoffset
offsetx = @event.screen_x - @screen_x
@screen_x = @event.screen_x
offsety = @event.screen_y - @screen_y
@screen_y = @event.screen_y
for i in 0...@maxparticless
@particles[i].z = @event.screen_z
if @particles[i].y <= @ytop
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x <= @xleft
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].y >= @ybottom
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @particles[i].x >= @xright
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
if @fade == 0
if @opacity[i] <= 0
@opacity[i] = @originalopacity
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
else
if @opacity[i] <= 0
@opacity[i] = 250
@particles[i].y = @startingy + @yoffset
@particles[i].x = @startingx + @xoffset
end
end
@opacity[i] = @opacity[i] - rand(30)
@leftright = rand(2)
if @leftright == 1
@particles[i].x = (@particles[i].x - 4) + offsetx
@particles[i].y = (@particles[i].y - 2) + offsety
else
@particles[i].x = (@particles[i].x + 4) + offsetx
@particles[i].y = (@particles[i].y - 2) + offsety
end
@particles[i].opacity = 50 #@opacity[i]
end
end
#------------------------------------------------------------------------
def dispose
for particle in @particles
particle.dispose
end
@particles = []
end
end
end
#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
# This class deals with events. It handles functions including event page
# switching via condition determinants, and running parallel process events.
# It's used within the Game_Map class.
#==============================================================================
class Game_Event < Game_Character
#--------------------------------------------------------------------------
attr_accessor :pe_refresh
#--------------------------------------------------------------------------
alias nf_particles_game_map_initialize initialize
alias nf_particles_game_map_refresh refresh
#--------------------------------------------------------------------------
def initialize(map_id, event)
@pe_refresh = false
nf_particles_game_map_initialize(map_id, event)
end
#--------------------------------------------------------------------------
def refresh
nf_particles_game_map_refresh
@pe_refresh = true
end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc.
# It's used within the Scene_Map class.
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
alias nf_particles_spriteset_map_init_viewports init_viewports
alias nf_particles_spriteset_map_dispose dispose
alias nf_particles_spriteset_map_update_character_sprites update_character_sprites
alias nf_particles_spriteset_map_update update
#--------------------------------------------------------------------------
def init_viewports
nf_particles_spriteset_map_init_viewports
@particle_engine = Particle_Engine.new(@viewport1)
end
#--------------------------------------------------------------------------
def dispose
nf_particles_spriteset_map_dispose
@particle_engine.dispose
end
#--------------------------------------------------------------------------
def update_character_sprites
nf_particles_spriteset_map_update_character_sprites
for sprite in @character_sprites
next unless sprite.character.is_a?(Game_Event)
if sprite.character.pe_refresh == true
sprite.character.pe_refresh = false
@particle_engine.remove_effect(sprite.character)
@particle_engine.add_effect(sprite.character)
end
end
end
#--------------------------------------------------------------------------
def update
nf_particles_spriteset_map_update
@particle_engine.update
end
end
#------------------------------------------------------------------------------
# * End SDK Enable Test
#------------------------------------------------------------------------------
endDownload e ficha técnica
- Download (clique com o botão esquerdo do mouse ou toque no link)
- Desenvolvedor, publisher e/ou distribuidor: Near Fantastica
- Sistema(s): Windows 98/98SE/Me/2000/XP/Vista/7
- Licença: Grátis
- Categoria: Programação XP
- Tags: Em revisão, RPG Maker XP
- Adicionado por: LichKing
- Acessos: 404
Observação: se você gostou deste post ou ele lhe foi útil de alguma forma, por favor considere apoiar financeiramente a Gaming Room. Fico feliz só de ajudar, mas a contribuição do visitante é muito importante para que este site continua existindo e para que eu possa continuar provendo este tipo de conteúdo e melhorar cada vez mais. Acesse aqui e saiba como. Obrigado!
