当前位置: 首页>>代码示例>>C#>>正文


C# IRenderer.AcquireAuto方法代码示例

本文整理汇总了C#中IRenderer.AcquireAuto方法的典型用法代码示例。如果您正苦于以下问题:C# IRenderer.AcquireAuto方法的具体用法?C# IRenderer.AcquireAuto怎么用?C# IRenderer.AcquireAuto使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IRenderer的用法示例。


在下文中一共展示了IRenderer.AcquireAuto方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Update

        public void Update(IRenderer renderer, double time)
        {
            using (var g = renderer.AcquireAuto())
            {
                // When the user moves the window we make the particles react to
                // this movement. The reaction is semi-random and not physically
                // correct. It looks quite good, however.
                if (position_changed)
                {
                    for (int i = 0; i < Particles.Count; i++)
                    {
                        Particle p = Particles[i];
                        p.Velocity += new Vector2(
                            16 * (position_dx + 0.05f * (float)(rand.NextDouble() - 0.5)),
                            32 * (position_dy + 0.05f * (float)(rand.NextDouble() - 0.5)));
                        Particles[i] = p;
                    }

                    position_changed = false;
                }
            }

            // For simplicity, we use simple Euler integration to simulate particle movement.
            // This is not accurate, especially under varying timesteps (as is the case here).
            // A better solution would have been time-corrected Verlet integration, as
            // described here:
            // http://www.gamedev.net/reference/programming/features/verlet/
            for (int i = 0; i < Particles.Count; i++)
            {
                Particle p = Particles[i];

                p.Velocity.X = Math.Abs(p.Position.X) >= 1 ? -p.Velocity.X * 0.92f : p.Velocity.X * 0.97f;
                p.Velocity.Y = Math.Abs(p.Position.Y) >= 1 ? -p.Velocity.Y * 0.92f : p.Velocity.Y * 0.97f;
                if (p.Position.Y > -0.99)
                {
                    p.Velocity.Y += (float)(GravityAccel * time);
                }
                else
                {
                    if (Math.Abs(p.Velocity.Y) < 0.02)
                    {
                        p.Velocity.Y = 0;
                        p.Position.Y = -1;
                    }
                    else
                    {
                        p.Velocity.Y *= 0.9f;
                    }
                }

                p.Position += p.Velocity * (float)time;
                if (p.Position.Y <= -1)
                    p.Position.Y = -1;

                Particles[i] = p;
            }
        }
开发者ID:diclogic,项目名称:cocktailvm,代码行数:57,代码来源:BounceDemo.cs


注:本文中的IRenderer.AcquireAuto方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。