当前位置: 首页>>代码示例>>C#>>正文


C# GameTime.Update方法代码示例

本文整理汇总了C#中GameTime.Update方法的典型用法代码示例。如果您正苦于以下问题:C# GameTime.Update方法的具体用法?C# GameTime.Update怎么用?C# GameTime.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GameTime的用法示例。


在下文中一共展示了GameTime.Update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            // init screen related constants
            Constants.windowSizeY = (int)VideoMode.DesktopMode.Height;
            Constants.windowSizeX = Constants.windowSizeY * 4 / 3;
            Constants.windowScaleFactor = Constants.windowSizeY / 600f;
            Constants.screenRatio = (float)Constants.windowSizeY / Constants.windowSizeX;
            Constants.worldToScreenRatio = Constants.windowSizeX / Constants.worldSizeX;
            Constants.worldSizeY = Constants.worldSizeX * Constants.screenRatio;

            // initialize window and view
            win = new RenderWindow(new VideoMode((uint)Constants.windowSizeX, (uint)Constants.windowSizeY), "Shøøp");
            view = new View();
            resetView();
            gui = new GUI(win, view);

            // exit Program, when window is being closed
            //win.Closed += new EventHandler(closeWindow);
            win.Closed += (sender, e) => { (sender as Window).Close(); };

            // initialize GameState
            handleNewGameState();

            // initialize GameTime
            gameTime = new GameTime();
            float deltaTime = 0f;
            gameTime.Start();
            while (running && win.IsOpen())
            {
            //		gameTime.Update();

                GamePadInputManager.update();
                KeyboardInputManager.update();

                if (currentGameState == GameState.InGame) { inGameFrameCount++; }
                currentGameState = state.update(deltaTime * Constants.gameSpeedFactor);

                if (currentGameState != prevGameState)
                {
                    handleNewGameState();
                }

                // draw current frame
                win.Clear(new Color(100, 149, 237));    //cornflowerblue ftw!!! 1337
                state.draw(win, view);
                state.drawGUI(gui);

                win.SetView(view);
                win.Display();

                // check for window-events. e.g. window closed
                win.DispatchEvents();

                System.Threading.Thread.Sleep(5);
                // update GameTime
                gameTime.Update();
                deltaTime = (float)gameTime.EllapsedTime.TotalSeconds;
            //	int waitTime = (int)(16.667f - gameTime.EllapsedTime.TotalMilliseconds);
            //	if (waitTime > 0) System.Threading.Thread.Sleep(waitTime);
            //	win.SetTitle(waitTime.ToString());
            //	win.SetTitle((count/60f).ToString("0.0") + " | " + gameTime.TotalTime.TotalSeconds.ToString("0.0"));
            }
        }
开发者ID:Gnaarf,项目名称:UnicycleSheep,代码行数:63,代码来源:Program.cs


注:本文中的GameTime.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。