コード例 #1
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 public static void Main()
 {
     using (Pickture game = new Pickture())
     {
         game.Run();
     }
 }
コード例 #2
0
ファイル: Pickture.cs プロジェクト: nusisschad/XNAGameStudio
        /// <summary>
        /// Construct a new instance of Pickture. This method will enforce that it is
        /// only ever called once because the game class itself is a singleton.
        /// </summary>
        public Pickture()
        {
            // Enforce singleton
            if (instance != null)
            {
                throw new InvalidOperationException(
                          "Only one instance of Pickture may be created.");
            }
            instance = this;

            // Initalize graphics
            graphics = new GraphicsDeviceManager(this);
            graphics.MinimumVertexShaderProfile = ShaderProfile.VS_2_0;
            graphics.MinimumPixelShaderProfile  = ShaderProfile.PS_2_0;

#if XBOX360
            // On Xbox360, always use the user's preferred resolution and multisampling
            // The other approach is to always use the same resolution (typically
            // 1920x1080). The hardware will automatically down scale and letterbox as
            // needed. However, Pickture is already resolution independant for Windows
            graphics.PreferredBackBufferWidth  = Window.ClientBounds.Width;
            graphics.PreferredBackBufferHeight = Window.ClientBounds.Height;
            graphics.PreferMultiSampling       = true;
            graphics.PreparingDeviceSettings  +=
                new EventHandler <PreparingDeviceSettingsEventArgs>(
                    graphics_PreparingDeviceSettings);
#else
            // On Windows, just use a small and simple starting size, but allow
            // the user to resize the Window however they like
            graphics.PreferredBackBufferWidth  = 800;
            graphics.PreferredBackBufferHeight = 600;
            Window.AllowUserResizing           = true;
            graphics.IsFullScreen = false;
#endif


            // Initalzie content
            Content.RootDirectory = "Content";

            // Initalize screen management
            ScreenManager screenManager = new ScreenManager(this);
            Components.Add(screenManager);

            // Initalize picture database
            PictureDatabase.Initialize();

            // If enough pictures are available,
            if (PictureDatabase.Count >= 2)
            {
                // start up the game
                screenManager.AddScreen(new MainMenuScreen());
            }
            else
            {
                // Otherwise, show error and quit
                MessageBoxScreen messageBox = new MessageBoxScreen(
                    "Unable to find enough pictures to play.", false);
                messageBox.Accepted += new EventHandler <EventArgs>(messageBox_Accepted);
                screenManager.AddScreen(messageBox);
            }
        }