Пример #1
0
 public Round(PhysicsSimulator simulator, Game game, object initializationData)
 {
     this.game = game;
     this.simulator = simulator;
     this.initializationData = initializationData;
     this.Construct();
 }
Пример #2
0
        public override void Initialize()
        {
            ClearCanvas();
            physicsSimulator = new PhysicsSimulator(new Vector2(0, 100));
            physicsSimulator.BiasFactor = .4f;
            int borderWidth = (int) (ScreenManager.ScreenHeight*.05f);
            _border = new Border(ScreenManager.ScreenWidth + borderWidth*2, ScreenManager.ScreenHeight + borderWidth*2,
                                 borderWidth, ScreenManager.ScreenCenter);
            _border.Load(this, physicsSimulator);
            _rectangleBody = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, 32, 32, 1f);
            _rectangleGeom = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, _rectangleBody, 32, 32);
            _rectangleGeom.FrictionCoefficient = .4f;
            _rectangleGeom.RestitutionCoefficient = 0f;

            //create the pyramid near the bottom of the screen.
            _pyramid = new Pyramid(_rectangleBody, _rectangleGeom, 32f/3f, 32f/3f, 32, 32, _pyramidBaseBodyCount,
                                   new Vector2(ScreenManager.ScreenCenter.X - _pyramidBaseBodyCount*.5f*(32 + 32/3),
                                               ScreenManager.ScreenHeight - 125));
            _pyramid.Load(this, physicsSimulator);

            _floor = new Floor(ScreenManager.ScreenWidth, 100,
                               new Vector2(ScreenManager.ScreenCenter.X, ScreenManager.ScreenHeight - 50));
            _floor.Load(this, physicsSimulator);

            _agent = new Agent(ScreenManager.ScreenCenter - new Vector2(320, 300));
            _agent.Load(this, physicsSimulator);
            controlledBody = _agent.Body;
            base.Initialize();
        }
Пример #3
0
        public void Load(TangramWindow window, PhysicsSimulator physicsSimulator)
        {
            //use the body factory to create the physics body
            this._borderBody = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, this._width, this._height, 1);
            this._borderBody.IsStatic = true;
            this._borderBody.Position = _position;
            LoadBorderGeom(physicsSimulator);
            float left = (_position.X - this._width / 2f);
            float right = (_position.X + this._width / 2f);
            float top = (_position.Y - this._height / 2f);
            float bottom = (_position.Y + this._height / 2f);

            // rectangle's position should be the point left and top most
            Rectangle leftBorder = window.AddRectangleToCanvas(null, Color.FromArgb(128, 255, 255, 255), new Vector2(this._borderWidth, this._height));
            TangramWindow.PositionTopLeft(leftBorder, new Vector2(left, top));

            Rectangle rightBorder = window.AddRectangleToCanvas(null, Color.FromArgb(128, 255, 255, 255), new Vector2(this._borderWidth, this._height));
            TangramWindow.PositionTopLeft(rightBorder, new Vector2(right - _borderWidth, top));

            Rectangle topBorder = window.AddRectangleToCanvas(null, Color.FromArgb(128, 255, 255, 255), new Vector2(this._width, this._borderWidth));
            TangramWindow.PositionTopLeft(topBorder, new Vector2(left, top));

            Rectangle bottomBorder = window.AddRectangleToCanvas(null, Color.FromArgb(128, 255, 255, 255), new Vector2(this._width, this._borderWidth));
            TangramWindow.PositionTopLeft(bottomBorder, new Vector2(left, bottom - _borderWidth));
        }
