change blue Vector in Particle event

Posted By: CocaCola

change blue Vector in Particle event - 04/02/16 17:24

Hello,
How can I change the blue Vector in Particle event in his lifespawn time?
Posted By: 3run

Re: change blue Vector in Particle event - 04/02/16 17:33

I just assign blank white bmap (8x8 - png) to particle and change it's 'p.blue' in particle event, that's all.


Best regards!
Posted By: CocaCola

Re: change blue Vector in Particle event - 04/02/16 17:42

maby I make something wrong, but it doesenīt work. Itīs a white picture and this code
Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <particles.c>
///////////////////////////////
function p_alphafade(PARTICLE *p)
{
	p.alpha -= p.skill_a*time_step;
	if (p.alpha <= 80)vec_set(p.blue,vector(0,55,255));
	if (p.alpha <= 55)vec_set(p.blue,vector(0,0,55));
	if (p.alpha <= 25)vec_set(p.blue,vector(0,0,0));
	if (p.alpha <= 0)	p.lifespan = 0;
}
function spriteraketeexpfunc(ENTITY* p){
	VECTOR vTemp;
	vec_randomize(vTemp,1);
	vec_add(p._VEL_X,vTemp);
	vec_set(p.blue,vector(15,255,255));
	set(p, _MOVE  | TRANSLUCENT);
	p.alpha = 100;
	p._SIZE = 2;
	p._GRAVITY = 0.2;
	p._FADE = 3;  // fade factor
	p.event = p_fade_sprite;	
}
function spriteraketefly(){
	var numberp=10;
	VECTOR temp;
	while(1){
		if(key_space){
			vec_set(temp.x,vector(0.2,0,0));
			effect_sprite ("wolke.tga",spriteraketeexpfunc,10 ,my.x , temp.x);
		}
		wait(1);
	}
}
function main()
{
	video_window(NULL,NULL,0,"My New Game");
	d3d_antialias = 9;
	shadow_stencil = 0;
	level_load(NULL);
	vec_set(camera.x,vector(0,0,70));
	vec_set(camera.pan,vector(0,-90,0));
	ent_create("rakete1.mdl",nullvector,spriteraketefly);
}

Posted By: 3run

Re: change blue Vector in Particle event - 04/02/16 18:01

I see you are using 'sprites', so this is something completely different (sprites are not particles, they only mimic them)! As far as I remember, you need to set LIGHT flag on to change the colors of models and sprites, give it a try.

Best regards!
Posted By: CocaCola

Re: change blue Vector in Particle event - 04/02/16 19:12

thx, now I understand the mistake, but how I put a png to particle?
I think I create a particle withe the effect function, is it ok?

In the manual is it define in this case:
Code:
effect (function, var number, VECTOR* pos, VECTOR* vel)


I do not see the place for the png String.
Posted By: 3run

Re: change blue Vector in Particle event - 04/02/16 19:32

Originally Posted By: CocaCola
I do not see the place for the png String.
You don't use String or anything like that, you don't need to 'place' png there.
I just wanted to say that I used a .png image file format (like .pcx, .tga, .dds etc) laugh

Best regards!
Posted By: CocaCola

Re: change blue Vector in Particle event - 04/02/16 19:46

I find many mistakes lice ENTITY not PARTICLE and wrong link.
No I understand that Praticles are only pointer laugh
Thx for the tip with the ambient=100;
now itīs works: the Particle is going be red
Code:
function exp_fade(ENTITY *p)
{
	p.alpha -= p.skill_b*time_step;
	p.blue -=p.skill_b*time_step;
	p.green -=p.skill_b*time_step;
	if (p.alpha <= 0)	p._LIFESPAN = 0;
}
function spriteraketeexpfunc(ENTITY* p){
	VECTOR vTemp;
	set(p,LIGHT); 
	p.ambient=100;  
	vec_randomize(vTemp,10);
	vec_add(p._VEL_X,vTemp);
	vec_set(p.blue,vector(0,0,0));
	set(p, _MOVE  | TRANSLUCENT);
	p.alpha = 100;
	p._SIZE = 2;
	p.skill_b=15;
	p._GRAVITY = 0.2;
	p._FADE = 1;  // fade factor
	p.event = exp_fade;	
}

© 2024 lite-C Forums