View Single Post
  #2  
Old 07-20-2017, 03:33 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Changed it from using built-in variables (e.g. this.x, this.y).

Changed it to a regular timeout instead of while true loop.

function looplights doesn't seem to do anything so I removed that as well.

Made showimg use 200+ for the IDs so they aren't displayed globally.

PHP Code:
//#CLIENTSIDE

function onPlayerEnters() {
  
seteffect(0.10.0500.03);
  
this.balls 50;
  
this.balls_angle = new[this.balls];
  
this.balls_x = new[this.balls];
  
this.balls_y = new[this.balls];
  
this.balls_radx = new[this.balls];
  
this.balls_rady = new[this.balls];
  
this.balls_dir = new[this.balls];
  
this.balls_speed = new[this.balls];
  for (
temp.0temp.this.ballstemp.i++) {
    
init_ball(temp.i);
  }
  
onTimeout();
}

function 
onTimeout() {
  for (
temp.0temp.this.ballstemp.i++) {
    if (
this.balls_angle[temp.iin |1.55,4.70|) {
      
init_ball(temp.i);
    } else {
      
this.balls_angle[temp.i] += this.balls_speed[temp.i];    // Move ball
      
this.balls_angle[temp.i] = this.balls_angle[temp.i] % 6.3// Make sure angle stays between 0 and 6.3
      
showimg(200+temp.i,"light2.png",this.balls_x[temp.i]-this.balls_radx[temp.i]*sin(this.balls_angle[temp.i])*this.balls_dir[temp.i],this.balls_y[temp.i]-this.balls_rady[temp.i]*cos(this.balls_angle[temp.i]));
      
changeimgcolors(200+temp.i,0,random(0.1,0.1),.1,0.99);
      
changeimgzoom(200+temp.i,random(0.15,0.35));
    }
  }
  
setTimer(0.05);
}

function 
init_ball(i) {
  
this.balls_x[i] = random(0,60);
  
this.balls_y[i] = random(0,62);
  
this.balls_radx[i] = random(0,2);
  
this.balls_rady[i] = random(2,8);
  
this.balls_angle[i] = 4.75;
  
this.balls_speed[i] = random(0.1,0.4);
  
this.balls_dir[i] = int(random(0,2))*2-1;

note: completely untested, but did verify it compiles successfully in a class script.
__________________
Quote:
Reply With Quote