예제 #1
0
        public Collider(float x, float y, float sizeX, float sizeY)
        {
            Box = new Box2D(x, y, sizeX, sizeY);
            //make a hsb color sweep in polar coordinates
            var polar = MathHelper.ToPolar(new Vector2(x, y));
            var rgb   = ColorSystems.Hsb2rgb(polar.X / MathHelper.TWO_PI + 0.5f, polar.Y, 1);

            Color    = ColorSystems.ToSystemColor(rgb);
            Velocity = Vector2.Zero;
        }
예제 #2
0
        private void InitParticles()
        {
            var          rnd      = new Random(12);
            Func <float> Rnd01    = () => (float)rnd.NextDouble();
            Func <float> RndCoord = () => (Rnd01() - 0.5f) * 2.0f;
            Func <float> RndSpeed = () => (Rnd01() - 0.5f) * 0.1f;

            bufferParticles = new BufferObject(BufferTarget.ShaderStorageBuffer);

            var data = new Particle[particelCount];

            for (int i = 0; i < particelCount; ++i)
            {
                data[i].position = new Vector2(RndCoord(), RndCoord());
                data[i].velocity = new Vector2(RndSpeed(), RndSpeed());
                var polar     = MathHelper.ToPolar(data[i].position);
                var color     = ColorSystems.Hsb2rgb(polar.X / MathHelper.TWO_PI + 0.5f, polar.Y, 1);
                var byteColor = ColorSystems.ToSystemColor(color);
                data[i].color = color;
                data[i].size  = (Rnd01() + 1) * 10;
            }
            bufferParticles.Set(data, BufferUsageHint.StaticCopy);
        }