コード例 #1
0
ファイル: ShapeEditing.cs プロジェクト: prepare/box2c
        public override void  Keyboard(SFML.Window.KeyCode key)
        {
            switch (char.ToLower((char)key))
            {
            case 'c':
                if (m_fixture2 == null)
                {
                    CircleShape shape = new CircleShape();
                    shape.Radius   = 3.0f;
                    shape.Position = new Vec2(0.5f, -4.0f);
                    m_fixture2     = m_body.CreateFixture(shape, 10.0f);
                    m_body.IsAwake = true;
                }
                break;

            case 'd':
                if (m_fixture2 != null)
                {
                    m_body.DestroyFixture(m_fixture2.Value);
                    m_fixture2     = null;
                    m_body.IsAwake = true;
                }
                break;
            }
        }
コード例 #2
0
ファイル: RayCast.cs プロジェクト: prepare/box2c
        public override void Keyboard(SFML.Window.KeyCode key)
        {
            switch (char.ToLower((char)key))
            {
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
                Create((int)(key - '1'));
                break;

            case 'd':
                DestroyBody();
                break;

            case 'm':
                if (m_mode == Mode.e_closest)
                {
                    m_mode = Mode.e_any;
                }
                else if (m_mode == Mode.e_any)
                {
                    m_mode = Mode.e_multiple;
                }
                else if (m_mode == Mode.e_multiple)
                {
                    m_mode = Mode.e_closest;
                }
                break;
            }
        }
コード例 #3
0
        public override void  Keyboard(SFML.Window.KeyCode key)
        {
            switch (char.ToLower((char)key))
            {
            case 'b':
                for (int i = 0; i < 4; ++i)
                {
                    if (m_bodies[i] != null)
                    {
                        m_world.DestroyBody(m_bodies[i]);
                        m_bodies[i] = null;
                        break;
                    }
                }
                break;

            case 'j':
                for (int i = 0; i < 8; ++i)
                {
                    if (m_joints[i] != null)
                    {
                        m_world.DestroyJoint(m_joints[i]);
                        m_joints[i] = null;
                        break;
                    }
                }
                break;
            }
        }
コード例 #4
0
ファイル: PolyShapes.cs プロジェクト: prepare/box2c
        public override void Keyboard(SFML.Window.KeyCode key)
        {
            switch ((char.ToLower((char)key)))
            {
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
                Create((int)(key - '1'));
                break;

            case 'a':
                for (int i = 0; i < k_maxBodies; i += 2)
                {
                    if (m_bodies[i] != null)
                    {
                        bool active = m_bodies[i].IsActive;
                        m_bodies[i].IsActive = !active;
                    }
                }
                break;

            case 'd':
                DestroyBody();
                break;
            }
        }
コード例 #5
0
        public override void  Keyboard(SFML.Window.KeyCode key)
        {
            switch (char.ToLower((char)key))
            {
            case 'w':
            {
                Vec2 f = m_body.GetWorldVector(new Vec2(0.0f, -200.0f));
                Vec2 p = m_body.WorldCenter;
                m_body.ApplyForce(f, p);
            }
            break;

            case 'a':
            {
                m_body.ApplyTorque(50.0f);
            }
            break;

            case 'd':
            {
                m_body.ApplyTorque(-50.0f);
            }
            break;
            }
        }
コード例 #6
0
ファイル: Confined.cs プロジェクト: prepare/box2c
 public override void Keyboard(SFML.Window.KeyCode key)
 {
     switch (char.ToLower((char)key))
     {
     case 'c':
         CreateCircle();
         break;
     }
 }
コード例 #7
0
ファイル: Cloth.cs プロジェクト: prepare/box2c
 public override void Keyboard(SFML.Window.KeyCode key)
 {
     switch (char.ToLower((char)key))
     {
     case 'w':
         _wind = !_wind;
         break;
     }
 }
