HoneycombRush.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // HoneycombRush.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 HoneycombRush.GameDebugTools;
  13. using Microsoft.Xna.Framework.GamerServices;
  14. #endregion
  15. namespace HoneycombRush
  16. {
  17. /// <summary>
  18. /// This is the main type for your game
  19. /// </summary>
  20. public class HoneycombRush : Game
  21. {
  22. #region Fields
  23. GraphicsDeviceManager graphics;
  24. ScreenManager screenManager;
  25. public static string GameName = "Honeycomb Rush";
  26. DebugSystem debugSystem;
  27. #endregion
  28. #region Initialization
  29. public HoneycombRush()
  30. {
  31. // Initialize sound system
  32. AudioManager.Initialize(this);
  33. graphics = new GraphicsDeviceManager(this);
  34. Content.RootDirectory = "Content";
  35. #if WINDOWS_PHONE
  36. // Frame rate is 30 fps by default for Windows Phone.
  37. TargetElapsedTime = TimeSpan.FromTicks(333333);
  38. graphics.IsFullScreen = true;
  39. screenManager = new ScreenManager(this, Vector2.One);
  40. #elif WINDOWS || MONOMAC || LINUX
  41. graphics.PreferredBackBufferHeight = 480;
  42. graphics.PreferredBackBufferWidth = 800;
  43. // Make the game windowed
  44. graphics.IsFullScreen = false;
  45. IsMouseVisible = true;
  46. Components.Add(new GamerServicesComponent(this));
  47. Vector2 scaleVector = new Vector2(graphics.PreferredBackBufferWidth / 1280f,
  48. graphics.PreferredBackBufferHeight / 720f);
  49. UIConstants.SetScale(scaleVector);
  50. // Create a new instance of the Screen Manager. Have all drawing scaled from 720p to the PC's resolution
  51. screenManager = new ScreenManager(this, scaleVector);
  52. #endif
  53. screenManager.AddScreen(new BackgroundScreen("titleScreen"), null);
  54. screenManager.AddScreen(new MainMenuScreen(), PlayerIndex.One);
  55. Components.Add(screenManager);
  56. }
  57. protected override void Initialize()
  58. {
  59. // Initialize the debug system with the game and the name of the font
  60. // we want to use for the debugging
  61. debugSystem = DebugSystem.Initialize(this, @"Fonts\GameScreenFont16px");
  62. base.Initialize();
  63. }
  64. #endregion
  65. #region Update and Draw
  66. protected override void Update(GameTime gameTime)
  67. {
  68. // Tell the TimeRuler that we're starting a new frame. you always want
  69. // to call this at the start of Update
  70. debugSystem.TimeRuler.StartFrame();
  71. // Start measuring time for "Update".
  72. debugSystem.TimeRuler.BeginMark("Update", Color.Blue);
  73. base.Update(gameTime);
  74. // Stop measuring time for "Update".
  75. debugSystem.TimeRuler.EndMark("Update");
  76. }
  77. protected override void Draw(GameTime gameTime)
  78. {
  79. // Start measuring time for "Draw".
  80. debugSystem.TimeRuler.BeginMark("Draw", Color.Yellow);
  81. base.Draw(gameTime);
  82. // Stop measuring time for "Draw".
  83. debugSystem.TimeRuler.EndMark("Draw");
  84. }
  85. #endregion
  86. }
  87. }