Sun.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // Sun.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 Microsoft.Xna.Framework;
  12. using Microsoft.Xna.Framework.Graphics;
  13. using System.Diagnostics;
  14. #endregion
  15. namespace Spacewar
  16. {
  17. /// <summary>
  18. /// Represents the sun game object
  19. /// </summary>
  20. public class Sun : SceneItem
  21. {
  22. /// <summary>
  23. /// Creates a new sun object
  24. /// </summary>
  25. /// <param name="shape">Which shape to use to draw this</param>
  26. /// <param name="position">Where to draw it on the screen</param>
  27. public Sun(Game game, Shape shape, Vector3 position)
  28. : base(game, shape, position)
  29. {
  30. if ((shape == null) || (shape is EvolvedSun))
  31. {
  32. center = new Vector3(.5f, .5f, 0);
  33. rotation = Vector3.Zero;
  34. radius = 15f;
  35. }
  36. else
  37. {
  38. scale = new Vector3(8, 8, 8);
  39. radius = 11f;
  40. }
  41. }
  42. /// <summary>
  43. /// Update the sun - a simple slow rotation
  44. /// </summary>
  45. /// <param name="time">Current game time</param>
  46. /// <param name="elapsedTime">Elapsed time since last update</param>
  47. public override void Update(TimeSpan time, TimeSpan elapsedTime)
  48. {
  49. rotation.Z += (float)(elapsedTime.TotalSeconds / 10.0f);
  50. base.Update(time, elapsedTime);
  51. }
  52. }
  53. }