IPhysicsBody IPhysicsBody.ImpulsePass(Vector2 gravity, float deltaT) { WorldPoint secOrigin = new WorldPoint(Position.Sector, Vector2.Zero); Vector2 f = Forces + gravity; Vector2 a = GetAccel(f, Mass); Vector2 p = Position.PixelDistance(secOrigin); Vector2 newP = GetNewPosition(p, a, Velocity, deltaT); Vector2 newVelocity = GetNewVelocity(a, Velocity, deltaT); WorldPoint newPosition = secOrigin.PixelTranslate(newP); return(new RigidBody(this, position: newPosition, velocity: newVelocity, forces: Vector2.Zero)); }
internal SoundSource UpdateInstances(WorldPoint listenerPos, Core.Audio.Mixer.Channels.State channelState) { List <SoundInstance> newInstances = new List <SoundInstance>(); foreach (SoundInstance instc in SoundInstances) { SoundInstance newInstc = instc.Update(channelState.Channels[instc.Channel]); if (newInstc.Progress < 1) { Vector2 newOffset = Position.PixelDistance(listenerPos); newInstc = newInstc.Reposition(newOffset); newInstances.Add(newInstc); } } return(new SoundSource(Position, newInstances)); }
/// <summary> /// Converts the given world-space position to a viewport-space position. /// </summary> /// <param name="position">The position to convert.</param> /// <returns>A <see cref="ScreenPoint"/> in viewport-space.</returns> public ScreenPoint WorldToViewportPosition(WorldPoint position) { return((ScreenPoint)(position.PixelDistance(this.Position))); }