Exemplo n.º 1
0
        public LaserParticle(Vector2 position, Vector2 velocity)
        {
            this.position = position;
            velocity.Normalize();

            this.velocity = velocity * SPEED;

            next = null;
            prev = null;
        }
Exemplo n.º 2
0
        private void DrawLaserForParticlePair(LaserParticle a, LaserParticle b, SpriteBatch batch)
        {
            Vector2 direction = a.Position - b.Position;

            float radians = (float)Math.Atan2(direction.Y, direction.X);
            float length = Vector2.Distance(b.Position, a.Position);

            Rectangle dest = new Rectangle((int)b.Position.X, (int)b.Position.Y - 1, (int)length, 2);
            /* texture is a 'CIRCLE', so pull a chunk out of it! */
            Rectangle source = new Rectangle(5, 5, 1, 1);

            batch.Draw(laser, dest, source, color, radians, new Vector2(0, 1), SpriteEffects.None, 1f);
        }
Exemplo n.º 3
0
        private void construct(Vector2 position, Vector2 velocity, Color color)
        {
            head = new LaserParticle(position, velocity);
            tail = new LaserParticle(position, velocity);

            head.Next = tail;
            tail.Prev = head;
            this.color = color;
        }
Exemplo n.º 4
0
        public void AppendParticle(LaserParticle addition)
        {
            LaserParticle penultimate = tail;

            // penultimate.Prev already is correct
            penultimate.Next = addition;
            addition.Prev = penultimate;
            addition.Next = null;

            tail = addition;
        }
Exemplo n.º 5
0
 private void LaserUpdate(GameTime gameTime)
 {
     if (m_generating != null)
     {
         Vector2 velocity = Vector2.Transform(Vector2.UnitX, Matrix.CreateRotationZ(this.orientation));
         LaserParticle newParticle = new LaserParticle(laserStart, velocity);
         m_generating.AppendParticle(newParticle);
     }
 }