コード例 #8
0
ファイル: Pyramid.cs プロジェクト: prepare/box2c
 public override void Keyboard(SFML.Window.KeyCode key)
 {
     switch (char.ToLower((char)key))
     {
     case 'e':
         PhysExplosion(cursorPos, 6, 12);
         break;
     }
     base.Keyboard(key);
 }
コード例 #9
0
        /// <summary>
        /// Gets the corresponding numeric value for function <see cref="Keys"/>, or null if the
        /// key is not a numeric key. That is, the keyboard key for F1 will return 1, while "A" will return null.
        /// </summary>
        /// <param name="key">The key to get the corresponding numeric value for.</param>
        /// <returns>The numeric value for the <paramref name="key"/>, or null if not a numeric key.</returns>
        public static int?GetFunctionKeyAsValue(this Keys key)
        {
            switch (key)
            {
            case Keys.F1:
                return(1);

            case Keys.F2:
                return(2);

            case Keys.F3:
                return(3);

            case Keys.F4:
                return(4);

            case Keys.F5:
                return(5);

            case Keys.F6:
                return(6);

            case Keys.F7:
                return(7);

            case Keys.F8:
                return(8);

            case Keys.F9:
                return(9);

            case Keys.F10:
                return(10);

            case Keys.F11:
                return(11);

            case Keys.F12:
                return(12);

            case Keys.F13:
                return(13);

            case Keys.F14:
                return(14);

            case Keys.F15:
                return(15);

            default:
                return(null);
            }
        }
コード例 #10
0
ファイル: Revolute.cs プロジェクト: prepare/box2c
        public override void  Keyboard(SFML.Window.KeyCode key)
        {
            switch (char.ToLower((char)key))
            {
            case 'l':
                m_joint.IsLimitEnabled = !m_joint.IsLimitEnabled;
                break;

            case 's':
                m_joint.IsMotorEnabled = !m_joint.IsMotorEnabled;
                break;
            }
        }
コード例 #11
0
ファイル: SliderCrank.cs プロジェクト: prepare/box2c
        public override void  Keyboard(SFML.Window.KeyCode key)
        {
            switch (char.ToLower((char)key))
            {
            case 'f':
                m_joint2.IsMotorEnabled = !m_joint2.IsMotorEnabled;
                m_joint2.BodyB.IsAwake  = true;
                break;

            case 'm':
                m_joint1.IsMotorEnabled = !m_joint1.IsMotorEnabled;
                m_joint1.BodyB.IsAwake  = true;
                break;
            }
        }
コード例 #12
0
        /// <summary>
        /// Gets the corresponding numeric value for numeric <see cref="Keys"/>, or null if the
        /// key is not a numeric key. That is, the keyboard key for the number 1 or numpad key 1 will return
        /// 1, while "A" will return null.
        /// </summary>
        /// <param name="key">The key to get the corresponding numeric value for.</param>
        /// <returns>The numeric value for the <paramref name="key"/>, or null if not a numeric key.</returns>
        public static int?GetNumericKeyAsValue(this Keys key)
        {
            switch (key)
            {
            case Keys.Num0:
            case Keys.Numpad0:
                return(0);

            case Keys.Num1:
            case Keys.Numpad1:
                return(1);

            case Keys.Num2:
            case Keys.Numpad2:
                return(2);

            case Keys.Num3:
            case Keys.Numpad3:
                return(3);

            case Keys.Num4:
            case Keys.Numpad4:
                return(4);

            case Keys.Num5:
            case Keys.Numpad5:
                return(5);

            case Keys.Num6:
            case Keys.Numpad6:
                return(6);

            case Keys.Num7:
            case Keys.Numpad7:
                return(7);

            case Keys.Num8:
            case Keys.Numpad8:
                return(8);

            case Keys.Num9:
            case Keys.Numpad9:
                return(9);

            default:
                return(null);
            }
        }
