A fade effect - [SOLVED]

Posted By: DonaldThief

A fade effect - [SOLVED] - 07/17/13 02:59

Hi, guys

I read some AUMs and everything worked fine until I came to the section talking about fade effect (actually, I couldn't understand anything). So, I'd like anyone to share his knowledge and tell me how to make fading in & out effect

Also, if any of you guys know some tutorial for particles (fire, explosion, smoke ...etc.) it will be better if he/she shares it

Thank you for reading
Posted By: Random

Re: A fade effect - 07/17/13 05:14

Easy fade script from the manual.

Code:
set(my,TRANSLUCENT);for (my.alpha=0; my.alpha+=5*time_step; my.alpha<100) wait(1);
reset(my,TRANSLUCENT);



The manual is a great place to look ^^
Posted By: Locoweed

Re: A fade effect - 07/17/13 05:56

BMAP* bmpSpark = "spark.bmp";


function effectBloodSplatFade(PARTICLE* p)
{
p.size -= (.25+random(.25)) * time_step; // reduce blood splats size with some randomness
p.alpha-=4*time_step; // fade out bloodsplat
p.lifespan = maxv(0,p.alpha); // when alpha reaches <= 0, lifespan = 0, thus ending that particular bloodsplat particle
}

function effectBloodSplat(PARTICLE* p)
{

vec_set(p.vel_x,vector((random(2)-1),(random(2)-1),(.5-random(1)))); // give a little random velocity to each bloodsplat particle

//give a little random start position to each bloodsplat
p.x += random(3)-1.5;
p.y += random(3)-1.5;
p.z += random(3)-1.5;
p.bmap = bmpSpark;
set(p,STREAK|BRIGHT|MOVE); // set particle parameters
p.size=4+random(8); // give each bloodsplat a little random size
p.alpha = 70 + random(15); // give each bloodsplat a little random alpha(visiblilty)

p.gravity = 0.3; // make particles fall down with gravity, not necessary for some effects

//give each bloodsplat a little random red color
p.red = 200 + random(55);
p.green= 20 + random(10);
p.blue = 20 + random(10);

p.event = effectBloodSplatFade; // call the fade event
}

// Somewhere in code that calls effect
...
effect_local(effectBloodSplat,(2+random(4)),my.x,nullvector); // create 2 to 6 blood splats at entity position
...

About as simple as it gets, except for the randomness stuff,
That's all I got for you, hope it helps,
Later,
Loco
Posted By: DonaldThief

Re: A fade effect - 07/17/13 11:54

@Locoweed thank you for helping

@Random Thank you but this is not what I want. I don't want an entity to fade in and out ,I want the whole screen (e.g. a white flash that increases ,and when reaching some maximum ,it decreases gradually)
Posted By: rayp

Re: A fade effect - 07/17/13 12:18

To fade the whole screen white/black whatever u can use panels of course.
Code:
BMAP* white_map = "white.pcx"; // a solid white 64x64 image
PANEL* white_pan ={
   alpha = 0;
   bmap  = white_map;
   flags = TRANSLUCENT;
}
void _fade_white_inandout(){
   if (is(white_pan, SHOW)) return;
   set (white_pan, SHOW);
   white_pan.alpha = 0;
   white_pan.scale_x = screen_size.x;
   white_pan.scale_y = screen_size.y;
   while (white_pan.alpha < 100){
      white_pan.alpha += time_step * 2;
      wait (1);
   }
   while (white_pan.alpha > 0){
      white_pan.alpha -= time_step * 2;
      wait (1);
   }   
   reset (white_pan, SHOW);
}

Greets
Posted By: Uhrwerk

Re: A fade effect - 07/17/13 14:07

Code:
white_pan.scale_x = screen_size.x

I guess this is not your intention. You meant
Code:
white_pan.size_x = screen_size.x

right?
Posted By: DonaldThief

Re: A fade effect - 07/17/13 14:15

@rayp Thank you very much
Posted By: rayp

Re: A fade effect - 07/17/13 14:41

@Uhrwerk
Yeah wrote it on the fly...your right of course ^^
thanks
Posted By: Locoweed

Re: A fade effect - 07/19/13 03:05

Ah, whole screen, glad you got it figured out.

Later,
Loco
© 2024 lite-C Forums