Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (AndrewAMD, TipmyPip, OptimusPrime), 15,229 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Particles - NOT a question : SOVLED #424655
06/19/13 23:41
06/19/13 23:41

M
Malice
Unregistered
Malice
Unregistered
M



Manual contents tab -> Engine Functions --> Materials & Praticles --> effect, effect_local

Read this section and

manual contents tab --> Engine Objects --> Particle --> all of this.

Ask questions in this thread


Code:
// helper function: sets the vector to random direction and length
function vec_randomize (VECTOR* vec, var range)
{
   vec_set(vec,vector(random(1)-0.5,random(1)-0.5,random(1)-0.5));
   vec_normalize(vec,random(range));
}

// helper function: fades out a particle
function p_alphafade(PARTICLE *p)
{
    p.alpha -= p.skill_a*time_step;
    if (p.alpha <= 0) p.lifespan = 0;
}

function p_fountain(PARTICLE* p)
{
   VECTOR vTemp;
   vec_randomize(vTemp,2);
   vec_add(p.vel_x,vTemp);
   vec_set(p.blue,vector(random(255),random(255),255));
   set(p, MOVE | BRIGHT | TRANSLUCENT);
   p.alpha = 100;
   p.size = 2;
   p.gravity = 0.2;
   p.skill_a = 3; // fade factor
   p.event = p_alphafade;
}

function main()
{
  level_load(NULL);
  video_window(NULL,NULL,0,"Particle demo");
  vec_set(camera.x,vector(-150,0,50));
  vec_set(sky_color,vector(50,0,0)); // dark blue

  while(1)
  {
     effect(p_fountain,maxv(1,40*time_step),vector(0,0,0),vector(0,0,5));
     wait(1);
  }
}



The effect() instruction is like ent_create for particles.

The p_fountain() function is like a PANEL* define it sets up the members of the particle effect and sets up it's behavior. You can also think of it like a entity action function that is placed last in ent_create("model", location , entity action); ..

The p.event = p_alphafade and p_alphafade() is kinda like a entity event function for particles.

Ask more as needed. I don't think I can do better then the information in AUM 64 ( just noticed this AUM is c-script but compare it to the code above from the manual and you should be able to see the difference you need to change to make it work)

Last edited by Malice; 06/20/13 18:14.
Re: Particles - NOT a question [Re: ] #424680
06/20/13 09:46
06/20/13 09:46
Joined: Jan 2013
Posts: 106
Only in your imagination!
The_KING Offline
Member
The_KING  Offline
Member

Joined: Jan 2013
Posts: 106
Only in your imagination!
I've already read the manual ,but when I try to do it ,the engine stops working and Windows displays "acknex.exe has stopped working" message:

Here's my code (not the main ,the included):

Code:
VIEW* movie_camera1 =
{
	layer = 5;
	pos_x = 0;
	pos_y = 0;
	size_x = screen_size.x;
	size_y = screen_size.y;
	arc = 60;
	x = 5800;
	y = 0;
	z = 2036;
	tilt = -20;
	pan = 181;
	genius = NULL;
	flags = UNTOUCHABLE;
} 
/////////////////////////////////////////

TEXT* location_info =
{
	pos_x = 300;
	pos_y = 500;
	layer = 0;
	font = "coure#25b";
	blue = 255;
	green = 20;
	red = 25;
	string("L");
}





/////////////////////////////////////


function p_explo1fade(PARTICLE *p)
{
    p.alpha -= 3*time_step;
    if (p.alpha <= 0) p.lifespan = 0;
}

///////////////////////////////////

function p_explo1(PARTICLE* p)
{
   VECTOR explo1_speed;
   vec_set(explo1_speed,vector(0.5-random(1),0.5-random(1),0.5-random(1)));
   vec_set(p.vel_x,explo1_speed.x);
   set(p, MOVE | BRIGHT | TRANSLUCENT);
   p.alpha = 100;
   p.size = 16;
   p.bmap = "explo+13.tga";
   p.gravity = 0.2;
   p.event = p_explo1fade;
}


/////////////////////////////////

function play_movie1 ()
{
	var CamPanStore;
	var time_passed = 0;
	
	VECTOR camera_speed;
	
	if (p_able_to_move == 0)
	{
		set(camera,0);
		set(movie_camera1,SHOW);
   }
   CamPanStore = movie_camera1.pan;
   set(location_info,SHOW);
   while(time_passed < 7)
   {
   	movie_camera1.pan -= 0.5*time_step;
   	time_passed += time_step/16;
   	if (time_passed >= 0.1) str_cpy((location_info.pstring)[0],"Lo");
   	if (time_passed >= 0.2) str_cpy((location_info.pstring)[0],"Loc");
   	if (time_passed >= 0.3) str_cpy((location_info.pstring)[0],"Loca");
   	if (time_passed >= 0.4) str_cpy((location_info.pstring)[0],"Locat");
   	if (time_passed >= 0.5) str_cpy((location_info.pstring)[0],"Locati");
   	if (time_passed >= 0.6) str_cpy((location_info.pstring)[0],"Locatio");
   	if (time_passed >= 0.7) str_cpy((location_info.pstring)[0],"Location");
   	if (time_passed >= 0.8) str_cpy((location_info.pstring)[0],"Location:");
   	if (time_passed >= 0.9) str_cpy((location_info.pstring)[0],"Location: ");
   	if (time_passed >= 1) str_cpy((location_info.pstring)[0],"Location: C");
   	if (time_passed >= 1.1) str_cpy((location_info.pstring)[0],"Location: Ch");
   	if (time_passed >= 1.2) str_cpy((location_info.pstring)[0],"Location: Chi");
   	if (time_passed >= 1.3) str_cpy((location_info.pstring)[0],"Location: Chin");
   	if (time_passed >= 1.4) str_cpy((location_info.pstring)[0],"Location: China");
   	wait(1);
   }
   toggle(location_info,SHOW);
   vec_set(movie_camera1.x,vector(6474,5770,2609));
   movie_camera1.pan += 43;
   
   wait(-1);
   time_passed = 0;
   while(time_passed < 2)
   {
   	time_passed += time_step/16;
   	movie_camera1.x -= 50*time_step;
   	movie_camera1.tilt -= 0.25*time_step;
   	wait(1);
   }
   
   effect(p_explo1,1,vector(1921,7288,95),normal);
   
   toggle(movie_camera1,SHOW);
   set(camera,SHOW);
   p_able_to_move = 1;

}




