• Main Page
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

D:/Projekt/ECF_trunk/examples/GPSpaceFlight/SpaceFlight.GUI/MouseShipController.cs

00001 using System;
00002 using System.Windows.Input;
00003 using SpaceFlight.Simulation;
00004 
00005 namespace SpaceFlight.GUI
00006 {
00007   public class MouseShipController : IShipController
00008   {
00009     SimulationView view;
00010 
00011     public MouseShipController(SimulationView view)
00012     {
00013       this.view = view;
00014     }
00015 
00016     public void UpdateShip(TestCase testCase, Vector2D gravity)
00017     {
00018       if (Mouse.PrimaryDevice.LeftButton == MouseButtonState.Pressed)
00019       {
00020         var mousePoint = view.GetTransform().Inverse.Transform(Mouse.PrimaryDevice.GetPosition(view));
00021         var mouseVector = new Vector2D { X = mousePoint.X, Y = mousePoint.Y };
00022         var difference = mouseVector - testCase.Ship.Position;
00023         testCase.Ship.Turn = Vector2D.Angle(testCase.Ship.Direction, difference);
00024       }
00025       else
00026       {
00027         testCase.Ship.Turn = 0;
00028       }
00029     }
00030   }
00031 }

Generated on Tue Oct 23 2012 11:14:22 for ECF by  doxygen 1.7.1