Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Near's Particle Engine

Rye

Member

Very simeple question, how can I use Near's Particle Engine without having to use SDK? If anyone knows and would tell me how, that would be very helpful, thank you very much. (And I am sorry if this has a very obvious answer and I just overlooked it.)
 
Delete the SDK lines, which are, I believe, something like:

Code:
if SDK.state(script name) == true
and
Code:
SDK.log(stuff)

Make sure you delete their end statements as well.
 
@Danie: Near used a lot of SDK commands inside, I don't think it'd work without...

@Topic: Well, the default method to make a script SDK-independent is to delete the lines Daniel mentioned, then testplay and check for the error, which should be an undefined method error. Go in SDK (word document or something) and search for def [insert missing method here], then copy it somewhere above main, above the particle script, below the default scripts, then testplay again and redo the process until you covered every method the script uses.

PS: I remember someone calling me 'Mr. Particle Engine' in IRC... was that you Rye? ^_^
 

Rye

Member

Daniel's way didn't work, I already tried that. But I really would rather have this be easy and have the version Ryanwh mentioned, I had it once, but it's long gone now. And BlueScope, I don't think that was me.
 

arev

Sponsor

Code:
module RPG
module Cache
def self.particles(filename, hue)
self.load_bitmap("Graphics/Particles/", filename, hue)
end
end
end

class ParticleEffect
class Particle < RPG::Sprite
attr_accessor :accel_x
attr_accessor :accel_y
def initialize(accel_x, accel_y, viewport = Viewport.new(0, 0, 640, 480))
super(viewport)
@accel_x = accel_x
@accel_y = accel_y
end
end
attr_reader :particles
def initialize(name, max, hue, add_hue, duration, opacity, start_x, start_y, speed,
accel_x, accel_y, x_grav, y_grav, blend, mag = 0)
@name = name
@max = max
@hue = hue
@add_hue = add_hue
@hi_opacity = opacity
@duration = duration
@start_x = start_x
@start_y = start_y
@speed = speed
@start_accel_x = accel_x
@start_accel_y = accel_y
@x_grav = x_grav
@y_grav = y_grav
@mag = mag
@screen = [0, 0, 640, 480]
@particles = []
for i in 0...@max
@particles[i] = Particle.new(@start_accel_x + @speed * (rand(10)-5),
@start_accel_y + @speed * (rand(10)-5))
@particles[i].zoom_x = 0.5 * @mag + 0.5
@particles[i].zoom_y = 0.5 * @mag + 0.5
@particles[i].bitmap = RPG::Cache.particles(@name, @hue)
@particles[i].blend_type = blend
@particles[i].x = @start_x
@particles[i].y = @start_y
@particles[i].opacity = @hi_opacity
end
end
def update
for i in 0...@particles.compact.size
next unless @particles[i]
@hue = 0 if @hue == 360
@hue += @add_hue
@particles[i].bitmap = RPG::Cache.particles(@name, @hue)
@particles[i].accel_x -= @x_grav
@particles[i].x += @particles[i].accel_x
@particles[i].accel_y -= @y_grav
@particles[i].y += @particles[i].accel_y
@particles[i].opacity -= (@hi_opacity / @duration).ceil
if @particles[i].opacity <= 0
@particles[i].dispose
@particles[i] = nil
@particles.compact
next
end
end
end
end

class Scene_Map
attr_accessor :particles
alias prex_particles_s_map_update update
def initialize
@particles = []
end

