Ejemplo n.º 1
0
        public void Update(BaseKeys keys)
        {
            actualTorque = -20;

            if (keys.GoLeft())
            {
                steeringRotation += -0.1f;
            }
            else if (keys.GoRight())
            {
                steeringRotation += 0.1f;
            }
            else if (steeringRotation > 0)
            {
                steeringRotation += -0.1f;
            }
            else if (steeringRotation < 0)
            {
                steeringRotation += 0.1f;
            }

            //else if (steeringRotation < 0) steeringRotation += 0.2f;
            //else if (steeringRotation > 0) steeringRotation -= 0.2f;

            //steeringRotation += 1 / 100;

            steeringRotation = MathHelper.Clamp(steeringRotation * 0.97f, -maxSteeringRotation, maxSteeringRotation);

            if (keys.GoUp()) // push gas
            {
                // Acceleration = (wheel power - drag power - rolling resistance power)/(mass x speed)
                actualTorque = Torque;
            }

            if (keys.GoDown()) // push break
            {
                actualTorque = brakeTorque;
            }
        }
Ejemplo n.º 2
0
 public Car(BaseKeys directionKeys, Texture2D texture, Vector2 position, Rectangle?sourceRectangle, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth, float speed) : base(directionKeys, texture, position, sourceRectangle, color, rotation, origin, scale, effects, layerDepth, speed)
 {
     this.engine    = new Engine();
     mass           = 1200;
     Game1.Updated += this.update;
 }