Пример #4
0
        public void LoadBorderGeom(PhysicsSimulator physicsSimulator)
        {
            this._borderGeom = new Geom[4];

            //left border
            Vector2 geometryOffset = new Vector2(-(_width * 0.5f - this._borderWidth * 0.5f), 0);
            _borderGeom[0] = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, this._borderBody,
                                                                      this._borderWidth, this._height, geometryOffset, 0);
            this._borderGeom[0].RestitutionCoefficient = .2f;
            this._borderGeom[0].FrictionCoefficient = .5f;
            this._borderGeom[0].CollisionGroup = 100;

            //right border
            geometryOffset = new Vector2((this._width * 0.5f - this._borderWidth * 0.5f), 0);
            _borderGeom[1] = GeomFactory.Instance.CreateGeom(physicsSimulator, this._borderBody, this._borderGeom[0],
                                                             geometryOffset, 0);

            //top border
            geometryOffset = new Vector2(0, -(_height*0.5f - this._borderWidth*0.5f));
            this._borderGeom[2] = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, this._borderBody,
                                                                           this._width, this._borderWidth,
                                                                           geometryOffset, 0);
            this._borderGeom[2].FrictionCoefficient = this._borderGeom[2].RestitutionCoefficient = .2f;
            this._borderGeom[2].CollisionGroup = 100;

            //bottom border
            geometryOffset = new Vector2(0, _height * 0.5f - this._borderWidth * 0.5f);
            this._borderGeom[3] = GeomFactory.Instance.CreateGeom(physicsSimulator, this._borderBody,
                                                                  this._borderGeom[2], geometryOffset, 0);
        }
Пример #5
0
        public void Load(Demo demo, PhysicsSimulator physicsSimulator)
        {
            //use the body factory to create the physics body
            borderBody = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, width, height, 1);
            borderBody.IsStatic = true;
            borderBody.Position = position;
            LoadBorderGeom(physicsSimulator);
            float left = (position.X - width / 2f);
            float top = (position.Y - height / 2f);
            float right = (position.X + width / 2f);
            float bottom = (position.Y + height / 2f);

            Rectangle leftBorder = demo.AddRectangleToCanvas(null, Color.FromArgb(128, 255, 255, 255),
                                                     new Vector2(borderWidth, height));
            Demo.PositionTopLeft(leftBorder, new Vector2(left, top));

            Rectangle rightBorder = demo.AddRectangleToCanvas(null, Color.FromArgb(128, 255, 255, 255),
                                                     new Vector2(borderWidth, height));
            Demo.PositionTopLeft(rightBorder, new Vector2(right-borderWidth, top));

            Rectangle topBorder = demo.AddRectangleToCanvas(null, Color.FromArgb(128, 255, 255, 255),
                                                     new Vector2(width, borderWidth));
            Demo.PositionTopLeft(topBorder, new Vector2(left, top));

            Rectangle bottomBorder = demo.AddRectangleToCanvas(null, Color.FromArgb(128, 255, 255, 255),
                                                     new Vector2(width, borderWidth));
            Demo.PositionTopLeft(bottomBorder, new Vector2(left, bottom - borderWidth));
        }
Пример #6
0
        public void Load(Demo demo, PhysicsSimulator physicsSimulator)
        {
            _circleBody = new Body[_count];
            _circleGeom = new Geom[_count];

            _circleBody[0] = BodyFactory.Instance.CreateCircleBody(physicsSimulator, _radius, .1f);
            _circleBody[0].Position = _startPosition;
            demo.AddCircleToCanvas(_circleBody[0], _color, _radius);
            for (int i = 1; i < _count; i++)
            {
                _circleBody[i] = BodyFactory.Instance.CreateBody(physicsSimulator, _circleBody[0]);
                _circleBody[i].Position = Vector2.Lerp(_startPosition, _endPosition, i / (float)(_count - 1));
                demo.AddCircleToCanvas(_circleBody[i], _color, _radius);
            }

            _circleGeom[0] = GeomFactory.Instance.CreateCircleGeom(physicsSimulator, _circleBody[0], _radius, 10);
            _circleGeom[0].RestitutionCoefficient = .7f;
            _circleGeom[0].FrictionCoefficient = .2f;
            _circleGeom[0].CollisionCategories = _collisionCategories;
            _circleGeom[0].CollidesWith = _collidesWith;
            for (int j = 1; j < _count; j++)
            {
                _circleGeom[j] = GeomFactory.Instance.CreateGeom(physicsSimulator, _circleBody[j], _circleGeom[0]);
            }
        }
