Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 30th, 2012  |  syntax: C#  |  size: 0.75 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public void Update()
  2.         {
  3.             _motion = Vector2.Zero;
  4.             if (InputHandler.KeyDown(Keys.Left))
  5.                 _motion.X = -1;
  6.             if (InputHandler.KeyDown(Keys.Right))
  7.                 _motion.X = 1;
  8.             if (InputHandler.KeyDown(Keys.Down))
  9.                 _motion.Y = 1;
  10.             if (InputHandler.KeyDown(Keys.Up))
  11.                 _motion.Y = -1;
  12.  
  13.             if (_motion != Vector2.Zero && _accel < 6)
  14.             {
  15.                 _accel += 0.5f;
  16.             }
  17.             else
  18.             {
  19.                 _accel = 0;
  20.             }
  21.  
  22.             _motion.X *= _playerSpeed + _accel;
  23.             _motion.Y *= _playerSpeed + _accel;
  24.             _position += _motion;
  25.             EnforceBounds();
  26.         }