Particles for beginners
Author: | ben mercer
|
Submitted: | 11th March, 2006
|
Views: | 7045
| Rated: |
|
|
I'm going to talk about creating particle effects in mmf. There are a lot of click games that have made attempts at particle effects that have looked poor (yes, including some of mine). I'm sharing some of my knowledge that i have built up from a few years of experience to get you particle novices on the right track
It might also be worth looking at for some of the mmf veterans too.
This article explains how to get started making some simple explosion, fire and spark effects.
1. Quality, Graphics and performance
====================================
The first thing you need to think about when making a particle effect in mmf is the quality of the effect versus the performance (cpu). For example, if you were only going to have a maximum of about one or two instances of an explosion effect in your frame at a time, then you can afford to make it detailed.
Detail relies on how many particles there are to an effect. An explosion with 4 particles will be low quality, but fast. An explosion with 40 particles will look great, but slow the game down if too many go off at once.
Obviously there is the sprite aspect of the particles themselves that can be controlled by you with no hits to performance. here are few tips when drawing particle sprites that i have learned from experience:
- Make sure you fade the edges of the sprite to an appropriate colour e.g. fire- orangey-brown (NOT BLACK), smoke- darkish grey etc.
- If appropriate, dither the edges of the sprite- the airbrush tool in paint can be used for this (this is a cheap replacement for an alpha channel )
- For bright effects such as fire, make sure the image is quite highly saturated (coloured)- otherwise it ends up looking like dust.
- For dust/smoke effects use low image saturation.
- The best particles are animated- create about 5-10 frames for your particle e.g. an fire particle would be bright at first then die down a bit.
Sparks can be look really nice if done properly. Create 10 frames for your spark's animation, and rotate it through 32 directions. Make the sprite go from a small dot, to a long spark (as if it is in motion). Now heres the clever stuff:
always
- force animation frame of spark to int(speed(spark)/10)
The spark will now appear to motion blur when moving faster.
2. Particle Motion
==================
I know a lot of people hate default movement, but in most cases it is entirely suitable for particles, because they need to have a minimal hit on performance. I use bouncing ball movement for most of my particles.
Look at a lot of click games today and you'll find particles that are created and move in a random direction, but with a FIXED SPEED. I don't think many people realise that particle effects can be made to look a lot better if you create a simple event:
(particle)flag 0 is off
- Set (particle)flag 0
+ Set (particle) speed to random(max speed)
+ Set (particle) value Z to speed
This simulates the idea that some particles may be moving out towards the screen instead of along just the x and y axis.
The value Z is used in this event:
Always
- Layer object- sort by value Z
Which sorts the particles so that the explosion particles supposedly moving out towards the screen will be on top, so you don't get this terrible looking 'last object created lies on top' effect.
There is the factor of what happens when particles collide with walls. Obviously you don't want fire to shoot straight through an obstacle, but it doesn't look too good if fire particles bounce perfectly off a wall. For fire, i normally use this:
Fire particle is overlapping backdrop
-add 2 to lifetime
-set speed to speed - 5
This makes the particle slow to a stop quickly but smoothly. It also makes the particle fade faster (you will learn about this in section 3).
For spark particles, you want them to bounce off walls, so you just use a simple event:
spark collides with obstacle
-bounce
-add 10 to lifetime
Which makes the particle bounce off the wall, and fade a small amount, so that bouncing multiple times will destroy the particle (you will learn about this in section 3).
3. Particle Lifetime/Destruction
================================
It seems like an easy way out to say:
(Particle) is stopped
-destroy
but this is also a bad way to do it. You should employ a couple of alterable values, one named lifetime and the other named lifemax. Lifemax is the amount of time before your particle is destroyed (in 1/50th sec). If you create these events:
Always- add 1 to lifetime
Lifetime>= lifemax- destroy
Then you have created a system whereby each particle will be destoyed after a set period of time relative to its creation. You can also make the particles fade out with this event:
Always- set semi transparency to lifetime/lifemax * 128
Evidently, this makes the system versatile because you could make particles with a random lifespan.
Other ideas for effects
=======================
Once you're fairly savvy with the concepts intoduced in this article, here are some other ideas you may want to start experimenting with.
- Explosion debris: works the same way as a normal particle but creates fire particles from it's position to give a flaming depris effect.
- Custom movement particles: This can be as simple as making a particle move left and right using a sin(lifetime) expression to simulate bubble motion.
- MMF2... In mmf2 additive and subtractive transparency will be available! Additive transparency is great for fire, explosions whereas subtractive is good for dark smoke effects and blood.
|
|
ben mercerPossibly Insane
Registered 11/07/2004
Points 2538
|