Пример #7
0
 //Constructor
 public MenuScreen(Game game)
     : base(game)
 {
     screenRect = new Rectangle(0, 0, 800, 600);
     shadeTexture = Game.Content.Load<Texture2D>("Media\\GUI\\Shade");
     physicsSim = new PhysicsSimulator(new Vector2(0.0f, 2.2f));
     //Load Menu screen content
     RigidEntity menuBottom = new RigidEntity("MenuBottom", Game.Content.Load<Texture2D>("Media\\Menus\\MainMenuBottom"), ref physicsSim, GeomType.Polygon);
     menuBottom.body.IsStatic = true;
     menuBottom.body.Position = new Vector2(menuBottom.Origin.X, 200+menuBottom.Origin.Y);
     RigidEntity EditorButton = new RigidEntity("BTN_Editor", Game.Content.Load<Texture2D>("Media\\Menus\\EditorButton"), ref physicsSim, GeomType.Circle);
     RigidEntity quitButton = new RigidEntity("BTN_Quit", Game.Content.Load<Texture2D>("Media\\Menus\\QuitButton"), ref physicsSim, GeomType.Circle);
     RigidEntity w1 = new RigidEntity("WALL1", ref physicsSim, new Vector2(-2.5f,300f), 5, 600);
     RigidEntity w2 = new RigidEntity("WALL2", ref physicsSim, new Vector2(802.5f, 300f), 5, 600);
     EditorButton.body.Position = new Vector2(200.0f, -220.0f);
     EditorButton.Friction = 1.0f;
     EditorButton.Restitution = 0.8f;
     menuBottom.Restitution = 0.3f;
     menuBottom.Friction = 0.8f;
     quitButton.body.Position = new Vector2(400.0f,-250.0f);
     quitButton.Friction = 1.0f;
     quitButton.Restitution = 0.4f;
     entityManager = new EntityManager();
     entityManager.Add(menuBottom);
     entityManager.Add(EditorButton);
     entityManager.Add(quitButton);
     entityManager.Add(w1);
     entityManager.Add(w2);
     shadeOpacity = 0;
 }
Пример #8
0
 protected override void Initialize(PhysicsSimulator simulator)
 {
     base.Initialize(simulator);
     this.Wind.RefreshRate = 2600;
     this.Wind.MaxXScale = 200;
     this.Wind.MaxYScale = 200;
 }
Пример #9
0
        protected override MapDefinition CreateMap(PhysicsSimulator simulator)
        {
            int random = Randomizer.Random.Next(2, 9);

            switch (random)
            {
                case 2:
                    this.map = new MapBDefinition(simulator);
                    break;
                case 3:
                    this.map = new MapCDefinition(simulator);
                    break;
                case 4:
                    this.map = new MapDDefinition(simulator);
                    break;
                case 5:
                    this.map = new MapEDefinition(simulator);
                    break;
                case 6:
                    this.map = new MapFDefinition(simulator);
                    break;
                case 7:
                    this.map = new MapGDefinition(simulator);
                    break;
                case 8:
                    this.map = new MapHDefinition(simulator);
                    break;
                default:
                    throw new Exception("Unknown random map index.");
            }

            return this.map;
        }
Пример #10
0
 public Wall(PhysicsSimulator simulator)
     : base(simulator)
 {
     this.simulator = simulator;
     this.Size = new Vector2(20, Screen.Height);
     this.Initialize();
 }
