Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Remake of classic style Fireworks (https://forums.graalonline.com/forums/showthread.php?t=134258397)

adam 03-15-2010 07:17 AM

Remake of classic style Fireworks
 
2 Attachment(s)
This is a remake of fireworks I did in GS1 years ago, before I could go on Testbed to learn GS2. Please, don't state the obvious, that I didn't use the built in particle engine, I'll work on it later... maybe. But any other comments are welcome. :D
Also thanks to Door for helping me make it prettier. And all the Testbed Server people for allowing me to learn GS2 there. And for everybody else in IRC who logs into testbed just because I say help I need a body to test on!

PHP Code:

//NPC Created by Rogue Shadow(TCN)
//AIM: RogueTCN
//#CLIENTSIDE
function onCreated(){
  
this.rockets = new[0];
  
this.bursts = new[0];
  
this.trails = new[0];
  
this.grav 0.1;
}
function 
onWeaponFired(){
  
AddRocket(random(0,64),50);
}
function 
onTimeout(){
  for (
temp.i=0;temp.i<this.rockets.size();temp.i++){
    
AddTrail(this.rockets[temp.i].x-.5,this.rockets[temp.i].y,this.rockets[temp.i].vx,this.rockets[temp.i].vy);
    if (
this.rockets[temp.i].this.rockets[temp.i].ttl){
      
AddBurst(this.rockets[temp.i].x,this.rockets[temp.i].y,160);
    }
  }
  
this.rockets UpdateEverything(this.rockets);
  
this.bursts UpdateEverything(this.bursts);
  
this.trails UpdateEverything(this.trails);
  
temp.img DrawParticle(200,this.rockets);
  
temp.img DrawParticle(temp.img,this.bursts);
  
temp.img DrawParticle(temp.img,this.trails);
  if (
temp.img this.lastimg)hideimgs(temp.img,this.lastimg);
  
this.lastimg temp.img;
  
settimer(0.05);
}
function 
UpdateEverything(temp.objs){
  for (
temp.0;temp.temp.objs.size() ; temp.i++ ){
    if (
temp.objs[temp.i].temp.objs[temp.i].ttl){
      
temp.objs.delete(temp.i);
    }
  }
  for (
temp.rtemp.objs){
    
temp.r.vy += this.grav;
    
temp.r.+= temp.r.vx;
    
temp.r.+= temp.r.vy;
    
temp.r.++;
  }
  return 
temp.objs;
}
function 
DrawParticle(temp.img,temp.p){
  for (
temp.rtemp.p){
    if (
temp.r.alpha){
      
temp.1-(temp.r.t/temp.r.ttl);
    }else 
temp.1;
    
temp.showimg(temp.img,r.image,temp.r.x,temp.r.y);
    
changeimgcolors(temp.img,r.red,r.green,r.blue,temp.a);
    
changeimgzoom(temp.img,r.zoom);
    if (
r.rotation){
      
temp.rot getangle(r.vx,r.vy)+pi/2;
      
with (temp.j)rotation temp.rot;
    }
    if (
r.spin){
      
with (temp.j)rotation += temp.r.spin_spd;
    }
    
temp.img++;
  }
  return 
temp.img;
}
function 
AddBurst(nx,ny,num){
  
temp.ang 0
  
temp.kind int(random(0,1)+.5);
  
temp.color int(random(0,7)+.5);
  for (
temp.j=0;temp.num;temp.j++){
    
temp.= new TStaticVar(); 
    
temp.i.image "g4_particle_x.png";
    if (
temp.kind == 1)temp.spd random(.1,.8);
    else 
temp.spd = (temp.j%2=1) ? .2:.3;
    
temp.i.zoom .6;
    
temp.i.vx sin(temp.ang)*temp.spd;
    
temp.i.vy cos(temp.ang)*temp.spd -.7;
    
temp.ang+=0.1;
    
temp.i.nx;
    
temp.i.ny;
    
temp.i.ttl 30;
    
temp.i.0;
    if (
temp.color == 0){
      
temp.i.red 1;
      
temp.i.green 0;
      
temp.i.blue 0;
    }elseif(
temp.color == 1){
      
temp.i.red 0;
      
temp.i.green 1;
      
temp.i.blue 0;
    }elseif(
temp.color == 2){   
      
temp.i.red 0;
      
temp.i.green 0;
      
temp.i.blue 1;
    }elseif(
temp.color == 3){
      
temp.i.red 1;
      
temp.i.green 1;
      
temp.i.blue 0;
    }elseif(
temp.color == 4){        
      
temp.i.red 1;
      
temp.i.green 0;
      
temp.i.blue 1;
    }elseif(
temp.color == 5){ 
      
temp.i.red 0;
      
temp.i.green 1;
      
temp.i.blue 1;
    }elseif(
temp.color == 6){
      
temp.i.red 1;
      
temp.i.green 1;
      
temp.i.blue 1;
    }elseif(
temp.color == 7){
      
temp.i.red random(0,1);
      
temp.i.green random(0,1);
      
temp.i.blue random(0,1);
    }
    
temp.i.alpha true;
    
temp.i.i=this.bursts.size();
    
temp.i.spin true;
    
temp.i.spin_spd random(-.5,.5);
    
this.bursts.add(temp.i);
  }
  
play("fireworks_explode.wav");
}
function 
AddRocket(nx,ny){
  
temp.= new TStaticVar();
  
temp.r.image "np_barrel.png";
  
temp.r.nx;
  
temp.r.zoom .7;
  
temp.r.ny;
  
temp.r.vx random(-.5,.5);
  
temp.r.vy = -random(2,3);
  
temp.r.ttl 30;
  
temp.r.0;
  
temp.r.red random(.7,1);
  
temp.r.green random(.7,1);
  
temp.r.blue random(.7,1);
  
temp.r.rotation true;
  
temp.r.alpha false;
  
temp.r.this.rockets.size();
  
this.rockets.add(temp.r);
  
play("fireworks_launch.wav");
  
settimer(0.05);
}

function 
AddTrail(nx,ny,vx,vy){
  
temp.= new TStaticVar();
  
temp.r.nx;
  
temp.r.ny;
  
temp.r.vy = -random(.1,.5);
  
temp.r.vx = -random(.1,.5);
  
temp.r.ttl 10;
  
temp.r.0;
  
temp.r.red 1;
  
temp.r.blue 1;
  
temp.r.green 1;
  
temp.r.alpha true;
  
temp.r.rotation true;
  
temp.r.zoom .7;
  
temp.r.image "g4_particle_smoke.png";
  
temp.r.this.trails.size();
  
this.trails.add(temp.r);



Cubical 03-15-2010 07:21 AM

Quote:

Originally Posted by adam (Post 1562684)
This is a remake of fireworks I did in GS1 years ago, before I could go on Testbed to learn GS2. Please, don't state the obvious, that I didn't use the built in particle engine, I'll work on it later... maybe. But any other comments are welcome. :D
Also thanks to Door for helping me make it prettier. And all the Testbed Server people for allowing me to learn GS2 there. And for everybody else in IRC who logs into testbed just because I say help I need a body to test on!

PHP Code:

//NPC Created by Rogue Shadow(TCN)
//AIM: RogueTCN
//#CLIENTSIDE
function onCreated(){
  
this.rockets = new[0];
  
this.bursts = new[0];
  
this.trails = new[0];
  
this.grav 0.1;
}
function 
onWeaponFired(){
  
AddRocket(random(0,64),50);
}
function 
onTimeout(){
  for (
temp.i=0;temp.i<this.rockets.size();temp.i++){
    
AddTrail(this.rockets[temp.i].x-.5,this.rockets[temp.i].y,this.rockets[temp.i].vx,this.rockets[temp.i].vy);
    if (
this.rockets[temp.i].this.rockets[temp.i].ttl){
      
AddBurst(this.rockets[temp.i].x,this.rockets[temp.i].y,160);
    }
  }
  
this.rockets UpdateEverything(this.rockets);
  
this.bursts UpdateEverything(this.bursts);
  
this.trails UpdateEverything(this.trails);
  
temp.img DrawParticle(200,this.rockets);
  
temp.img DrawParticle(temp.img,this.bursts);
  
temp.img DrawParticle(temp.img,this.trails);
  if (
temp.img this.lastimg)hideimgs(temp.img,this.lastimg);
  
this.lastimg temp.img;
  
settimer(0.05);
}
function 
UpdateEverything(temp.objs){
  for (
temp.0;temp.temp.objs.size() ; temp.i++ ){
    if (
temp.objs[temp.i].temp.objs[temp.i].ttl){
      
temp.objs.delete(temp.i);
    }
  }
  for (
temp.rtemp.objs){
    
temp.r.vy += this.grav;
    
temp.r.+= temp.r.vx;
    
temp.r.+= temp.r.vy;
    
temp.r.++;
  }
  return 
temp.objs;
}
function 
DrawParticle(temp.img,temp.p){
  for (
temp.rtemp.p){
    if (
temp.r.alpha){
      
temp.1-(temp.r.t/temp.r.ttl);
    }else 
temp.1;
    
temp.showimg(temp.img,r.image,temp.r.x,temp.r.y);
    
changeimgcolors(temp.img,r.red,r.green,r.blue,temp.a);
    
changeimgzoom(temp.img,r.zoom);
    if (
r.rotation){
      
temp.rot getangle(r.vx,r.vy)+pi/2;
      
with (temp.j)rotation temp.rot;
    }
    if (
r.spin){
      
with (temp.j)rotation += temp.r.spin_spd;
    }
    
temp.img++;
  }
  return 
temp.img;
}
function 
AddBurst(nx,ny,num){
  
temp.ang 0
  
temp.kind int(random(0,1)+.5);
  
temp.color int(random(0,7)+.5);
  for (
temp.j=0;temp.num;temp.j++){
    
temp.= new TStaticVar(); 
    
temp.i.image "g4_particle_x.png";
    if (
temp.kind == 1)temp.spd random(.1,.8);
    else 
temp.spd = (temp.j%2=1) ? .2:.3;
    
temp.i.zoom .6;
    
temp.i.vx sin(temp.ang)*temp.spd;
    
temp.i.vy cos(temp.ang)*temp.spd -.7;
    
temp.ang+=0.1;
    
temp.i.nx;
    
temp.i.ny;
    
temp.i.ttl 30;
    
temp.i.0;
    if (
temp.color == 0){
      
temp.i.red 1;
      
temp.i.green 0;
      
temp.i.blue 0;
    }elseif(
temp.color == 1){
      
temp.i.red 0;
      
temp.i.green 1;
      
temp.i.blue 0;
    }elseif(
temp.color == 2){   
      
temp.i.red 0;
      
temp.i.green 0;
      
temp.i.blue 1;
    }elseif(
temp.color == 3){
      
temp.i.red 1;
      
temp.i.green 1;
      
temp.i.blue 0;
    }elseif(
temp.color == 4){        
      
temp.i.red 1;
      
temp.i.green 0;
      
temp.i.blue 1;
    }elseif(
temp.color == 5){ 
      
temp.i.red 0;
      
temp.i.green 1;
      
temp.i.blue 1;
    }elseif(
temp.color == 6){
      
temp.i.red 1;
      
temp.i.green 1;
      
temp.i.blue 1;
    }elseif(
temp.color == 7){
      
temp.i.red random(0,1);
      
temp.i.green random(0,1);
      
temp.i.blue random(0,1);
    }
    
temp.i.alpha true;
    
temp.i.i=this.bursts.size();
    
temp.i.spin true;
    
temp.i.spin_spd random(-.5,.5);
    
this.bursts.add(temp.i);
  }
  
play("fireworks_explode.wav");
}
function 
AddRocket(nx,ny){
  
temp.= new TStaticVar();
  
temp.r.image "np_barrel.png";
  
temp.r.nx;
  
temp.r.zoom .7;
  
temp.r.ny;
  
temp.r.vx random(-.5,.5);
  
temp.r.vy = -random(2,3);
  
temp.r.ttl 30;
  
temp.r.0;
  
temp.r.red random(.7,1);
  
temp.r.green random(.7,1);
  
temp.r.blue random(.7,1);
  
temp.r.rotation true;
  
temp.r.alpha false;
  
temp.r.this.rockets.size();
  
this.rockets.add(temp.r);
  
play("fireworks_launch.wav");
  
settimer(0.05);
}

function 
AddTrail(nx,ny,vx,vy){
  
temp.= new TStaticVar();
  
temp.r.nx;
  
temp.r.ny;
  
temp.r.vy = -random(.1,.5);
  
temp.r.vx = -random(.1,.5);
  
temp.r.ttl 10;
  
temp.r.0;
  
temp.r.red 1;
  
temp.r.blue 1;
  
temp.r.green 1;
  
temp.r.alpha true;
  
temp.r.rotation true;
  
temp.r.zoom .7;
  
temp.r.image "g4_particle_smoke.png";
  
temp.r.this.trails.size();
  
this.trails.add(temp.r);



That's pretty cool.

DustyPorViva 03-15-2010 08:53 AM

You could shorten some things considerably:
PHP Code:

  temp.color int(random(0,7)+.5); 
    if (
temp.color == 0){
      
temp.i.red 1;
      
temp.i.green 0;
      
temp.i.blue 0;
    }elseif(
temp.color == 1){
      
temp.i.red 0;
      
temp.i.green 1;
      
temp.i.blue 0;
    }elseif(
temp.color == 2){   
      
temp.i.red 0;
      
temp.i.green 0;
      
temp.i.blue 1;
    }elseif(
temp.color == 3){
      
temp.i.red 1;
      
temp.i.green 1;
      
temp.i.blue 0;
    }elseif(
temp.color == 4){        
      
temp.i.red 1;
      
temp.i.green 0;
      
temp.i.blue 1;
    }elseif(
temp.color == 5){ 
      
temp.i.red 0;
      
temp.i.green 1;
      
temp.i.blue 1;
    }elseif(
temp.color == 6){
      
temp.i.red 1;
      
temp.i.green 1;
      
temp.i.blue 1;
    }elseif(
temp.color == 7){
      
temp.i.red random(0,1);
      
temp.i.green random(0,1);
      
temp.i.blue random(0,1);
    } 

=

PHP Code:

  temp.color int(random(0,7)+.5);
  if (
temp.color 7) {
    
// if they are in the array, they will = 1, if not 0, so it handles the troubles for you!
    
temp.i.red temp.color in {0,3,4,6};  
    
temp.i.green temp.color in {1,3,5,6};
    
temp.i.blue temp.color in {2,4,5,6};
  } else {
      
temp.i.red random(0,1);
      
temp.i.green random(0,1);
      
temp.i.blue random(0,1);
  }; 

Or even:
PHP Code:

  temp.color int(random(0,7)+.5);
  
temp.i.red temp.color == random(0,1) : temp.color in {0,3,4,6};  
  
temp.i.green temp.color == random(0,1) : temp.color in {1,3,5,6};
  
temp.i.blue temp.color == random(0,1) : temp.color in {2,4,5,6}; 

Also things like this, which isn't really that bad anyways but can cut some things down:
temp.i.red = temp.i.green = temp.i.blue = 1;
this.rockets = this.bursts = his.trails = new[0];

Crow 03-15-2010 01:50 PM

You can make the whole thing more colorful and more realistic by using my HSLtoRGB function, allowing you to have slightly different tones of whichever color you wish. Bet it looks quite cool :) I guess adding a random hue value between -0.02 and 0.02 to the color of your choice using my function should do the trick. Those single color effects still look a bit not-so-nice, so that'd spice it up (:

Cubical 03-15-2010 01:54 PM

Quote:

Originally Posted by Crow (Post 1562704)
You can make the whole thing more colorful and more realistic by using my HSLtoRGB function, allowing you to have slightly different tones of whichever color you wish. Bet it looks quite cool :) I guess adding a random hue value between -0.02 and 0.02 to the color of your choice using my function should do the trick. Those single color effects still look a bit not-so-nice, so that'd spice it up (:

You can check it out by hopping on testbed and adding 'Public\adam\fireworks', the pictures don't do it justice. It looks a lot better when it's moving.

adam 03-15-2010 07:14 PM

Dusty's inspiration and comments added. Should be outwardly the same, but the code is much shorter in the color respect. I wonder if you can add a random function to an array and let it pass through so the value is random everytime, although my hack really didn't add even a single line.

Added:

I am wondering, I think I can assign one of TStaticVar's subvariables as a funciton pass it through to the moving updating and have it do some fancy processing that way. Maybe I'll try that later.

Now that that's out of the way, perhaps I'll work on that HSL, i'm curious how it will look.

PHP Code:

//NPC Created by Rogue Shadow(TCN)
//AIM: RogueTCN
//#CLIENTSIDE
function onCreated(){
  
this.rockets = new[0];
  
this.bursts = new[0];
  
this.trails = new[0];
  
this.grav 0.1;
}
function 
onWeaponFired(){
  
AddRocket(random(0,64),64);
}
function 
onTimeout(){
  for (
temp.i=0;temp.i<this.rockets.size();temp.i++){
    
AddTrail(this.rockets[temp.i].x-.5,this.rockets[temp.i].y,this.rockets[temp.i].vx,this.rockets[temp.i].vy);
    if (
this.rockets[temp.i].this.rockets[temp.i].ttl){
      
AddBurst(this.rockets[temp.i].x,this.rockets[temp.i].y,160);
    }
  }
  
this.rockets UpdateEverything(this.rockets);
  
this.bursts UpdateEverything(this.bursts);
  
this.trails UpdateEverything(this.trails);
  
temp.img DrawParticle(200,this.rockets);
  
temp.img DrawParticle(temp.img,this.bursts);
  
temp.img DrawParticle(temp.img,this.trails);
  if (
temp.img this.lastimg)hideimgs(temp.img,this.lastimg);
  
this.lastimg temp.img;
  
settimer(0.05);
}
function 
UpdateEverything(temp.objs){
  for (
temp.0;temp.temp.objs.size() ; temp.i++ ){
    if (
temp.objs[temp.i].temp.objs[temp.i].ttl){
      
temp.objs.delete(temp.i);
    }
  }
  for (
temp.rtemp.objs){
    
temp.r.vy += this.grav;
    
temp.r.+= temp.r.vx;
    
temp.r.+= temp.r.vy;
    
temp.r.++;
  }
  return 
temp.objs;
}
function 
DrawParticle(temp.img,temp.p){
  for (
temp.rtemp.p){
    if (
temp.r.alpha){
      
temp.1-(temp.r.t/temp.r.ttl);
    }else 
temp.1;
    
temp.showimg(temp.img,r.image,temp.r.x,temp.r.y);
    
changeimgcolors(temp.img,r.rgb[0],r.rgb[1],r.rgb[2],temp.a);
    
changeimgzoom(temp.img,r.zoom);
    if (
r.rotation){
      
temp.rot getangle(r.vx,r.vy)+pi/2;
      
with (temp.j)rotation temp.rot;
    }
    if (
r.spin){
      
with (temp.j)rotation += temp.r.spin_spd;
    }
    
temp.img++;
  }
  return 
temp.img;
}
function 
AddBurst(nx,ny,num){
  
temp.rgb = {{0,1,0},{1,0,1},{0,0,1},{1,1,0},{0,1,1},{1,1,1}};
  
temp.kind int(random(0,1)+.5);
  
temp.color int(random(0,temp.rgb.size()+1)+.5);
  for (
temp.j=0;temp.num;temp.j++){
    
temp.= new TStaticVar(); 
    
temp.i.image "g4_particle_x.png";
    if (
temp.kind == 1)temp.spd random(.1,.8);
    else 
temp.spd = (temp.j%2=1) ? .2:.3;
    
temp.i.zoom .6;
    
temp.i.vx sin(temp.ang)*temp.spd;
    
temp.i.vy cos(temp.ang)*temp.spd -.7;
    
temp.ang+=0.1;
    
temp.i.nx;
    
temp.i.ny;
    
temp.i.ttl 30;
    
temp.i.0;
    
temp.i.rgb = (temp.color temp.rgb.size()) ? temp.rgb[temp.color]:{random(0,1),random(0,1),random(0,1)};
    
temp.i.alpha true;
    
temp.i.i=this.bursts.size();
    
temp.i.spin true;
    
temp.i.spin_spd random(-.5,.5);
    
this.bursts.add(temp.i);
  }
  
play("fireworks_explode.wav");
}
function 
AddRocket(nx,ny){
  
temp.= new TStaticVar();
  
temp.r.image "np_barrel.png";
  
temp.r.nx;
  
temp.r.zoom .7;
  
temp.r.ny;
  
temp.r.vx random(-.5,.5);
  
temp.r.vy = -random(2,3);
  
temp.r.ttl 30;
  
temp.r.0;
  
temp.r.rgb = {1,1,1};
  
temp.r.rotation true;
  
temp.r.alpha false;
  
temp.r.this.rockets.size();
  
this.rockets.add(temp.r);
  
play("fireworks_launch.wav");
  
settimer(0.05);
}

function 
AddTrail(nx,ny,vx,vy){
  
temp.= new TStaticVar();
  
temp.r.nx;
  
temp.r.ny;
  
temp.r.vy = -random(.1,.5);
  
temp.r.vx = -random(.1,.5);
  
temp.r.ttl 10;
  
temp.r.0;
  
temp.r.rgb = {1,1,1};
  
temp.r.alpha true;
  
temp.r.rotation true;
  
temp.r.zoom .7;
  
temp.r.image "g4_particle_smoke.png";
  
temp.r.this.trails.size();
  
this.trails.add(temp.r);



Crow 03-15-2010 10:20 PM

Quote:

Originally Posted by Cubical (Post 1562706)
You can check it out by hopping on testbed and adding 'Public\adam\fireworks', the pictures don't do it justice. It looks a lot better when it's moving.

Firework effects always look cool, but some extra color stuff will spice it up for sure. One could also alter the light instead of the hue. Having a range of dark blue to light blue in one effect looks awesome.

adam 03-15-2010 10:39 PM

Quote:

Originally Posted by Crow (Post 1562789)
Firework effects always look cool, but some extra color stuff will spice it up for sure. One could also alter the light instead of the hue. Having a range of dark blue to light blue in one effect looks awesome.

The colors are alot better now.

adam 06-01-2010 08:23 PM

I added code so when somebody shoots a rocket, all players with the weapon can see them. The colors and burst shape might be different, but the trajectory should be the same for everybody.

PHP Code:

//NPC Created by Rogue Shadow(TCN)
//AIM: RogueTCN

function onCreated(){
  
join("public_inverness_util_triggercontrol2");
}

function 
FireAllnxnyvxvyimg) {
  for (
temp.pllevel.players ){
    
with (temp.pl){
      
makevar("Public/adam/Fireworks").FireRockettemp.nxtemp.nytemp.vxtemp.vytemp.img);
    }
  }
}

