Advertisement
Guest User

Untitled

a guest
May 2nd, 2013
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1. // Set Damping for realistic movement
  2. this.mf_Body.LinearDamping = 5f;
  3. // Set movement speed and max speed.
  4. this.mec_movementSpeed = FarseerConvertUnits.ToSimUnits(new Vector2(10, 10));
  5. this.mec_maxSpeed = FarseerConvertUnits.ToSimUnits(new Vector2(50, 50));
  6.  
  7. // Example movement code
  8. public void IncreaseSpeedX()
  9. {
  10.     this.mf_Body.ApplyLinearImpulse(new Vector2(this.mec_movementSpeed.X, 0));
  11.     this.mf_Body.LinearVelocity = new Vector2(Math.Min(this.mf_Body.LinearVelocity.X, this.mec_maxSpeed.X),                        
  12.                                               this.mf_Body.LinearVelocity.Y);
  13. }
  14.  
  15. public void IncreaseSpeedY()
  16. {
  17.     this.mf_Body.ApplyLinearImpulse(new Vector2(0, -this.mec_movementSpeed.Y));
  18.     this.mf_Body.LinearVelocity = new Vector2(this.mf_Body.LinearVelocity.X,
  19.                                               Math.Min(this.mf_Body.LinearVelocity.Y, this.mec_maxSpeed.Y));
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement