View Single Post
  #3  
Old 03-15-2010, 08:53 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
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];
Reply With Quote