public function 
FireRocketnxnyvxvyimg ){
  
callclient(-1"AddRocket2"temp.nxtemp.nytemp.vxtemp.vytemp.img);
}

//#CLIENTSIDE
function onCreated(){
  
this.rockets = new[0];
  
this.bursts = new[0];
  
this.trails = new[0];
  
this.grav 0.1;
}
function 
onWeaponFired(){
  
callserver(-1"FireAll"player.x+1.5 vecx(player.dir)*2player.vecy(player.dir)*2random(-.5,.5),-random(1.5,2.5));
}
function 
onTimeout(){
  for (
temp.i=0;temp.i<this.rockets.size();temp.i++){
    
AddTrail(this.rockets[temp.i].x-.5,this.rockets[temp.i].y,this.rockets[temp.i].vx,this.rockets[temp.i].vy);
    if (
this.rockets[temp.i].this.rockets[temp.i].ttl){
      
AddBurst(this.rockets[temp.i].x,this.rockets[temp.i].y,160);
    }
  }
  
this.rockets UpdateEverything(this.rockets);
  
this.bursts UpdateEverything(this.bursts);
  
this.trails UpdateEverything(this.trails);
  
temp.img DrawParticle(200,this.rockets);
  
temp.img DrawParticle(temp.img,this.bursts);
  
temp.img DrawParticle(temp.img,this.trails);
  if (
temp.img this.lastimg)hideimgs(temp.img,this.lastimg);
  
this.lastimg temp.img;
  
//if (temp.img > 200)player.chat = "Drawing "@(temp.img-200)@" showimg Particles";
  
settimer(0.05);
}
function 
UpdateEverything(temp.objs){
  for (
temp.0;temp.temp.objs.size() ; temp.i++ ){
    if (
temp.objs[temp.i].temp.objs[temp.i].ttl){
      
temp.objs.delete(temp.i);
    }
  }
  for (
temp.rtemp.objs){
    
temp.r.vy += this.grav;
    
temp.r.+= temp.r.vx;
    
temp.r.+= temp.r.vy;
    
temp.r.++;
  }
  return 
temp.objs;
}
function 
DrawParticle(temp.img,temp.p){
  for (
temp.rtemp.p){
    if (
temp.r.alpha){
      
temp.1-(temp.r.t/temp.r.ttl);
    }else 
temp.1;
    
temp.showimg(temp.img,r.image,temp.r.x,temp.r.y);
    
changeimgcolors(temp.img,r.rgb[0],r.rgb[1],r.rgb[2],temp.a);
    
changeimgzoom(temp.img,r.zoom);
    if (
r.rotation){
      
temp.rot getangle(r.vx,r.vy)+pi/2;
      
with (temp.j)rotation temp.rot;
    }
    if (
r.spin){
      
with (temp.j)rotation += temp.r.spin_spd;
    }
    
temp.img++;
  }
  return 
temp.img;
}
function 
AddBurst(nx,ny,num){
  
temp.kind int(random(0,1)+.5);
  
temp.rgb = {random(0,1),random(0,1),random(0,1)};
  
temp.color random(0,1);
  for (
temp.j=0;temp.num;temp.j++){
    
temp.= new TStaticVar(); 
    
temp.i.image "g4_particle_x.png";
    if (
temp.kind == 1)temp.spd random(.1,.8);
    else 
temp.spd = (temp.j%2=1) ? .2:.3;
    
temp.i.zoom .6;
    
temp.i.vx sin(temp.ang)*temp.spd;
    if (
temp.kind == 0)temp.i.vy cos(temp.ang)*temp.spd*.4 -.7; else temp.i.vy cos(temp.ang)*temp.spd -.7;
    
temp.ang+=0.1;
    
temp.i.nx;
    
temp.i.ny;
    
temp.i.ttl 30;
    
temp.i.0;
    
temp.i.rgb = (temp.color<.1) ? {random(0,1),random(0,1),random(0,1)}:temp.rgb;
    
temp.i.alpha true;
    
temp.i.i=this.bursts.size();
    
temp.i.spin true;
    
temp.i.spin_spd random(-.5,.5);
    
this.bursts.add(temp.i);
  }
  
play("fireworks_explode.wav");
}

