本文整理汇总了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;
}
}