class Scene_Map alias prex_particles_s_map_update update def initialize @particles = [] end def update for particle in @particles next unless particle particle.update particle.dispose if particle.particles.size <= 0 end prex_particles_s_map_update end def add_effect(id) case id when 'test' @particles.push(ParticleEffect.new("smash", 50, 0, 4, 250, 32, 32, 10, 10)) end end end class ParticleEffect attr_reader :particles def initialize(name, max, hue, slowdown, opacity, start_x, start_y, x_grav, y_grav) @name = name @max = max @hue = hue @slowdown = slowdown @hi_opacity = opacity @start_x = start_x @start_y = start_y @x_grav = x_grav @y_grav = y_grav @screen = [0, 0, 640, 480] @particles = [] for i in 0...@max @particles[i] = Sprite.new @particles[i].bitmap = RPG::Cache.particles(@name, @hue) @particles[i].blend_type = 1 @particles[i].y = $startingy @particles[i].x = $startingx @particles[i].opacity = @hi_opacity end end def update for i in 0...@particles.size if @particles[i].y <= @screen[1] or @particles[i].x <= @screen[0] or @particles[i].y >= @screen[3] or @particles[i].x >= @screen[2] @particles[i].dispose @particles[i] = nil @particles.compact next end @hue = 0 if @hue == 360 @hue += 0.5 @particles[i].bitmap = RPG::Cache.particle(@name, @hue) if rand(100) <= 70 if @particles[i].opacity <= 0 @particles[i].dispose @particles[i] = nil @particles.compact next end @particles[i].opacity -= rand(10) @particles[i].x = (@particles[i].x - (@x_grav / @slowdown) - rand(10)) @particles[i].y = (@particles[i].y - (@y_grav / @slowdown) - rand(10)) end end end end module RPG module Cache def self.particles(filename, hue) self.load_bitmap("Graphics/Particles/" + filename, hue) end end end