TitleScreen.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // TitleScreen.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.Graphics;
  12. using Microsoft.Xna.Framework;
  13. #endregion
  14. namespace Marblets
  15. {
  16. /// <summary>
  17. /// Title screen is the initial screen for Marblets. Allows you to select 2d or 3d
  18. /// and displays the high scores
  19. /// </summary>
  20. public class TitleScreen : Screen
  21. {
  22. /// <summary>
  23. /// Initializes a new instance of the <see cref="TitleScreen"/> class.
  24. /// </summary>
  25. /// <param name="game">The game object to use</param>
  26. /// <param name="backgroundImage">The background image to use when this is
  27. /// visible</param>
  28. /// <param name="backgroundMusic">The background music to play when this is
  29. /// visible</param>
  30. public TitleScreen(Game game, string backgroundImage,
  31. SoundEntry backgroundMusic)
  32. : base(game, backgroundImage, backgroundMusic)
  33. {
  34. }
  35. /// <summary>
  36. /// Checks for game start button presses
  37. /// </summary>
  38. ///
  39. public override void Update(GameTime gameTime)
  40. {
  41. base.Update(gameTime);
  42. GameState returnValue = GameState.None;
  43. //Transition to next state if those properties are set
  44. if(InputHelper.GamePads[PlayerIndex.One].APressed || Clicked)
  45. {
  46. Sound.Play(SoundEntry.Menu2DStart);
  47. returnValue = GameState.Play2D;
  48. }
  49. MarbletsGame.NextGameState = returnValue;
  50. }
  51. /// <summary>
  52. /// Draws the high scores
  53. /// </summary>
  54. ///
  55. public override void Draw(GameTime gameTime)
  56. {
  57. base.Draw(gameTime);
  58. //If the guide is visible - then there are no high scores yet and the array
  59. //will be null
  60. if(MarbletsGame.HighScores != null)
  61. {
  62. SpriteBatch.Begin();
  63. //Draw the high scores
  64. for(int i = 0; i < 5; i++)
  65. {
  66. if(MarbletsGame.HighScores[i] != 0)
  67. {
  68. Font.Draw(SpriteBatch, FontStyle.Small, 135, 340 + i * 22,
  69. MarbletsGame.HighScores[i]);
  70. }
  71. }
  72. SpriteBatch.End();
  73. }
  74. }
  75. }
  76. }