Пример #11
0
        public FieldPong()
        {
            graphics = new GraphicsDeviceManager(this);
            content = new ContentManager(Services);

            graphics.PreferredBackBufferWidth = 1024;
            graphics.PreferredBackBufferHeight = 768;
            graphics.MinimumPixelShaderProfile = ShaderProfile.PS_2_0;
            graphics.SynchronizeWithVerticalRetrace = true;

            physicsSimulator = new PhysicsSimulator(new Vector2(0));
            physicsSimulator.AllowedPenetration = 0.3f;
            physicsSimulator.BiasFactor = 1.0f;
            Services.AddService(typeof(PhysicsSimulator), physicsSimulator);

            screenManager = new ScreenManager(this);
            Components.Add(screenManager);

            bloomProcessor = new BloomPostProcessor(this);
            Components.Add(bloomProcessor);

            // Uncomment this to monitor the FPS:

            //fpsCounter = new FrameRateCounter(this);
            //Components.Add(fpsCounter);

            audioEngine = new AudioEngine("Content\\Audio\\FieldPongAudio.xgs");
            waveBank = new WaveBank(audioEngine, "Content\\Audio\\Wave Bank.xwb");
            soundBank = new SoundBank(audioEngine, "Content\\Audio\\Sound Bank.xsb");

            backgroundMusic = soundBank.GetCue("GameSong0010 16 Bit");
            backgroundMusic.Play();
        }
Пример #12
0
        //, int width)
        public Platform(string path, PhysicsSimulator pS)
        {
            bytes=File.ReadAllBytes(path+".bmp");
            int width = bytes[18];
            int heigth = bytes[22];

            for (int i = 0; i < width*heigth; i++)
                if (bytes[bytes.Length-1-i]==0)
                {
                    createRectangle(pS, i, width);
                }
                else if (bytes[bytes.Length - 1 - i] == 1)
                {
                    createTriangle(pS, i, width, Triangles.LeftRightDown);
                }
                else if (bytes[bytes.Length - 1 - i] == 2)
                {
                    createTriangle(pS, i, width, Triangles.RightLeftDown);
                }
                else if (bytes[bytes.Length - 1 - i] == 3)
                {
                    createTriangle(pS, i, width, Triangles.RightLeftUp);
                }
                else if (bytes[bytes.Length - 1 - i] == 4)
                {
                    createTriangle(pS, i, width, Triangles.LeftRightUp);
                }
            rBodies = new RecBody(path, pS);
        }
Пример #13
0
        public override void Initialize()
        {
            PhysicsSimulator = new PhysicsSimulator(new Vector2(0, 100));
            PhysicsSimulatorView = new PhysicsSimulatorView(PhysicsSimulator);

            base.Initialize();
        }
Пример #14
0
 public Game(PhysicsSimulator simulator)
 {
     this.player = new Player(simulator);
     this.computer = new Player(simulator);
     this.simulator = simulator;
     this.rounds = new List<Round>();
 }
Пример #15
0
        public void Load(PhysicsSimulator physicsSimulator, GraphicsDevice device)
        {
            Random rand = new Random();

            physicsSimulator.Add(_topBody);
            physicsSimulator.Add(_rightLegBody);
            physicsSimulator.Add(_leftLegBody);
            physicsSimulator.Add(_topGeom);
            physicsSimulator.Add(_rightLegGeom);
            physicsSimulator.Add(_leftLegGeom);

            _leftWeldJoint = new WeldJoint(_leftLegBody, _topBody, _leftLegBody.Position - new Vector2(-5, _height / 2));
            _leftWeldJoint.Breakpoint = (float)rand.NextDouble() * 3f + 1f;
            _leftWeldJoint.Broke += _leftWeldJoint_Broke;
            physicsSimulator.Add(_leftWeldJoint);

            _rightWeldJoint = new WeldJoint(_rightLegBody, _topBody, _rightLegBody.Position - new Vector2(5, _height / 2));
            _rightWeldJoint.Breakpoint = (float)rand.NextDouble() * 3f + 1f;
            _rightWeldJoint.Broke += _rightWeldJoint_Broke;
            physicsSimulator.Add(_rightWeldJoint);

            _topBrush = new PolygonBrush(_topGeom.LocalVertices, Color.BurlyWood, Color.Black, 1.0f, 0.5f);
            _leftBrush = new PolygonBrush(_leftLegGeom.LocalVertices, Color.BurlyWood, Color.Black, 1.0f, 0.5f);
            _rightBrush = new PolygonBrush(_rightLegGeom.LocalVertices, Color.BurlyWood, Color.Black, 1.0f, 0.5f);

            _topBrush.Load(device);
            _leftBrush.Load(device);
            _rightBrush.Load(device);
        }
