BlackjackGame.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // PauseScreen.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.Linq;
  13. using System.Globalization;
  14. #if ANDROID
  15. using Android.App;
  16. #endif
  17. using Microsoft.Xna.Framework;
  18. using Microsoft.Xna.Framework.Audio;
  19. using Microsoft.Xna.Framework.Content;
  20. using Microsoft.Xna.Framework.GamerServices;
  21. using Microsoft.Xna.Framework.Graphics;
  22. using Microsoft.Xna.Framework.Input;
  23. using Microsoft.Xna.Framework.Media;
  24. using CardsFramework;
  25. using GameStateManagement;
  26. #endregion
  27. namespace Blackjack
  28. {
  29. /// <summary>
  30. /// This is the main game type.
  31. /// </summary>
  32. public class BlackjackGame : Microsoft.Xna.Framework.Game
  33. {
  34. GraphicsDeviceManager graphics;
  35. ScreenManager screenManager;
  36. public static float HeightScale = 1.0f;
  37. public static float WidthScale = 1.0f;
  38. /// <summary>
  39. /// Initializes a new instance of the game.
  40. /// </summary>
  41. public BlackjackGame ()
  42. {
  43. graphics = new GraphicsDeviceManager(this);
  44. Content.RootDirectory = "Content";
  45. screenManager = new ScreenManager(this);
  46. screenManager.AddScreen(new BackgroundScreen(), null);
  47. screenManager.AddScreen(new MainMenuScreen(), null);
  48. Components.Add(screenManager);
  49. #if WINDOWS || MACOS || LINUX
  50. IsMouseVisible = true;
  51. #elif WINDOWS_PHONE || IOS || ANDROID
  52. // Frame rate is 30 fps by default for Windows Phone.
  53. TargetElapsedTime = TimeSpan.FromTicks(333333);
  54. graphics.IsFullScreen = true;
  55. #else
  56. Components.Add(new GamerServicesComponent(this));
  57. #endif
  58. // Initialize sound system
  59. AudioManager.Initialize(this);
  60. }
  61. protected override void Initialize()
  62. {
  63. base.Initialize();
  64. #if XBOX
  65. graphics.PreferredBackBufferHeight = graphics.GraphicsDevice.DisplayMode.Height;
  66. graphics.PreferredBackBufferWidth = graphics.GraphicsDevice.DisplayMode.Width;
  67. #elif WINDOWS || MACOS || LINUX
  68. graphics.PreferredBackBufferHeight = 480;
  69. graphics.PreferredBackBufferWidth = 800;
  70. #endif
  71. graphics.ApplyChanges();
  72. Rectangle bounds = graphics.GraphicsDevice.Viewport.TitleSafeArea;
  73. HeightScale = bounds.Height / 480f;
  74. WidthScale = bounds.Width / 800f;
  75. }
  76. /// <summary>
  77. /// LoadContent will be called once per game and is the place to load
  78. /// all of your content.
  79. /// </summary>
  80. protected override void LoadContent()
  81. {
  82. AudioManager.LoadSounds();
  83. base.LoadContent();
  84. }
  85. }
  86. }