コード例 #1
0
ファイル: Desktop.cs プロジェクト: zhuangfangwang/ise
		public Desktop()
		{
			windowToBody = new Dictionary<Window, Body>();
			contactJoints = new Dictionary<int, FixedHingeJoint>();
			engine = new PhysicsEngine();
			engine.BroadPhase = new SweepAndPruneDetector();
			engine.Solver = new SequentialImpulsesSolver();
			timer = new PhysicsTimer(PhysicsTimerCallback, 0.01);
			timer.IsRunning = true;

			injectorClass = new DWMInjectorClass();
			if (!injectorClass.IsInjected)
				injectorClass.Inject();
			injectorClass.GetDWMExObject(out dwm);
			Debug.Assert(dwm != null, "DWM is NULL");

			windowManager = new WindowManager();
			windowManager.WindowCreated += windowManager_WindowCreated;
			windowManager.WindowDestroyed += windowManager_WindowDestroyed;
			windowManager.Register(MessageEvents.Handle);

			ThreadPool.QueueUserWorkItem(delegate
										 {
											 hook = new LowLevelMouseHook(MouseHook);
											 hook.StartHook();
											 Application.Run();
										 });
		}
コード例 #2
0
ファイル: Window.cs プロジェクト: timdetering/Physics2D.Net
 public Window(Size size)
 {
     this.size = size;
     this.drawTimer = new PhysicsTimer(GraphicsProcess, .01f);
     this.viewports = new PendableCollection<Window, Viewport>(this);
     this.syncRoot = new object();
     this.rwLock = new AdvReaderWriterLock();
 }
コード例 #3
0
        public override void Init(PrototypingFramework.engine.GameEngine game)
        {
            base.Init(game);
            world = new PhysicsEngine();
            world.BroadPhase = new Physics2DDotNet.Detectors.SelectiveSweepDetector();
            world.Solver = new Physics2DDotNet.Solvers.SequentialImpulsesSolver();

            PhysicsTimer timer = new PhysicsTimer(world.Update, .01f);
            timer.IsRunning = true;

            rs = new RectangleShape(new SFML.Window.Vector2f(10, 10));
            rs.FillColor = Color.Black;
            rs.Position = new SFML.Window.Vector2f(10, 5);

            Coefficients coffecients = new Coefficients(/*restitution*/1, /*friction*/.5f);
            IShape shape2 = new PolygonShape(VertexHelper.CreateRectangle(10, 20), 3);
             body2 = new Body(new PhysicsState(new ALVector2D(0,10,5)), shape2, 5, coffecients, new Lifespan());

            world.AddBody(body2);

            PhysicsLogic logGravity;

            logGravity = (PhysicsLogic)new GravityField(new Vector2D(0f, 200f), new Lifespan());
            //pretty basic, create a downward force

            world.AddLogic(logGravity);

            Body bdyFloor;
            PhysicsState flrState;
            PolygonShape flrShape;
            Coefficients flrCoff;
            Lifespan flrLife;

            flrState = new PhysicsState(new ALVector2D((float)0.0, 0, (float)_game.Window.Size.Y-64));
            //create the state, centering the x-axis on screen and bottom of the y-axis

            flrShape = new PolygonShape(VertexHelper.CreateRectangle(_game.Window.Size.X, 64), 2);
            //create form.widthX64 rectangle (sq) with grid spacing at 2

            flrCoff = new Coefficients(0.5f, 0.4f, 0.4f);
            //might require tuning to your liking...

            flrLife = new Lifespan();
            //forever and ever

            bdyFloor = new Body(flrState, flrShape, float.PositiveInfinity, flrCoff, flrLife);
            //never ending mass means it isn't going to move on impact

            bdyFloor.IgnoresGravity = true;
            //make sure the floor stays

            world.AddBody(bdyFloor);

            floor = new RectangleShape(new SFML.Window.Vector2f( _game.Window.Size.X,64));
            floor.Position = new SFML.Window.Vector2f(0, _game.Window.Size.Y - 64);
            floor.FillColor = Color.Red;
        }
コード例 #4
0
ファイル: TouchablePanel.cs プロジェクト: zhuangfangwang/ise
        /// <summary>
        /// Initializes a new instance of the <see cref="TouchablePanel"/> class.
        /// </summary>
        public TouchablePanel()
        {
			elementToBody = new Dictionary<FrameworkElement, Body>();
            shouldCreateBody = new List<FrameworkElement>();
            shouldRemoveBody = new List<FrameworkElement>();
            contactJoints = new Dictionary<int, FixedHingeJoint>();
            elementToScale = new Dictionary<FrameworkElement, ScaleState>();
            ignorer = new ObjectIgnorer();

            engine = new PhysicsEngine();
            engine.BroadPhase = new SweepAndPruneDetector();
            engine.Solver = new SequentialImpulsesSolver();
            timer = new PhysicsTimer(PhysicsTimerCallback, 0.01);

            Loaded += TouchablePanel_Loaded;
        }
