Esempio n. 1
0
 public void Sprite_Constructor_Test()
 {
     var texture = new Texture(Device, Path.Combine(RenderSettings.MediaPath, "Test/fatship256.tga"), "");
     var sprite = new Sprite(texture);
     Assert.AreEqual(texture, sprite.Texture);
     Assert.AreEqual(Color.White, sprite.Color);
 }
Esempio n. 2
0
        private void AddSprite()
        {
            // Linear velocity
            float variation = (random.Next(Spread) - Spread / 2) / 100.0f;
            Radian dir = (Direction - new Radian(MathUtils.PI / 2)).Wrap(new Radian(MathUtils.PI * 2));
            Vector2 velocity = new Vector2(MathUtils.Cos(dir) + variation, MathUtils.Sin(dir) + variation);

            // Random color based on ranges
            int a = random.Next(ColorRange.Min.IntA, ColorRange.Max.IntA);
            int r = random.Next(ColorRange.Min.IntR, ColorRange.Max.IntR);
            int g = random.Next(ColorRange.Min.IntG, ColorRange.Max.IntG);
            int b = random.Next(ColorRange.Min.IntB, ColorRange.Max.IntB);
            Color color = new Color(a, r, g, b);

            Sprite sprite = new Sprite(this.texture)
            {
                Position = this.Position,
                Velocity = velocity * this.Velocity,
                Color = color,
                Scale = new Vector2(this.Scale, this.Scale)
            };

            this.sprites.Add(sprite);
        }