Пример #16
0
        public void Load(GraphicsDevice graphicsDevice, PhysicsSimulator physicsSimulator)
        {
            _circleBrush = new CircleBrush(_radius, _color, _borderColor);
            _circleBrush.Load(graphicsDevice);

            _circleBody = new Body[_count];
            _circleGeom = new Geom[_count];

            _circleBody[0] = BodyFactory.Instance.CreateCircleBody(physicsSimulator, _radius, .5f);
            _circleBody[0].Position = _startPosition;
            for (int i = 1; i < _count; i++)
            {
                _circleBody[i] = BodyFactory.Instance.CreateBody(physicsSimulator, _circleBody[0]);
                _circleBody[i].Position = Vector2.Lerp(_startPosition, _endPosition, i/(float) (_count - 1));
            }

            _circleGeom[0] = GeomFactory.Instance.CreateCircleGeom(physicsSimulator, _circleBody[0], _radius, 10);
            _circleGeom[0].RestitutionCoefficient = .7f;
            _circleGeom[0].FrictionCoefficient = .2f;
            _circleGeom[0].CollisionCategories = CollisionCategories;
            _circleGeom[0].CollidesWith = CollidesWith;
            for (int j = 1; j < _count; j++)
            {
                _circleGeom[j] = GeomFactory.Instance.CreateGeom(physicsSimulator, _circleBody[j], _circleGeom[0]);
            }
        }
Пример #17
0
        private void LoadBorderGeom(PhysicsSimulator physicsSimulator)
        {
            _borderGeom = new Geom[4];
            //left border
            Vector2 geometryOffset = new Vector2(-(_width * .5f - _borderWidth * .5f), 0);
            _borderGeom[0] = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, _borderBody, _borderWidth,
                                                                      _height,
                                                                      geometryOffset, 0);
            _borderGeom[0].RestitutionCoefficient = .2f;
            _borderGeom[0].FrictionCoefficient = .5f;
            _borderGeom[0].CollisionGroup = 100;

            //right border (clone left border since geometry is same size)
            geometryOffset = new Vector2(_width * .5f - _borderWidth * .5f, 0);
            _borderGeom[1] = GeomFactory.Instance.CreateGeom(physicsSimulator, _borderBody, _borderGeom[0],
                                                             geometryOffset,
                                                             0);

            //top border
            geometryOffset = new Vector2(0, -(_height * .5f - _borderWidth * .5f));
            _borderGeom[2] = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, _borderBody, _width,
                                                                      _borderWidth,
                                                                      geometryOffset, 0);
            _borderGeom[2].RestitutionCoefficient = .2f;
            _borderGeom[2].FrictionCoefficient = .2f;
            _borderGeom[2].CollisionGroup = 100;

            //bottom border (clone top border since geometry is same size)
            geometryOffset = new Vector2(0, _height * .5f - _borderWidth * .5f);
            _borderGeom[3] = GeomFactory.Instance.CreateGeom(physicsSimulator, _borderBody, _borderGeom[2],
                                                             geometryOffset,
                                                             0);
        }
