Changeset 15

Show
Ignore:
Timestamp:
12/08/07 04:40:37 (1 year ago)
Author:
charlie137
Message:

Added random angle when saucer fire

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/guisterax/src/saucer.d

    r10 r15  
    9494        Vect f_target = target.pos + 20 * target.speed; 
    9595        Vect speed = this.speed + 4 * (f_target - pos).normal(); 
     96        speed.rotate(rand(-0.2, 0.2));  // we add a random angle to the fire 
    9697        m_fire_sound.play(); 
    9798        universe.append(new Saucer.Fire(pos, speed), this); 
  • trunk/guisterax/src/vect.d

    r10 r15  
    5959    float norm() {return sqrt(norm2());} 
    6060    Vect normal() {assert(norm2() != 0); return *this / norm();} 
     61     
     62    // Rotate the vector by angle a (in rad) 
     63    void rotate(float a) { 
     64        float c = cos(a); 
     65        float s = sin(a); 
     66        x = x * c - y * s; 
     67        y = x * s + y * c; 
     68    } 
    6169}; 
    6270