亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? gamemain.cs

?? 說明如何使用托管 Direct3D Mobile 創建一個簡單的二維游戲。
?? CS
?? 第 1 頁 / 共 2 頁
字號:
//---------------------------------------------------------------------
//  This file is part of the Microsoft .NET Framework SDK Code Samples.
// 
//  Copyright (C) Microsoft Corporation.  All rights reserved.
// 
//This source code is intended only as a supplement to Microsoft
//Development Tools and/or on-line documentation.  See these other
//materials for detailed information regarding Microsoft code samples.
// 
//THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
//KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//PARTICULAR PURPOSE.
//---------------------------------------------------------------------

using System;
using System.Data;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using System.Diagnostics;
using System.Drawing;
using System.Threading;
using System.Globalization;
using GraphicsLibrary;
using InputLibrary;
using Timer;

namespace GameApp
{
    /// <summary>
    /// Encapsulates loading and runnig of the game.  This class contains the
    /// game loop and initialization and is the top-level entry point to the
    /// game.
    /// </summary>
    public class GameMain : IDisposable
    {
        /// <summary>
        /// Minimum seconds that one frame can take i.e., the fastest
        /// framerate.
        /// </summary>
        private const float MinSecondsPerFrame = 1.0F / 50.0F;

        /// <summary>
        /// Maximum seconds that one frame can take i.e., the slowest
        /// framerate.
        /// </summary>
        private const float MaxSecondsPerFrame = 1.0F / 10.0F;

        /// <summary>
        /// The initial estimate of the framerate. This value will only be
        /// used until enough frames have been rendered that we can make
        /// reasonable estimates of the true framerate.
        /// </summary>
        private const float InitialSecondsPerFrame = 1.0F / 25.0F;

        /// <summary>
        /// Total length of time to count down after loading level,
        /// before level is playable.
        /// </summary>
        private const float TotalCountDownTime = 3.5F;

        /// <summary>
        /// Minimum length of time to display the splash screen.
        /// </summary>
        private const float TotalSplashTime = 2.0F;

        /// <summary>
        /// Current frame time in seconds.  This is provided as a static
        /// method accessible throughout the game because the rate can be
        /// variable.
        /// </summary>
        public static float SecondsPerFrame
        { get { return currentSecondsPerFrame; } }

        /// <summary>
        /// Current frame time in seconds.
        /// </summary>
        private static float currentSecondsPerFrame =
            InitialSecondsPerFrame;

        /// <summary>
        /// Specifies if the game is done.  When done, the game exits.
        /// </summary>
        private bool done = false;

        /// <summary>
        /// Graphics instance used by the game.
        /// </summary>
        private IGraphics graphics = null;

        /// <summary>
        /// Input instance used by the game.
        /// </summary>
        private Input gi = null;

        /// <summary>
        /// Stopwatch used by the game for timing the frames.
        /// </summary>
        private Timer.Stopwatch sw = null;

        /// <summary>
        /// Level that is currently loaded in the game.
        /// </summary>
        private Level level = null;

        /// <summary>
        /// User interface that is currently loaded in the game.
        /// </summary>
        private UserInterface ui = null;

        /// <summary>
        /// Intro data displayed before the current level.  This is only valid
        /// once loaded and until the level starts.
        /// </summary>
        private Intro intro = null;

        /// <summary>
        /// Defines the current update method.  This is determined by which
        /// state the game is in.
        /// </summary>
        private UpdateDelegate update = null;
        private delegate void UpdateDelegate();

        /// <summary>
        /// This enum is set by update delegates when the game needs to switch
        /// to a different update mode.  This is not done from within the
        /// update methods because problems can occur when delegate is
        /// modified from within a call to that delegate.
        /// </summary>
        private enum ModeSwitch
        {
            UpdateCountdown,
            UpdateLevel,
            UpdateIntro,
            None
        }
        private ModeSwitch mode = ModeSwitch.None;

        /// <summary>
        /// Splash screen image.  This is only valid while the splash
        /// screen is displayed at the start of the game.
        /// </summary>
        private IBitmap splash = null;

        /// <summary>
        /// Shared instance of the game's random number generator.
        /// </summary>
        private static Random rnd = null;