Пример #18
0
 public void Update(PhysicsSimulator pS, KeyboardState kbState, Vector2 pos, MouseState mouseStateCurrent, MouseState mouseStatePrevious)
 {
     if (!sPlaced)
     {
         startV = pos;
         if (mouseStatePrevious.LeftButton == ButtonState.Released & mouseStateCurrent.LeftButton == ButtonState.Pressed)
             sPlaced = true;
     }
     else if (!ePlaced)
     {
         endV = pos;
         if (mouseStatePrevious.LeftButton == ButtonState.Released & mouseStateCurrent.LeftButton == ButtonState.Pressed)
             ePlaced = true;
     }
     else
     {
         if (kbState.IsKeyDown(Keys.Add))
         {
             bodies += 1;
         }
         if (kbState.IsKeyDown(Keys.Subtract))
         {
             bodies -= 1;
         }
         if (kbState.IsKeyDown(Keys.Enter))
             Finish(pS);
     }
 }
Пример #19
0
        public void Load(Demo demo, PhysicsSimulator physicsSimulator)
        {
            agentBody = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, 80, 80, 5);
            agentBody.Position = _position;
            demo.AddAgentToCanvas(agentBody);
            agentGeom = new Geom[7];
            agentGeom[0] = GeomFactory.Instance.CreateCircleGeom(physicsSimulator, agentBody, 16, 10,
                                                                 new Vector2(-40, -40), 0);
            agentGeom[0].RestitutionCoefficient = .4f;
            agentGeom[0].FrictionCoefficient = .2f;
            agentGeom[0].CollisionGroup = 1;
            agentGeom[0].CollisionCategories = collisionCategory;
            agentGeom[0].CollidesWith = collidesWith;
            agentGeom[1] = GeomFactory.Instance.CreateGeom(physicsSimulator, agentBody, agentGeom[0],
                                                           new Vector2(-40, 40), 0);
            agentGeom[2] = GeomFactory.Instance.CreateGeom(physicsSimulator, agentBody, agentGeom[0],
                                                           new Vector2(40, -40), 0);
            agentGeom[3] = GeomFactory.Instance.CreateGeom(physicsSimulator, agentBody, agentGeom[0],
                                                           new Vector2(40, 40), 0);
            agentGeom[4] = GeomFactory.Instance.CreateGeom(physicsSimulator, agentBody, agentGeom[0],
                                                           new Vector2(0, 0),
                                                           0);

            agentGeom[5] = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, agentBody, 16, 120, Vector2.Zero,
                                                                    MathHelper.PiOver4);
            agentGeom[5].CollisionGroup = 1;
            agentGeom[5].CollisionCategories = collisionCategory;
            agentGeom[5].CollidesWith = collidesWith;

            agentGeom[6] = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, agentBody, 16, 120, Vector2.Zero,
                                                                    -MathHelper.PiOver4);
            agentGeom[6].CollisionGroup = 1;
            agentGeom[6].CollisionCategories = collisionCategory;
            agentGeom[6].CollidesWith = collidesWith;
        }
Пример #20
0
 public Ceiling(PhysicsSimulator simulator)
     : base(simulator)
 {
     this.simulator = simulator;
     this.Size = new Vector2(Screen.Width - 20, 20);
     this.Initialize();
 }
Пример #21
0
 public AppFramework()
 {
     map = new Map();
     graphics = new GraphicsDeviceManager(this);
     Content.RootDirectory = "Content";
     PhysicsSimulator = new PhysicsSimulator(new Vector2(0, 0));
 }