コード例 #5
0
ファイル: Will.cs プロジェクト: homoluden/fukami
        private Will()
        {
            _engine = new PhysicsEngine
                {
                    BroadPhase = new Physics2DDotNet.Detectors.SelectiveSweepDetector(),
                    Solver = new Physics2DDotNet.Solvers.SequentialImpulsesSolver
                        {
                            AllowedPenetration = 0.0001f
                        }
                };
            _engine.AddLogic(new GravityField(new Vector2D(0, -300), new Lifespan()));

            _engine.Updated += OnEngineUpdated;

            _timer = new PhysicsTimer(_engine.Update, .005f);
        }
コード例 #6
0
ファイル: ScrollViewer.cs プロジェクト: zhuangfangwang/ise
		/// <summary>
		/// Initializes a new instance of the <see cref="ScrollViewer"/> class.
		/// </summary>
		public ScrollViewer()
		{
			borderSoftness = BorderSoftness;

			AddHandler(MultitouchScreen.NewContactEvent, (NewContactEventHandler)OnNewContact);
			AddHandler(MultitouchScreen.ContactMovedEvent, (ContactEventHandler)OnContactMoved);
			AddHandler(MultitouchScreen.ContactRemovedEvent, (ContactEventHandler)OnContactRemoved);
			AddHandler(MultitouchScreen.ContactLeaveEvent, (ContactEventHandler)OnContactLeave);	

			engine = new PhysicsEngine();
			engine.BroadPhase = new SweepAndPruneDetector();
			engine.Solver = new SequentialImpulsesSolver();
			engine.AddLogic(new BoundsConstrainLogic(this));
			timer = new PhysicsTimer(PhysicsTimerCallback, 0.01);

			Loaded += ScrollViewer_Loaded;
		}
コード例 #7
0
ファイル: Demo.cs プロジェクト: bsvercl/physics2d
        public Demo()
        {

            Events.MouseButtonDown += new EventHandler<SdlDotNet.Input.MouseButtonEventArgs>(Events_MouseButtonDown);
            Events.MouseButtonUp += new EventHandler<SdlDotNet.Input.MouseButtonEventArgs>(Events_MouseButtonUp);
            Events.KeyboardDown += new EventHandler<SdlDotNet.Input.KeyboardEventArgs>(Events_KeyboardDown);
            Events.KeyboardUp += new EventHandler<SdlDotNet.Input.KeyboardEventArgs>(Events_KeyboardUp);
            Events.MouseMotion += new EventHandler<SdlDotNet.Input.MouseMotionEventArgs>(Events_MouseMotion);
            objects = new List<OpenGlObject>();



            font = new Font(Path.Combine(dataDir, "FreeSans.ttf"), 40);
            font.Bold = true;
            font2 = new Font(Path.Combine(dataDir, "FreeSans.ttf"), 15);
            font2.Bold = true;
            pauseSprite = new SurfaceGl(font.Render("PAUSED", System.Drawing.Color.White, System.Drawing.Color.Black, true));
            upsSprite = new SurfaceGl(font2.Render("UPS:", System.Drawing.Color.White, System.Drawing.Color.Black, true));
            CreateNumbers();

            CreateEngine();
            timer = new PhysicsTimer(Update, .010f);

            CreateBomb();
            CreateAvatar();
            CreateClipper();
            Demo1();
        }
コード例 #8
0
 private void InitializePhysicsEngine()
 {
     _engine = new PhysicsEngine();
     _engine.BroadPhase = new SpatialHashDetector();
     _engine.Solver = new SequentialImpulsesSolver();
     _timer = new PhysicsTimer(PhysicsTimerCallback, 0.02f);
 }
コード例 #9
0
ファイル: Scene.cs プロジェクト: timdetering/Physics2D.Net
 public Scene()
 {
     this.syncRoot = new object();
     this.engine = new PhysicsEngine();
     this.rwLock = new AdvReaderWriterLock();
     this.timer = new PhysicsTimer(Update, .01f);
     this.graphics = new PendableCollection<Scene, Graphic>(this);
     this.viewports = new List<Viewport>();
     this.bodies = new List<Body>();
     this.joints = new List<Joint>();
     this.physicsLogics = new List<PhysicsLogic>();
 }