本文整理汇总了C#中GameTime.Start方法的典型用法代码示例。如果您正苦于以下问题:C# GameTime.Start方法的具体用法?C# GameTime.Start怎么用?C# GameTime.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameTime
的用法示例。
在下文中一共展示了GameTime.Start方法的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"));
}
}