def update
prex_particles_s_map_update
for particle in @particles
next unless particle
particle.update
particle.dispose if particle.particles.size <= 0
end
end
def add_effect(id)
case id
when 'sign01'
@particles.push(ParticleEffect.new("sign01", 5, 0, 0, 25, 200, $particle_x-53, $particle_y-53, 1, 0, 0, 0, 0, 1))
when 'sign02'
@particles.push(ParticleEffect.new("sign02", 5, 0, 0, 25, 200, $particle_x-53, $particle_y-53, 1, 0, 0, 0, 0, 1))
when 'sign03'
@particles.push(ParticleEffect.new("sign03", 5, 0, 0, 25, 200, $particle_x-53, $particle_y-53, 1, 0, 0, 0, 0, 1))
when 'sign04'
@particles.push(ParticleEffect.new("sign04", 15, 0, 0, 25, 255, $particle_x-8, $particle_y-24, 1, 0, 0, 0, 0, 1))
when 'fire'
@particles.push(ParticleEffect.new("fire", 15, 45, 0, 15, 200, $particle_x-6, $particle_y-24, 0.3, 0, 0, -0.1, 0.1, 1))
when 'rainbow'
@particles.push(ParticleEffect.new("fire", 15, 45, 2, 35, 255, $particle_x-4, $particle_y-24, 1, 0, 0, 0, 0, 1))
when 'sparks'
@particles.push(ParticleEffect.new("fire", 25, 60, 0, 15, 255, $particle_x-4, $particle_y-24, 1, 0, -1, 0, -0.5, 1))
when 'smoke'
@particles.push(ParticleEffect.new("smoke", 10, 0, 0, 15, 64, $particle_x-6, $particle_y-24, 0.1, 1, -1, 0.1, 0.1, 1))
when 'campfire'
@particles.push(ParticleEffect.new("fire", 15, 45, 0, 15, 200, $particle_x-6, $particle_y-24, 0.2, 0, 0, -0.1, 0.1, 1))
@particles.push(ParticleEffect.new("smoke", 10, 0, 0, 15, 128, $particle_x-6, $particle_y-32, 0.1, 1, -1, 0.1, 0.1, 1))
when 'candle'
@particles.push(ParticleEffect.new("fire", 1, 60, 0, 10, 250, $particle_x - 5, $particle_y - 18, 0, 0, 0, 0, 0.2, 1))
when 'mist'
@particles.push(ParticleEffect.new("star", 5, 0, 0, 15, 128, $particle_x-32, $particle_y-48, 1, 0, 0, 0, 0, 1))
when 'darkness'
@particles.push(ParticleEffect.new("star", 5, 0, 0, 15, 128, $particle_x-32, $particle_y-48, 1, 0, 0, 0, 0, 2))
@particles.push(ParticleEffect.new("fire", 2, 60, 0, 15, 250, $particle_x-4, $particle_y - 32, 0.2, 0, 0, 0, 0, 1, 1))
when 'aura'
@particles.push(ParticleEffect.new("fire", 5, 0, 4, 15, 250, $particle_x-4, $particle_y - 8, 0.2, 0.1, 0.1, -0.1, 0.2, 1))
when 'portal'
@particles.push(ParticleEffect.new("wideportal", 1, 270, 0, 20, 200, $particle_x - 32, $particle_y - 48, 0, 0, -2, 0, 0.2, 1, 1))
end
end
end

this is almost original script :] created by Pinkman, fixed by Sylver, and then by me. it's the only version I have.
you call the particles with (example):
Code:
$scene.add_effect('mist')
this will call the "mist" effect, described at the end. each effect uses graphics from "Graphics/Particles" folder (it can be changed). I guess you can use particles graphics from the SDK version, but if you'll need some other just ask :)
 

arev

Sponsor

well, the line I gave you displays the desired effect once. the effects are initialized with many parameters (thir descriptive names are in the def initialize). this way you can easily make o spark effect, or something similar. but the fun part is when you combine more effects (thats my idea ^_^). here's an example:
make an event with something like this:
call script:
Code:
character = get_character(-1)
$cx = character.screen_x
$cy = character.screen_y - 32
wait: 2
Code:
character = get_character(0)
if @t == nil
@t = 0.0
else
@t += 0.5
end
for i in 1..6
@a = @t + i*60
$particle_x=$cx-Math.cos(@a)*32
$particle_y=$cy-Math.sin(@a)*32
$scene.add_effect('darkness')
end
wait: 2
Code:
character = get_character(0)
if @t == nil
@t = 0.0
else
@t += 0.5
end
for i in 1..6
@a = @t + i*60
$particle_x=$cx-Math.cos(@a)*32
$particle_y=$cy-Math.sin(@a)*32
$scene.add_effect('darkness')
end
wait: 2
Code:
character = get_character(0)
if @t == nil
@t = 0.0
else
@t += 0.5
end
for i in 1..6
@a = @t + i*60
$particle_x=$cx-Math.cos(@a)*32
$particle_y=$cy-Math.sin(@a)*32
$scene.add_effect('darkness')
end
wait: 2
Code:
character = get_character(0)
if @t == nil
@t = 0.0
else
@t += 0.5
end
for i in 1..6
@a = @t + i*60
$particle_x=$cx-Math.cos(@a)*32
$particle_y=$cy-Math.sin(@a)*32
$scene.add_effect('mist')
end

this is one of my best effects so use it only as e tutorial :p

the particles graphics you'll need are attached:
http://www.rmxp.org/forums/attachment.php?attachmentid=498&stc=1&d=1154461769
http://www.rmxp.org/forums/attachment.php?attachmentid=499&stc=1&d=1154461769
hope I didn't forget anything ^_^

edit: I've prepared a small demo with three of my effects:
http://www.calamity.cba.pl/files/partikle.rar
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top