コード例 #13
0
        public override void Keyboard(SFML.Window.KeyCode key)
        {
            switch (char.ToLower((char)key))
            {
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
                Create((int)(key - '1'));
                break;

            case 'd':
                DestroyBody();
                break;
            }
        }
コード例 #14
0
ファイル: TheoJansen.cs プロジェクト: prepare/box2c
        public override void  Keyboard(SFML.Window.KeyCode key)
        {
            switch (char.ToLower((char)key))
            {
            case 'a':
                m_motorJoint.MotorSpeed = -m_motorSpeed;
                break;

            case 's':
                m_motorJoint.MotorSpeed = 0.0f;
                break;

            case 'd':
                m_motorJoint.MotorSpeed = m_motorSpeed;
                break;

            case 'm':
                m_motorJoint.IsMotorEnabled = !m_motorJoint.IsMotorEnabled;
                break;
            }
        }
コード例 #15
0
        public override void Keyboard(SFML.Window.KeyCode key)
        {
            switch (char.ToLower((char)key))
            {
            case 'd':
                wheelL.IsMotorEnabled = wheelR.IsMotorEnabled = true;
                wheelL.MaxMotorTorque = wheelR.MaxMotorTorque = 2500;
                wheelL.MotorSpeed     = wheelR.MotorSpeed = 750;
                break;

            case 'a':
                wheelL.IsMotorEnabled = wheelR.IsMotorEnabled = true;
                wheelL.MaxMotorTorque = wheelR.MaxMotorTorque = 2500;
                wheelL.MotorSpeed     = wheelR.MotorSpeed = -750;
                break;

            case 's':
                wheelL.IsMotorEnabled = wheelR.IsMotorEnabled = false;
                break;
            }
        }
コード例 #16
0
ファイル: Car.cs プロジェクト: prepare/box2c
        public override void Keyboard(SFML.Window.KeyCode key)
        {
            switch (char.ToLower((char)key))
            {
            case 'a':
                m_leftJoint.MaxMotorTorque = 800.0f;
                m_leftJoint.MotorSpeed     = 36.0f;
                break;

            case 's':
                m_leftJoint.MaxMotorTorque = 100.0f;
                m_leftJoint.MotorSpeed     = 0.0f;
                break;

            case 'd':
                m_leftJoint.MaxMotorTorque = 1200.0f;
                m_leftJoint.MotorSpeed     = -36.0f;
                break;

            case 'w':
                m_vehicle.ApplyLinearImpulse(new Vec2(0.0f, 455.0f), m_vehicle.WorldCenter);
                m_vehicle.ApplyAngularImpulse(66);
                break;

            case 't':
                _points.Add(Program.MainForm.ConvertScreenToWorld(Main.GLWindow.Input.GetMouseX(), Main.GLWindow.Input.GetMouseY()));
                break;

            case 'y':
            {
                var chain = new EdgeChain(_points.ToArray());
                chain.GenerateBodies(m_world, new Vec2(0, 0), new FixtureDef(null, 0, 0, 0.65f));
                _points.Clear();
            }
            break;
            }
        }
コード例 #17
0
ファイル: BodyTypes.cs プロジェクト: prepare/box2c
        public override void  Keyboard(SFML.Window.KeyCode key)
        {
            switch (char.ToLower((char)key))
            {
            case 'd':
                m_platform.BodyType = BodyType.Dynamic;
                break;

            case 's':
                m_platform.BodyType = BodyType.Static;
                break;

            case 'k':
                m_platform.BodyType        = BodyType.Kinematic;
                m_platform.LinearVelocity  = new Vec2(-m_speed, 0.0f);
                m_platform.AngularVelocity = 0.0f;
                break;

            case 'n':
                m_payload.BodyType = (m_payload.BodyType == BodyType.Dynamic) ? BodyType.Static : BodyType.Dynamic;
                m_platform.IsAwake = true;
                break;
            }
        }
コード例 #18
0
 public virtual void Keyboard(SFML.Window.KeyCode key)
 {
 }