RetroSun.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // RetroSun.cs
  4. //
  5. // Microsoft XNA Community Game Platform
  6. // Copyright (C) Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #endregion
  9. #region Using Statements
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Text;
  13. using Microsoft.Xna.Framework;
  14. using Microsoft.Xna.Framework.Graphics;
  15. #endregion
  16. namespace Spacewar
  17. {
  18. /// <summary>
  19. /// The shape drawn for the sun in retro mode
  20. /// </summary>
  21. public class RetroSun : VectorShape
  22. {
  23. public RetroSun(Game game)
  24. : base(game)
  25. {
  26. }
  27. /// <summary>
  28. /// Loads up the data for a sun shape
  29. /// </summary>
  30. /// <param name="data"></param>
  31. protected override void FillBuffer(VertexPositionColor[] data)
  32. {
  33. float r2 = (float)Math.Sqrt(2);
  34. data[0] = new VertexPositionColor(new Vector3(0, 2, 0), Color.White);
  35. data[1] = new VertexPositionColor(new Vector3(0, -2, 0), Color.White);
  36. data[2] = new VertexPositionColor(new Vector3(2, 0, 0), Color.White);
  37. data[3] = new VertexPositionColor(new Vector3(-2, 0, 0), Color.White);
  38. data[4] = new VertexPositionColor(new Vector3(-r2, r2, 0f), Color.Gray);
  39. data[5] = new VertexPositionColor(new Vector3(r2, -r2, 0f), Color.Gray);
  40. data[6] = new VertexPositionColor(new Vector3(r2, r2, 0f), Color.Gray);
  41. data[7] = new VertexPositionColor(new Vector3(-r2, -r2, 0f), Color.Gray);
  42. }
  43. /// <summary>
  44. /// Sun consists of 4 lines
  45. /// </summary>
  46. protected override int NumberOfVectors
  47. {
  48. get
  49. {
  50. return 4;
  51. }
  52. }
  53. }
  54. }