fork download
  1. KeyboardState keyboard = Keyboard.GetState();
  2.  
  3. if (keyboard.IsKeyDown(Keys.Left))
  4. direction -= 0.05;
  5.  
  6. if (keyboard.IsKeyDown(Keys.Right))
  7. direction += 0.05;
  8.  
  9. if (speed == 0)
  10. speed = 0.1;
  11.  
  12.  
  13.  
  14. Vector2 currentVector = new Vector2((float) (Math.Cos(motionDirection) * speed), (float) (Math.Sin(motionDirection) * speed));
  15. Vector2 keyVector = keyboard.IsKeyDown(Keys.Up) ? new Vector2((float) (Math.Cos(direction)*2), (float) (Math.Sin(direction)*2)) : Vector2.Zero;
  16. Vector2 newVector = Vector2.Add(currentVector, keyVector);
  17.  
  18.  
  19. if (Vector2.Distance(Vector2.Zero, newVector) != 0)
  20. {
  21. speed = (float)Math.Sqrt(Math.Pow(newVector.X, 2) + Math.Pow(newVector.Y, 2));
  22. motionDirection = (float)Math.Atan(newVector.Y / newVector.X);
  23. }
  24.  
  25. if (speed > 2)
  26. speed = 2;
  27.  
  28. position.X += newVector.X;
  29. position.Y += newVector.Y;
  30.  
  31.  
  32. polygon.setPosition(position);
  33. polygon.setRotation(direction);
  34.  
  35. Console.WriteLine("Motion direction: " + motionDirection);
  36. Console.WriteLine("Direction: " + direction);
  37. Console.WriteLine("Speed: " + speed);
  38. Console.WriteLine();
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(1,0): error CS1525: Unexpected symbol `KeyboardState'
prog.cs(14,25): error CS1530: Keyword `new' is not allowed on namespace elements
prog.cs(14,28): error CS1525: Unexpected symbol `Vector2'
prog.cs(15,51): error CS1530: Keyword `new' is not allowed on namespace elements
prog.cs(15,54): error CS1525: Unexpected symbol `Vector2'
Compilation failed: 5 error(s), 0 warnings
stdout
Standard output is empty