Zippy-Egoboo Home EgoWiki > Documentation > MakingZippyObjects > ZippyCharacterType > ZippyProfiles > ZippyParticles EgoWiki webs:
Main | TWiki | Know | Sandbox
Documentation . { Changes | Index | Search | Go }
"particles" are 2D sprites that move in predictable (read: not scripted) patterns. They may attach to a vertex on a model, fall freely with a starting velocity and a maximum speed of travel, or follow a character limited by turn radius. The sprite graphics may be animated, but individual frames must be taken from a central particle bitmap (at the moment, basicdat/particles.bmp); therefore, the particle frames are all of uniform size, and are numbered from left to right, top to bottom. A final property of particles is that each particle must belong to a single character.

Particles are spawned using shared particle types, which may be created in the following way:

type = PrtType{
   [field = value,]
   -- ...
}

Particles can be spawned using the spawn_particle member function of the Character object. Once spawned, they may be "referenced" using the "ref_particle" function as follows:

ref = ref_particle(order)

"order" is a number specifying how many particles have been spawned since the desired particle was (including the desired particle), and the function returns an object that represents that particle. The following example references the last particle spawned:

ref = ref_particle(1)

Particle references have the following members:

Member Type Description
type particle type The particle type used to spawn this particle
position vector? The position of this particle
velocity vector? The velocity of this particle
owner character The character that spawned this particle
attached_to character The character to which this particle is attached (or nil if it is not)
vertex number The index of the grip vertex from which this particle gets its position
target character If the particle has a target, this is it
time number The number of updates left for this particle
image number The index of the current sprite frame
angle number (degrees) The direction the particle is facing
in_view boolean If non-nil, the particle is currently on the screen
over_tile number The index of the tile the particle is above
level number The height of the particle
size number The current size of the particle
valid function (no args) Returns non-nil if the referenced particle is valid. Otherwise, the other fields will not work
kill function (no args) Removes the particle from the game

Any of the above fields may be set, but it's usually not useful to do so. If you ever need to set one of the above fields, it will probably be either "position," "owner," or "target."

The fields of the type constructor are described in the table below. Any additional fields will be retained in the type object.

Field Type Default Meaning
render_type render type PRTRENDER_LIGHT The method used for drawing the particle (see #RenderTypes)
image_start number 0 The starting frame of the particle graphic
frame_rate number 0 The animation speed in frames per update (0 for no animation)
frames number 0 The number of frames in the particle animation (or 0 for no animation)
speed number 0 The maximum speed in map tiles per update
velocity_rand vector <0, 0, 0> A random number is generated for each dimension, and the resulting vector is multiplied with this one component-wise and added to the velocity specified in the particle spawning function to get the initial velocity of each particle of this type
face_velocity boolean nil If non-nil, the particle is rotated to face in the direction of its motion
position_rand vector <0, 0, 0> Same semantics as velocity_rand, but applied to the initial position of the vector
vertex number [-1, 128] -1 Default starting vertex (-1 for free motion)
end_on_water boolean nil If non-nil, the particle dies when it hits water
end_on_wall boolean nil If non-nil, the particle dies when it hits a wall
end_on_bump boolean nil If non-nil, the particle dies when it hits a character
end_on_ground boolean nil If non-nil, the particle dies when it hits the ground
end_on_last_frame boolean nil If non-nil, the particle dies when it finishes its animation
end_time number [-1, infinity] -1 The lifetime of the particle (-1 for indefinite)
homing (not implemented) boolean nil If non-nil, and if the particle has a target, the particle follows its target
needs_target boolean nil If non-nil, the particle will not spawn without a target
damage (deprecated)
damage_type (deprecated)
is_light boolean nil If non-nil, the particle acts as a light source
light_falloff number [0, infinity] 0 The distance at which the light source falls off
light_level number [0, 1] 0 The level of light the particle provides
rotation range (degrees) [0, 0] A rotation rate is chosen randomly from this range
angle range (degrees) [0, 0] A starting angle is chosen randomly from this range
bounce_dampen number [0, 1] 1 The elasticity of collisions is scaled by this number
air_dampen number [0, 1] 1 The rate of travel through air is scaled by this number
bump_size number [0, infinity] 0 The size of the particle for collisions
bump_height number [0, infinity] 0 The height of the particle for collisions
size number [0, infinity] 25000 The starting size of the particle
size_add number 0 How much to add to the size of the particle each update

Render Types

The following table describes the different values for "render_type" in the particle type constructor (screenshots forthcoming):

Value Meaning
PRTRENDER_SOLID The particle graphic is drawn directly over the rest of the scene, with no blending
PRTRENDER_TRANS The particle graphic is blended with the colors in the scene below it
PRTRENDER_LIGHT The particle graphic has its color values added to those of the scene below it, increasing the brightess of those pixels

-- ElminI - 01 Feb 2004

Topic ZippyParticles . { Edit | Attach | Ref-By | Printable | Diffs | r1.3 | > | r1.2 | > | r1.1 | More }
Revision r1.3 - 02 Feb 2004 - 05:16 GMT - ElminI
Parents: WebHome > MakingZippyObjects > ZippyCharacterType > ZippyProfiles
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding EgoWiki? Send feedback.