        /// <summary>
        /// Number of frames since the last auto-update check.
        /// </summary>
        public static Int64 CurrentFrame { get { return numFrames; } }
        private static Int64 numFrames = 0;

        /// <summary>
        /// The number of seconds which have passed for 'numFrames' 
        /// number of frames to have been rendered
        /// </summary>
        private float secondsElapsedForCurrentFrames;

        /// <summary>
        /// Specifies if the intro has finished loading.
        /// </summary>
        private bool introLoaded = false;

        /// <summary>
        /// Specifies if the level has finished loading.
        /// </summary>
        private bool levelLoaded = false;

        /// <summary>
        /// Total time left to countdown before starting the game.
        /// </summary>
        private float countDown = TotalCountDownTime;

        /// <summary>
        /// Rectangle cached for drawing routines to reduce memory
        /// allocations.
        /// </summary>
        Rectangle src = new Rectangle();

        /// <summary>
        /// Specifies if the countdown to start the level should begin.
        /// </summary>
        private bool startCountDown = false;

        /// <summary>
        /// Initializes the game libraries.
        /// </summary>
        /// <param name="owner">Control (Form) that owns the game</param>
        public GameMain(Control owner)
        {
            // Create a Graphics instance
#if USE_GDI
            graphics = new GdiGraphics(owner);
#else
            graphics = new DirectXGraphics(owner);
#endif
            Debug.Assert(graphics != null,
                "GameMain.GameMain: Failed to initialize Graphics object");

            // Create a Input instance
            gi = new Input(owner);
            Debug.Assert(gi != null,
                "GameMain.GameMain: Failed to initialize Input object");

            // Register the hardware buttons
            gi.RegisterAllHardwareKeys();

            // Initialize the random number generator
            rnd = new Random();

            // Create a stopwatch instance for timing the frames
            sw = new Timer.Stopwatch();
            Debug.Assert(sw != null,
                "GameMain.Run: Failed to initialize StopWatch");

        }

        /// <summary>
        /// Get a random float from 0-1.
        /// </summary>
        /// <returns>Random float from 0-1</returns>
        public static float Random()
        {
            return (float)rnd.NextDouble();
        }

        /// <summary>
        /// Get a random number in the specified range.
        /// </summary>
        /// <param name="min">Minimum number to return</param>
        /// <param name="max">Maximum number to return</param>
        /// <returns>Random int in range</returns>
        public static int Random(int min, int max)
        {
            return rnd.Next(min, max);
        }

        /// <summary>
        /// Get the full path to the specified file by prepending it
        /// with the directory of the executable.
        /// </summary>
        /// <param name="fileName">Name of file</param>
        /// <returns>Full path of the file</returns>
        public static string GetFullPath(string fileName)
        {
            Debug.Assert(fileName != null && fileName.Length > 0,
                "GameMain.GetFullPath: Invalid string");

            Assembly asm = Assembly.GetExecutingAssembly();
            string str = asm.GetName().CodeBase;
            string fullName = Path.GetDirectoryName(str);

            // the full name can be a URI (eg file://...) but some of the
            // loader functions can't parse that type of path. Hence we get
            // a path that starts with a drive letter.
            Uri uri = new Uri(Path.Combine(fullName, fileName));
            return uri.LocalPath;
        }

        /// <summary>
        /// Reset the current level.
        /// </summary>
        private void Reset()
        {
            // Reset the game
            level.ResetAll();

            // Clear any latent key presses
            gi.ClearKeyPresses();

            // Do one update of the level so it can be drawn
            level.Update(gi);

            startCountDown = false;
            update = new UpdateDelegate(UpdateCountdown);
            countDown = TotalCountDownTime;
            numFrames = 0;
            secondsElapsedForCurrentFrames = 0;

        }