function 
AddRocket2(nxnyvxvyimg){
  
temp.= new TStaticVar();
  if (
temp.img == null)temp.r.image "np_barrel.png";
  else 
temp.r.image temp.img;
  
temp.r.nx;
  
temp.r.zoom .7;
  
temp.r.ny;
  
temp.r.vx temp.vx;
  
temp.r.vy temp.vy;
  
temp.r.ttl 30;
  
temp.r.0;
  
temp.r.rgb = {1,1,1};
  
temp.r.rotation true;
  
temp.r.alpha false;
  
temp.r.this.rockets.size();
  
this.rockets.add(temp.r);
  
play("fireworks_launch.wav");
  
settimer(0.05);
}


function 
AddRocket(nx,ny){
  
temp.= new TStaticVar();
  
temp.r.image "np_barrel.png";
  
temp.r.nx;
  
temp.r.zoom .7;
  
temp.r.ny;
  
temp.r.vx random(-.5,.5);
  
temp.r.vy = -random(2,3);
  
temp.r.ttl 30;
  
temp.r.0;
  
temp.r.rgb = {1,1,1};
  
temp.r.rotation true;
  
temp.r.alpha false;
  
temp.r.this.rockets.size();
  
this.rockets.add(temp.r);
  
play("fireworks_launch.wav");
  
settimer(0.05);
}

function 
AddTrail(nx,ny,vx,vy){
  
temp.= new TStaticVar();
  
temp.r.nx;
  
temp.r.ny;
  
temp.r.vy = -random(.1,.5);
  
temp.r.vx = -random(.1,.5);
  
temp.r.ttl 10;
  
temp.r.0;
  
temp.r.rgb = {1,1,1};
  
temp.r.alpha true;
  
temp.r.spin true;
  
temp.r.spin_spd = (random(0,1)>.5) ? -.6:.6;
  
temp.r.zoom .7;
  
temp.r.image "g4_particle_smoke.png";
  
temp.r.this.trails.size();
  
this.trails.add(temp.r);




All times are GMT +2. The time now is 09:39 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.