コード例 #1
0
        /*-------------------------------------
         * PROTECTED METHODS
         *-----------------------------------*/

        protected override void UpdateControls(Entity entity,
                                               ControlsComponent controls,
                                               float dt)
        {
            var body       = entity.GetComponent <BodyComponent>();
            var paddleInfo = entity.GetComponent <PaddleInfoComponent>();

            if (controls.Controls.ContainsKey("Y"))
            {
                var acc    = paddleInfo.Speed * controls.Controls["Y"] * dt;
                var newVel = new Vector2(body.Velocity.X, body.Velocity.Y + acc);
                body.Velocity = newVel;
            }

            if (controls.Controls.ContainsKey("Tilt"))
            {
                var paddle = (PaddleEntity)entity;
                paddle.Tilt = controls.Controls["Tilt"] * paddleInfo.TiltAngle;
            }
        }
コード例 #2
0
 protected abstract void UpdateControls(Entity entity,
                                        ControlsComponent controls,
                                        float dt);