        /// <summary>
        /// Start the game.  This method loads the game resources and
        /// runs the main game loop.
        /// </summary>
        public void Run()
        {

            // Load and validate the splash screen
            splash = graphics.CreateBitmap(GetFullPath(@"Data\Splash\splash.bmp"), false);
            Debug.Assert(splash != null,
                "GameMain.Run: Failed to initialized splash screen");
            Debug.Assert(splash.Width <= graphics.ScreenWidth &&
                splash.Height <= graphics.ScreenHeight,
                "GameMain.Run: Splash screen has invalid dimensions");

            // Load the game ui now because it has font information that is
            // needed for drawing the 'Loading...' tag
            DataSet dsUI = new DataSet();
            
            Debug.Assert(dsUI != null,
                "GameMain.LoadLevel: Failed to initialize UI DataSet");

            dsUI.Locale = CultureInfo.InvariantCulture;

            // Load the ui xml file
            dsUI.ReadXml(GetFullPath(@"Data\UI\ui.xml"));

            // Load the resources specified in the xml file
            ui = new UserInterface(dsUI, graphics, level);
            Debug.Assert(ui != null,
                "GameMain.LoadLevel: Failed to initialize UI");
            
            // Set the current update method as the splash screen updater
            update = new UpdateDelegate(UpdateSplash);

            // Loop until the game is done
            while (!done)
            {
                // Switch the update delegate if a switch was requested.
                switch (mode)
                {
                    case ModeSwitch.UpdateLevel:
                        gi.ClearKeyPresses();
                        update = new UpdateDelegate(UpdateLevel);
                        numFrames = 0;
                        secondsElapsedForCurrentFrames = 0;
                        break;
                    case ModeSwitch.UpdateCountdown:
                        intro.Dispose();
                        intro = null;
                        level.Update(gi);
                        update = new UpdateDelegate(UpdateCountdown);
                        break;
                    case ModeSwitch.UpdateIntro:
                        LoadLevel();
                        update = new UpdateDelegate(UpdateIntro);
                        splash.Dispose();
                        splash = null;
                        break;
                }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
麻豆精品精品国产自在97香蕉| 中文字幕一区二区三区在线播放| 欧美精品一区二区三区蜜臀| 久久精品免费在线观看| 亚洲视频一二区| 亚洲444eee在线观看| 国产真实精品久久二三区| 99久久精品国产毛片| 欧美精品777| 久久精品人人做人人爽97| 一区二区三区四区在线免费观看| 日本va欧美va瓶| 成人在线视频首页| 欧美三级日韩三级| 国产欧美精品一区| 亚洲bt欧美bt精品| 国产99久久久国产精品免费看| 在线观看视频一区| 精品播放一区二区| 亚洲国产欧美在线人成| 国产一区二区三区av电影| 日本精品视频一区二区三区| 日韩欧美的一区| 1024亚洲合集| 韩国av一区二区三区| 欧美性色综合网| 久久精品人人做| 日韩精品电影在线| 成人免费毛片aaaaa**| 欧美绝品在线观看成人午夜影视| 国产欧美日韩中文久久| 狠狠色狠狠色综合| 欧美日精品一区视频| 日本一区二区三区国色天香| 热久久久久久久| 色婷婷综合久色| 精品国产凹凸成av人网站| 亚洲一区在线播放| 99久久精品免费看国产免费软件| 日韩一区二区三区视频| 一区二区三区不卡在线观看| 国产91高潮流白浆在线麻豆| 日韩免费一区二区三区在线播放| 亚洲自拍与偷拍| 不卡av电影在线播放| 久久蜜桃香蕉精品一区二区三区| 亚洲v中文字幕| 一本色道久久综合亚洲精品按摩| 国产日韩欧美电影| 理论电影国产精品| 91精品国产综合久久久久久久久久| 亚洲欧美日韩在线不卡| 丁香天五香天堂综合| 精品剧情在线观看| 日韩中文字幕麻豆| 欧美日韩中文字幕一区| 亚洲美女免费视频| www.激情成人| 中文字幕不卡一区| 福利电影一区二区三区| 久久伊人蜜桃av一区二区| 美女性感视频久久| 日韩欧美在线123| 图片区小说区国产精品视频| 欧美日韩一级片在线观看| 亚洲激情在线播放| 在线亚洲欧美专区二区| 亚洲精品大片www| 色一情一伦一子一伦一区| 亚洲手机成人高清视频| 99久久99久久精品国产片果冻| 国产精品伦理在线| av中文字幕一区| 成人免费小视频| 91丨九色丨尤物| 亚洲精品日韩专区silk| 在线观看精品一区| 亚洲综合在线电影| 欧美日韩免费在线视频| 香蕉成人伊视频在线观看| 欧美猛男超大videosgay| 五月天一区二区| 51精品国自产在线| 蜜臀精品一区二区三区在线观看 | 欧美性受xxxx| 午夜影院在线观看欧美| 欧美一区二视频| 久久成人久久鬼色| 久久久精品国产免大香伊| 国产精品123区| 亚洲欧洲日韩在线| 欧美无乱码久久久免费午夜一区| 亚洲成人动漫av| 日韩欧美国产午夜精品| 国产精品影视在线观看| 国产蜜臀97一区二区三区| 成人精品免费视频| 亚洲精品国产视频| 欧美二区三区的天堂| 毛片一区二区三区| 国产欧美精品区一区二区三区| 99精品欧美一区二区蜜桃免费| 亚洲人成影院在线观看| 欧美手机在线视频| 久久国产乱子精品免费女| 日本一区二区三区四区| 91片在线免费观看| 青青草原综合久久大伊人精品优势| 久久免费美女视频| 一本久久精品一区二区| 亚洲r级在线视频| 国产亚洲精品超碰| 在线视频你懂得一区| 久久精品国产色蜜蜜麻豆| 欧美国产成人精品| 欧美日韩免费一区二区三区视频 | 久久精品人人做人人爽人人| 99精品视频在线观看| 日韩av一区二区在线影视| 日本一区二区视频在线观看| 在线观看亚洲成人| 国产精品一区二区91| 亚洲另类色综合网站| 精品欧美乱码久久久久久1区2区| 成人av网站免费| 日韩国产成人精品| 亚洲国产经典视频| 欧美一区二区在线播放| 成人91在线观看| 毛片基地黄久久久久久天堂| 亚洲人成伊人成综合网小说| 日韩免费看的电影| 日本丰满少妇一区二区三区| 精品一区二区三区在线视频| 亚洲日本在线看| 亚洲欧美乱综合| 精品国产乱码久久久久久久久| 色综合久久久久综合| 久久99精品国产麻豆婷婷| 玉足女爽爽91| 欧美国产综合一区二区| 欧美一区二区在线视频| 91国产免费看| 国产不卡视频一区二区三区| 秋霞av亚洲一区二区三| 艳妇臀荡乳欲伦亚洲一区| 日本一区二区电影| 欧美一区2区视频在线观看| 色综合天天做天天爱| 国产精品一区在线| 亚洲高清不卡在线| ●精品国产综合乱码久久久久| 久久亚洲私人国产精品va媚药| 欧美另类videos死尸| 99综合影院在线| 国产福利91精品| 久久99精品视频| 手机精品视频在线观看| 一个色在线综合| 国产精品电影院| 国产欧美日韩亚州综合| 日韩欧美电影在线| 91精品国产福利| 欧美视频精品在线观看| 91亚洲午夜精品久久久久久| 成人午夜视频在线观看| 国产mv日韩mv欧美| 国产精品一区二区三区乱码 | 精品盗摄一区二区三区| 欧美喷水一区二区| 欧美日韩在线三级| 91黄色免费网站| 一本大道久久a久久综合| 成人免费视频视频| 成a人片亚洲日本久久| 成人三级在线视频| 成人亚洲精品久久久久软件| 国产91精品免费| 成人永久aaa| 成人精品高清在线| 97se狠狠狠综合亚洲狠狠| aaa国产一区| 一本到不卡精品视频在线观看| 99re热视频精品| av在线播放不卡| 成人美女在线视频| 国产激情一区二区三区| 国产v综合v亚洲欧| 国产suv一区二区三区88区| 午夜精彩视频在线观看不卡| 偷拍日韩校园综合在线| 亚洲一二三四在线观看| 一区二区三区欧美亚洲| 一区二区三区国产精华| 亚洲人成在线播放网站岛国| 亚洲天堂精品在线观看| 一区二区三区在线视频观看| 亚洲欧美视频一区| 亚洲精品中文在线影院| 亚洲午夜国产一区99re久久|