Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Particle effects  (Read 4522 times)

0 Members and 1 Guest are viewing this topic.

SBOVIS

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 404
  • FORGET REALITY SURRENDER TO YOUR DARKEST DREAMS
    • View Profile
    • LIMBO of the LOST
Particle effects
« on: November 02, 2004, 11:39:05 AM »

This maybe a silly question but hey ho I will ask it anyway.

I have in the past used 3D engines that use particles for effects like smoke, fire, mist, fog etc

Using transparency values and sprites is it possible to create an emitter that emits particles that could resemble smoke, fire, magic portals etc

If so are there any sample scripts of this, I have seen the weather effect with snow and rain and thought this could be used in a smaller way for other effects.


A tutorial and sample scripts would be great if this is possible.


Many thanks.

 >:D
Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

organican

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 74
    • View Profile
Re: Particle effects
« Reply #1 on: November 02, 2004, 06:54:19 PM »

I also thought about this one..

If you change the transparency and or colors every fifteen milliseconds or whatever,
it should really get flashy.

Like:
Red 40 transparency
wait 50;
blue 60 transparency
wait 30;
transparency 100
(don't remember if it's 0 or 100 that's completely transparent)
wait 40;
yellow 20 transparency;
etc

I guess that you have to try it out for yourself to get the results YOU want
(no standard solutions here...)
but it would be great... magic portals and stuff is used all the time in fantasy games,
and cool effects can never hurt a game... right ;D

I was actually thinking of using this in My Game(tm)
so I guess we'll have to see what I'll come up with.
but it would really be nice to have an effects maker or something (Mnemonic...)
« Last Edit: November 02, 2004, 07:28:56 PM by organican »
Logged

Jerrot

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 690
    • View Profile
Re: Particle effects
« Reply #2 on: November 02, 2004, 07:21:34 PM »

Hey guys,

well, the major advantage having this in the engine itself is the one: performance. But since we know what big WME updates are planned before already, you could have a try yourself, your ideas are the right way already and in the last year many features were added to solve these things by scripting, although you should not compare it with a particle solution you know by 3D programs.

There are two major features I think of:
a) you can create entities at runtime
b) your entities can contain custom properties
c) you have math functions included. :)
d) you can alternate those entities at runtime (sprite, transparency, color, rotation...)

So what will you need ?
Of course something you would call an emitter. Actually you don't need it in 2D, it's just some x/y coordinate on the screen. This is the point where you create your entities.

You need some loop in an attached script to control every "particle" entity, which means - in each loop you tell the particles where to move, how to look, etc.

And finally - you need an endpoint. For example if your particle reached 100% transparency, you can "reset" this particle and create a new one at the emitter (or just use the same entity, giving it the default values for new particles).

The rest depends on what you want to do.
IMHO my old "WeatherGod" with its snowflakes might be a good base for creating something. My "emitter" was the whole top y-line with random x-values. I gave every particle some properties like its size, speed, transparency and in a loop I calculated the next position for every snowflake depending on their properties. When the snowflake reached its end point and "melt" to 100% transparency, I recreated it as new slowflake in the "emitter line".

Anyway - too many particles and calculations kill the performance finally, but for some nice little effects it should work fine.

I'm sorry not having the time to write something more common with some examples, but I hope you got the idea of it... and if you feel like "YEAH! I will DO it!" - feel free to ask and to submit us the code. ;)

Good luck.
Logged
Mooh!

organican

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 74
    • View Profile
Re: Particle effects
« Reply #3 on: November 03, 2004, 10:58:21 AM »

I messed around a bit with this just to see what can be done.

So I created this little piece of code

global particle_x;
global particle_y;

while(true)
{
particle_x=Random(70, 160);
particle_y=Random(270, 360);
this.SkipTo(particle_x, particle_y);
this.AlphaColor=RGB(255, 255, 255, 160);
Sleep (10);
particle_x=Random(70, 160);
particle_y=Random(270, 360);
this.SkipTo(particle_x, particle_y);
this.AlphaColor=RGB(235, 235, 235, 160);
Sleep (15);

}

Attached to a 1*1 pixel entity...
just to see what can be done with particles...
it looks ok on a black background,
but can hardly be seen on brighter ones.

The problem is, that if you make it too transparent, you can't even see it if the background's not too dark.
And if you make it less transparent, it looks kind of squary.

Ok, so what this simple script does is move the particle to a random x coordinate,
and changes it's transparency and RGB color.
in "this.AlphaColor=RGB(235, 235, 235, 160);"
the (235, 235, 235... is red green and blue, and 160 is transparency, 0 completely transparent and 255 not even a little bit transparent.
So if you change the Sleep(x milliseconds) and the area x and y,
and if you add more particles with this same script, you've got...
at least something.

The second problem with this is if you want the area to be, say, a circle or a triangle.
So we really need something better. This is just for starters.

There. ::thumbdown ::thumbup ???
« Last Edit: November 03, 2004, 12:30:18 PM by organican »
Logged

organican

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 74
    • View Profile
Re: Particle effects
« Reply #4 on: November 04, 2004, 12:04:48 AM »

Ok, so now I've made a simple rain effect.

For this I used a 1*13 pixel sprite, painted in blue colors.

Then I made five (5) entities with this script attached:

var rain_x;

while(true)
{ this.Y=this.Y+12;
Sleep(1);
 this.Y=this.Y+12;
Sleep(1);
 this.Y=this.Y+12;
Sleep(1);
if(this.Y>600)
   {this.Y=0;
rain_x=Random(0, 800);
this.X=rain_x;
   }
}

Of course you can have some more rain entities,
and make them drops or whatever..
But the thing is, if you make them too small,
they're hardly visible.

Hey, it almost even looks like it's raining!  ;D

I'm not sure I'll take this much further until I know I will use it in my game,
the other post was a fantasy portal btw,
oh, and if you make the particles in that one dark they will be visible in daylight,
mine were white,
but I'm not really an expert,
don't know much about programming really.

But these (in this post) rain drops and things like that,
would work better if created dynamically.
But how do you make multiple objects of the same entity
with the same sprite and script.
Shows my complete ignorance of the subject matter and my total lack of experience and programming sKiLlz ;)

I tried with Scene.LoadEntity("scenes\fall\rain.entity");
But nothing happened. Oh well...

So I made five entities in scenedit and copied the scripts.

There.  :P
« Last Edit: November 04, 2004, 12:19:45 AM by organican »
Logged

Jerrot

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 690
    • View Profile
Re: Particle effects
« Reply #5 on: November 04, 2004, 10:04:26 AM »

Hiya,

Ok, so now I've made a simple rain effect.

Good good, you make your way.

But how do you make multiple objects of the same entity
with the same sprite and script.
I tried with Scene.LoadEntity("scenes\fall\rain.entity");

You tried well, that's what I mentioned in my answer about creating entities at runtime.
In my snowflakes, I wrote this small part to initialize all snowflakes:

Code: [Select]
var flake_image = "images\snowflake.png";
var max_flakes = 200;
var snow;
for(var counter=0; counter<max_flakes; counter=counter+1)
{
    snow[counter] = Scene.LoadEntity("scenes\snowflakes\snowflake.entity");
    this_snowflake = snow[counter];
    this_snowflake.SetSprite(flake_image);
    init_snowflake();
}

The init_snowflake() function simply sets the x/y coordinates for this snow flake and some other properties I needed for this special case. Have a try, it should work.
Logged
Mooh!
 

Page created in 0.071 seconds with 19 queries.