Also, I want to know how to REMOVE objects like: views, panels....etc.

Last edited by The_KING; 06/20/13 10:42.
Re: Particles - NOT a question [Re: The_KING] #424712
06/20/13 16:10
06/20/13 16:10

M
Malice
Unregistered
Malice
Unregistered
M



Question if you comment out only the effect() line does this fix the engine crash? Sounds like a endless loop somewhere else.

EDIT* Need morning coffee to early... Please disregard what was in the space earlier.

Also for your other question PLEASE pick something specific and Start a new thread. With information you provided I don't know how to answer and also this thread is for fixing you particle problem . But look up ptr_remove()..

Last edited by Malice; 06/20/13 16:24.
Re: Particles - NOT a question [Re: ] #424721
06/20/13 17:38
06/20/13 17:38
Joined: Jan 2013
Posts: 106
Only in your imagination!
The_KING Offline
Member
The_KING  Offline
Member

Joined: Jan 2013
Posts: 106
Only in your imagination!
I changed the position of the particle emitter and after that ,the engine didn't crash ,but still can't see the effect

EDIT* I use a .tga bitmap of 13 frames for the particle ,I guess this is the problem

Last edited by The_KING; 06/20/13 17:46.
Re: Particles - NOT a question [Re: The_KING] #424722
06/20/13 17:46
06/20/13 17:46

M
Malice
Unregistered
Malice
Unregistered
M



It's crashing me so I'll work it now... You need change 'normal' to a vector - you have no idea what value the 'normal' contains.

EDIT* Ok new to me .. Maybe you can use effect_sprite(STRING* image, EVENT func, var number, VECTOR* pos, VECTOR* vel) for that effect.

EDIT2* Also you need time_step in the particle number.
effect(p_explo1,100*time_step,my.x,vector(10,10,20));

Last edited by Malice; 06/20/13 17:54.
Re: Particles - NOT a question [Re: ] #424723
06/20/13 18:01
06/20/13 18:01

M
Malice
Unregistered
Malice
Unregistered
M



Work from this

Code:
#include <particles.c>


function p_fountain(PARTICLE* p)
{
   VECTOR vTemp;
   vec_randomize(vTemp,2);
   vec_add(p.vel_x,vTemp);
   vec_set(p.blue,vector(random(255),random(255),255));
   set(p, MOVE | BRIGHT | TRANSLUCENT);
   p.alpha = 100;
   p.size = 2;
   p.gravity = 0.2;
   p.skill_a = 3; // fade factor
   p.event = p_fade;
}

// sprite-emulated particle function
function p_fountain_sprite(ENTITY* p)
{
   VECTOR vTemp;
   vec_randomize(vTemp,2);
   vec_add(p._VEL_X,vTemp);
   vec_set(p.blue,vector(random(255),random(255),255));
   set(p, _MOVE | BRIGHT | TRANSLUCENT);
   p.alpha = 100;
   p._SIZE = 2;
   p._GRAVITY = 0.2;
   p._FADE = 3;  // fade factor
   p.event = p_fade_sprite;
}


function create particles()
{
   while(x)
       {
         effect_sprite("explo+13.tga", p_fountain_sprite,1*time_step,my.x,vector(0,0,50));
       wait(1);
       } 
}



Awesome effect! When my project player model runs he has fire shooting out his butt. grin

@The_KING please let me know if I can mark this thread SOLVED ?

Last edited by Malice; 06/20/13 18:05.
Re: Particles - NOT a question [Re: ] #424726
06/20/13 18:10
06/20/13 18:10
Joined: Jan 2013
Posts: 106
Only in your imagination!
The_KING Offline
Member
The_KING  Offline
Member

Joined: Jan 2013
Posts: 106
Only in your imagination!
OK. I handled it.

Thank you

Re: Particles - NOT a question [Re: The_KING] #424727
06/20/13 18:13
06/20/13 18:13

M
Malice
Unregistered
Malice
Unregistered
M



Lol - I am a idiot again.

Solved

Re: Particles - NOT a question [Re: ] #424739
06/20/13 19:43
06/20/13 19:43
Joined: Jan 2013
Posts: 106
Only in your imagination!
The_KING Offline
Member
The_KING  Offline
Member

Joined: Jan 2013
Posts: 106
Only in your imagination!
I think I was...
When you know what the problem was ,you won't believe it!!....

I won't tell you the problem grin


Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1