Пример #22
0
        public void Initialize(PhysicsSimulator physicsSimulator)
        {
            //The wave controller controls how the waves move.. how big, how fast, etc..
            //The wave controller is represented as set of points equally
            //spaced horizontally along the width of the wave.
            WaveController = new WaveController();
            WaveController.Position = ConvertUnits.ToSimUnits(0, 300);
            WaveController.Width = ConvertUnits.ToSimUnits(700);
            WaveController.Height = ConvertUnits.ToSimUnits(200);
            WaveController.NodeCount = 20; //how many vertices make up the surface of the wave
            WaveController.DampingCoefficient = .95f; //determines how quickly the wave will disipate
            WaveController.Frequency = .16f; //determines how fast the wave algorithm runs (seconds)

            //The wave generator parameters simply move an end-point of the wave up and down.
            //Think of a string attached to a wall on one end and held by a person on the other.
            //If the person moves the string up and down to make "waves" then the arm is acting
            //similar to the wave generator. The WaveGeneratorStep property controls how fast the "arm"
            //moves.
            WaveController.WaveGeneratorMax = WaveGeneratorMax;
            WaveController.WaveGeneratorMin = WaveGeneratorMin;
            WaveController.WaveGeneratorStep = WaveGeneratorStep;

            WaveController.Initialize();

            //fluid drag controller controls how things move once IN the water.
            FluidDragController = new FluidDragController();
            FluidDragController.Initialize(WaveController, 5f, 4f, 2f, physicsSimulator.Gravity);
            //init with default values.
            physicsSimulator.Add(FluidDragController);
        }
Пример #23
0
 public PhysicsComponent(Game game, PhysicsSimulator physicsSimulator)
     : base(game)
 {
     physicsSimulatorView = new PhysicsSimulatorView(physicsSimulator);
     this.PhysicsSimulator = physicsSimulator;
     this.Debug = false;
     Game.Services.AddService(typeof(IPhysicsSimulatorService), this);
 }
Пример #24
0
        public void Build(string filename, PhysicsSimulator physicsSimulator, ContentManager content, Vector2 position)
        {
            startPosition = position;

            Build(filename, physicsSimulator, content);


        }
Пример #25
0
        public Form_user( PhysicsSimulator world, Vector2 position, User user)
        {
            this.world = world;
            this.position = position;
            this.user = user;

            InitializeComponent();
        }
Пример #26
0
        public Rectangle(PhysicsSimulator physicsSimulator)
        {
            InitializeComponent();

            this.physicsSimulator = physicsSimulator;

            ReBuildGeometry();
        }
Пример #27
0
 protected override void Initialize(PhysicsSimulator simulator)
 {
     this.enemyCount = 2;
     base.Initialize(simulator);
     this.Wind.RefreshRate = 2400;
     this.wind.MaxXScale = 200;
     this.wind.MaxYScale = 20;
 }
Пример #28
0
 protected GameScreen()
 {
     ScreenState = ScreenState.TransitionOn;
     TransitionPosition = 1;
     TransitionOffTime = TimeSpan.Zero;
     TransitionOnTime = TimeSpan.Zero;
     PhysicsSimulator = new PhysicsSimulator(new Vector2(0, 0));
     PhysicsSimulatorView = new PhysicsSimulatorView(PhysicsSimulator);
 }
Пример #29
0
 public void Update(PhysicsSimulator pS, KeyboardState kbState, Vector2 pos, MouseState mouseStateCurrent, MouseState mouseStatePrevious)
 {
     if (!rec.placing)
         placing = Place(pS, mouseStateCurrent, mouseStatePrevious, pos);
     if (rec.placing)
         rec.Update(kbState, pos, mouseStateCurrent, mouseStatePrevious);
     if (mouseStateCurrent.LeftButton == ButtonState.Pressed & mouseStatePrevious.LeftButton == ButtonState.Released & rec.placing)
         rec.placing = false;
 }
Пример #30
0
        public override void Initialize()
        {
            PhysicsSimulator = new PhysicsSimulator(new Vector2(0, 0));
            PhysicsSimulator.MaxContactsToDetect = 2;
            //for stacked objects, simultaneous collision are the bottlenecks so limit them to 2 per geometric pair.
            PhysicsSimulatorView = new PhysicsSimulatorView(PhysicsSimulator);

            base.Initialize();
        }