Explosion in mouse coordinated

Posted By: alves

Explosion in mouse coordinated - 06/06/08 23:14

Simple explosion, on top of the click.

Code:
#include <acknex.h>
#include <default.c>

SOUND* Explosion_wav = "Explosion.wav";
BMAP* Fire_tga = "Fire.tga";

function VecRandomize(var *vec, var range);
function FadeParticle(PARTICLE *p);
function Fire(PARTICLE *p);
function Explosion();

VECTOR ParticlePos;

/* Main Function
---------------------------------*/
function main()
{
	mouse_mode = 2;
	level_load("Explosao.wmb");
	wait(2);
	while(1)
	{
		on_mouse_left = Explosion;
		vec_set(mouse_pos, mouse_cursor);
		vec_set(ParticlePos, mouse_pos);
		wait(1);
	}
}

function Explosion()
{
	ParticlePos.z = 200;
	snd_play(Explosion_wav, 100, 1);
	vec_for_screen(ParticlePos, camera);
	effect(Fire, 1000, ParticlePos, normal);
}


/* Particle Generator
-------------------------------*/
function Fire(PARTICLE *p)
{
	var temp[3];
	VecRandomize(temp, 10);
	vec_add(p.vel_x, temp);
	p.alpha = 25 + random(25);
	p.bmap = Fire_tga;
	p.flags |= (BRIGHT | MOVE);
	p.event = FadeParticle;
}


/* Dist and Direction of particle
---------------------------------------------------------*/
function VecRandomize(var *vec, var range)
{
	vec[0] = random(1) - 0.5;
	vec[1] = random(1) - 0.5;
	vec[2] = random(1) - 0.5;
	vec_normalize(vec, random(range));
}


/* Particle life
-------------------------------*/
function FadeParticle(PARTICLE *p)
{
	p.alpha -= 2 * time_step;
	if(p.alpha <= 0)p.lifespan = 0;
}


Executavel
Posted By: PadMalcom

Re: Explosion in mouse coordinated - 06/07/08 18:12

Nice one, could not stop clicking for about 2 Minutes :P
Posted By: alves

Re: Explosion in mouse coordinated - 06/07/08 19:01

Change the "on_mouse_left = Explosion," in main function for:

Code:
if(mouse_left == ON)
{
   Explosion();
   wait(-2);
}



In the "wait ()", you set the waiting time.
Posted By: Poison

Re: Explosion in mouse coordinated - 06/08/08 15:17

wow, looks awesome.
Thank you alves.
Posted By: JimFox

Re: Explosion in mouse coordinated - 06/11/08 14:19

Hi,
I usually groan when I see "rapidshare" as the file location. But this time it downloaded very easily. No problem.
Thanks for a nice little effect!!
Best regards,
Posted By: VeT

Re: Explosion in mouse coordinated - 06/25/08 09:52

he-he, i also couldnt stop clicking for some minutes)))
© 2024 lite-C Forums