Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, 1 invisible), 1,086 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Need a laser beam particle effect example #413400
12/13/12 12:30
12/13/12 12:30
Joined: Apr 2011
Posts: 75
Malta
E
Ercoles Offline OP
Junior Member
Ercoles  Offline OP
Junior Member
E

Joined: Apr 2011
Posts: 75
Malta
Can anyone provide a laser beam particle effect example, like a function which takes start and destination inputs and generates a laser beam from start to destination coordinates?

Re: Need a laser beam particle effect example [Re: Ercoles] #413402
12/13/12 13:11
12/13/12 13:11
Joined: Oct 2008
Posts: 681
Germany
Ayumi Offline
User
Ayumi  Offline
User

Joined: Oct 2008
Posts: 681
Germany

Last edited by Ayumi; 12/13/12 13:13.
Re: Need a laser beam particle effect example [Re: Ayumi] #413406
12/13/12 14:15
12/13/12 14:15
Joined: Apr 2011
Posts: 75
Malta
E
Ercoles Offline OP
Junior Member
Ercoles  Offline OP
Junior Member
E

Joined: Apr 2011
Posts: 75
Malta
They are good examples but I need one done only with SED script editor and maybe a pcx file. I need an example causing a line from a corner of the screen to the middle.

Re: Need a laser beam particle effect example [Re: Ercoles] #413409
12/13/12 14:41
12/13/12 14:41
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
You're not asking for a sample but for a completed piece of work. Go through the tutorials and try if for yourself. If you get into any difficulties don't hesitate to ask for advice here. But please don't ask other people to do the work for you.

And please DO NOT CROSSPOST. tired

http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=413369#Post413369


Always learn from history, to be sure you make the same mistakes again...
Re: Need a laser beam particle effect example [Re: Uhrwerk] #413416
12/13/12 16:38
12/13/12 16:38
Joined: Apr 2011
Posts: 75
Malta
E
Ercoles Offline OP
Junior Member
Ercoles  Offline OP
Junior Member
E

Joined: Apr 2011
Posts: 75
Malta
Ok I have managed to make this code which seems to do what I need:

ENTITY* gun1;
ENTITY* gun2;

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

function p_trace(PARTICLE *p)
{
set(p, BRIGHT|TRANSLUCENT|BEAM);
p.size = 1;
p.skill_a = 20; // fade factor
p.event = p_alphafade;
p.red =255;
p.blue=20;
p.green=128;
}

action tracer_right()
{
VECTOR last_pos;
while(1){
vec_set(last_pos,my.x);
my.z +=1.5;
my.y +=2;
if (my.y>1){break;}
effect(p_trace,1,my.x,vec_sub(last_pos,my.x));
wait(1);
}
}

action tracer_left()
{
VECTOR last_pos;
while(1){
vec_set(last_pos,my.x);
my.z +=1.5;
my.y -=2;
if (my.y<-1){break;}
effect(p_trace,1,my.x,vec_sub(last_pos,my.x));
wait(1);
}
}

function main()
{
vec_set(sky_color,vector(0,0,0));
level_load(NULL);
video_window(NULL,NULL,0,"Laser demo");
vec_set(camera.x,vector(-250,0,50));
vec_set(camera.pan,vector(0,-15,0));
while (1){
if (mouse_left == 1){
gun1=ent_create(NULL,vector(-100,-170,-80),tracer_right);
gun2=ent_create(NULL,vector(-100,170,-80),tracer_left);
}
//if(proc_status(tracer_right) == 0){ent_remove(gun1);}
//if(proc_status(tracer_left) == 0){ent_remove(gun2);}
wait(1);
}
}

However the entities need to be destroyed otherwise after a couple of fires they will cause an error. I tried using the commented lines in the main function but they causes errors.

Last edited by Ercoles; 12/13/12 17:11.
Re: Need a laser beam particle effect example [Re: Ercoles] #413417
12/13/12 17:10
12/13/12 17:10
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Excellent work. And you did it all by yourself. :-)


Always learn from history, to be sure you make the same mistakes again...
Re: Need a laser beam particle effect example [Re: Uhrwerk] #413418
12/13/12 17:13
12/13/12 17:13
Joined: Apr 2011
Posts: 75
Malta
E
Ercoles Offline OP
Junior Member
Ercoles  Offline OP
Junior Member
E

Joined: Apr 2011
Posts: 75
Malta
Thanks

However the entities need to be destroyed otherwise after a couple of fires they will cause an error. I tried using the commented lines in the main function but they causes errors.

Last edited by Ercoles; 12/13/12 17:15.
Re: Need a laser beam particle effect example [Re: Ercoles] #413420
12/13/12 17:17
12/13/12 17:17
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
What error do these entities cause?


Always learn from history, to be sure you make the same mistakes again...
Re: Need a laser beam particle effect example [Re: Uhrwerk] #413423
12/13/12 18:51
12/13/12 18:51
Joined: Apr 2011
Posts: 75
Malta
E
Ercoles Offline OP
Junior Member
Ercoles  Offline OP
Junior Member
E

Joined: Apr 2011
Posts: 75
Malta
Everytime I press the mouse button a new entity is created. After several clicks it gave me an error:

Not enough entities reserved(1000)

So I think that I must kill the entities created with each mouse click when the particle effect has finished.

Re: Need a laser beam particle effect example [Re: Ercoles] #413425
12/13/12 19:15
12/13/12 19:15
Joined: Apr 2011
Posts: 75
Malta
E
Ercoles Offline OP
Junior Member
Ercoles  Offline OP
Junior Member
E

Joined: Apr 2011
Posts: 75
Malta
I have solved it by using this in the fire loop:

if(proc_status(tracer_right) < 5){gun1=ent_create(NULL,vector(-100,-170,-80),tracer_right);}
if(proc_status(tracer_left) < 5){gun2=ent_create(NULL,vector(-100,170,-80),tracer_left);}

This way it is not causing the error so often(only rarely). But do I still need to kill the entities created or particle entities die by themselves?

I added these lines instead of the commented ones but do not seem to make much difference:

if(proc_status(tracer_right) == 0){ptr_remove(gun1);}
if(proc_status(tracer_left) == 0){ptr_remove(gun2);}

Last edited by Ercoles; 12/13/12 19:20.
Page 1 of 3 1 2 3

Gamestudio download | chip programmers | 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