RotatingPiece.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Microsoft.Xna.Framework;
  6. namespace Flood_Control
  7. {
  8. class RotatingPiece : GamePiece
  9. {
  10. public bool clockwise;
  11. public static float rotationRate = (MathHelper.PiOver2 / 10);
  12. private float rotationAmount = 0;
  13. public int rotationTicksRemaining = 10;
  14. public float RotationAmount
  15. {
  16. get
  17. {
  18. if (clockwise)
  19. return rotationAmount;
  20. else
  21. return (MathHelper.Pi * 2) - rotationAmount;
  22. }
  23. }
  24. public RotatingPiece(string pieceType, bool clockwise)
  25. : base(pieceType)
  26. {
  27. this.clockwise = clockwise;
  28. }
  29. public void UpdatePiece()
  30. {
  31. rotationAmount += rotationRate;
  32. rotationTicksRemaining = (int)MathHelper.Max(
  33. 0,
  34. rotationTicksRemaining - 1);
  35. }
  36. }
  37. }