public static void Main(string[] args) { Initialize(); stopWatch.Start(); while (loop) { //Thread.Sleep(10); SystemEvents.CheckEvents(); Update(); Render(); #region "Calculation for frame rate" mFrame++; mT = stopWatch.ElapsedMilliseconds; if (mT - mT0 >= 1000) { float seconds = (mT - mT0) / 1000; mFps = mFrame / seconds; mT0 = mT; mFrame = 0; } #endregion } term(); }
public virtual void Run() { StartGame(); RenderGame(); long time = _stopwatch.ElapsedMilliseconds; for (;;) { SystemEvents.CheckEvents(); if (_updateRate == 0) { continue; } UpdateGame(); RenderGame(); if (_updateRate == 0 || _updateRate >= 60) { continue; } long period = 1000 / _updateRate; while (_stopwatch.ElapsedMilliseconds - time < period) { SystemEvents.CheckEvents(); } time += period; } }
public static void Run(string[] args) { stopwatch = Stopwatch.StartNew(); uint sprites_capacity = 500; uint draw_helpers_capacity = 400; GraphicsContext context = new GraphicsContext(960, 544, PixelFormat.Rgba, PixelFormat.Depth24, MultiSampleMode.Msaa4x); //建立Context Director.Initialize(sprites_capacity, draw_helpers_capacity, context); //调用基础构造 Director.Instance.GL.Context.SetClearColor(1, 98, 165, 255); Game.Instance = new Game(); //主游戏类 var game = Game.Instance; Sce.Pss.HighLevel.UI.UISystem.Initialize(context); // 初始化UI类 Sce.Pss.HighLevel.UI.UISystem.SetScene(PSVX.Base.GameUI.Instance, null); //开启音乐线程 PSVX.Base.SoundManager soundManager = new PSVX.Base.SoundManager (@"/Application/Content/Sound/", @"/Application/Content/Music/");//修改为你自己的目录 Thread SoundManager = new Thread(new ThreadStart(soundManager.update)); SoundManager.IsBackground = true; //设置为后台线程 SoundManager.Start(); //线程启动 //开启游戏方法 game.Main(); //游戏主方法 while (true) { int start = (int)stopwatch.ElapsedTicks; SystemEvents.CheckEvents(); Director.Instance.GL.SetBlendMode(BlendMode.Normal); Director.Instance.Update(); Director.Instance.Render(); var gamePadData = GamePad.GetData(0); List <TouchData> touchDataList = Touch.GetData(0); //UI类的按键检测 Sce.Pss.HighLevel.UI.UISystem.Update(touchDataList); PSVX.Base.TouchManager.Instance.BaceUpdate(touchDataList); Sce.Pss.HighLevel.UI.UISystem.Render(); Director.Instance.GL.Context.SwapBuffers(); Director.Instance.PostSwap(); cpuTicks += (int)stopwatch.ElapsedTicks - start; if ((++frameCount) % 100 == 0) { float freq = (float)Stopwatch.Frequency; float cpu = (float)cpuTicks * 60.0f / freq; PSVX.Base.DebugScene.Instance.CPUUpdate(cpu); cpuTicks = 0; } } }
static void Main(string[] args) { Init(); while (loop) { SystemEvents.CheckEvents(); Update(); Render(); } Term(); }
public static void Main(string[] args) { Initialize(); while (true) { SystemEvents.CheckEvents(); Update(); Render(); } }
public void MainLoop() { Initialize(); while (true) { SystemEvents.CheckEvents(); Update(); Render(); } }
public static void Main(string[] args) { Initialize(); while (!Quit) { SystemEvents.CheckEvents(); Update(); Render(); } Director.Terminate(); UISystem.Terminate(); }
public static void Main(string[] args) { Initialize(); while (true) // change true condition { SystemEvents.CheckEvents(); Update(); Render(); } // Clean up after exiting game loop }
public override void RunLoop() { while (_loop) { SystemEvents.CheckEvents(); UpdateTouches(); // Update and render the game. if (Game != null) { Game.Tick(); } } }
public OS(bool hasPASS) { /* Graphics Disable due to Xperia Z errors*/ //intro Loading = new intro(); graphics = new GraphicsContext(960, 544, PixelFormat.Rgba, PixelFormat.Depth16, MultiSampleMode.None); UISystem.Initialize(graphics); Terminal scene = new Terminal(); SetupListNum(scene.RootWidget); scene.SetWidgetLayout(LayoutOrientation.Horizontal); UISystem.SetScene(scene); if (!hasPASS) { scene.fresh(); } for (; ;) { SystemEvents.CheckEvents(); // update { List <TouchData> touchDataList = Touch.GetData(0); var gamePad = GamePad.GetData(0); UISystem.Update(touchDataList, ref gamePad); } // draw { graphics.SetViewport(0, 0, graphics.Screen.Width, graphics.Screen.Height); graphics.SetClearColor( 0xFF, 0xFF, 0xFF, 0xff); graphics.Clear(); UISystem.Render(); graphics.SwapBuffers(); if (scene.isHacking) { scene.fakePACKETS(); } if (scene.isFlow) { scene.addCash(); } } } }
//private static MP3Player invincible, level_clear; public static void Main(string[] args) { Initialize(); while (true) { startTime = clock.ElapsedMilliseconds; SystemEvents.CheckEvents(); Update(); Render(); stopTime = clock.ElapsedMilliseconds; timeDelta = stopTime - startTime; } }
public static void Main(string[] args) { Initialize(); while (DoRunGame) { //I plan on useing a timer later. It is here for decorations right now. startTime = clock.ElapsedMilliseconds; SystemEvents.CheckEvents(); Update(); Render(); stopTime = clock.ElapsedMilliseconds; timeDelta = stopTime - startTime; } }
public static void Main(string[] args) { Initialize(); while (true) { startTime = clock.ElapsedMilliseconds; //how much time since clock has started SystemEvents.CheckEvents(); //checks for new events that may be happening like button presses or taps to the screen SystemEvents.CheckEvents(); Update(); Draw(); stopTime = clock.ElapsedMilliseconds; timeDelta = stopTime - startTime; // shows how long it took for my gameloop to run } }
public static void Main(string[] args) { Initialize(); //Main Game Loop while (running == true) { startTime = timer.ElapsedMilliseconds; SystemEvents.CheckEvents(); Update(); Render(); stopTime = timer.ElapsedMilliseconds; timeDelta = stopTime - startTime; } }
public static void Main(string[] args) { Initialize(); stopWatch.Start(); while (loop) { //Thread.Sleep(10); SystemEvents.CheckEvents(); Update(); Render(); } term(); }
public void Run(string[] args) { Initialize(); while (loop) { time[0] = (int)stopwatch.ElapsedTicks; // start SystemEvents.CheckEvents(); Update(); time[1] = (int)stopwatch.ElapsedTicks; Render(); } Terminate(); }
public static void Run() { Game.Instance = new Game(); var game = Game.Instance; game.Initialize(); while (game.Running) { SystemEvents.CheckEvents(); game.Update(); game.Render(); } game.Cleanup(); }
/// 実行メイン public void Run(string[] args) { /// 初期化 init(); while (loop) { /// アプリケーションの状態を更新 SystemEvents.CheckEvents(); /// Fps制御 long currTime = stopwatch.ElapsedMilliseconds; long diffTime = currTime - prevFpsTime; if (diffTime < waitFpsTime && (waitFpsTime - diffTime) < waitFpsTime) { Thread.Sleep((int)(waitFpsTime - diffTime)); } /// FPSを計測 currTime = stopwatch.ElapsedMilliseconds; if ((currTime - prevFpsTime) > 0) { nowMs = (currTime - prevFpsTime); nowFps = 1000.0f / nowMs; } else { nowMs = (currTime - prevFpsTime); nowFps = 0.0f; } prevFpsTime = currTime; // 入力情報更新 inputTouch.Update(); inputGPad.Update(); /// 更新&描画 update(); render(); } /// 破棄 term(); }
public static void Main(string[] args) { Director.Initialize(); Director.Instance.GL.Context.SetClearColor(Colors.Black); Director.Instance.DebugFlags |= DebugFlags.DrawGrid; //UICamera = new Camera2D( Director.Instance.GL, Director.Instance.DrawHelpers ); //UICamera.SetViewFromWidthAndCenter( 16.0f, Math._00 ); UIFontMap = new FontMap(new Font(FontAlias.System, 20, FontStyle.Bold)); LargeFontMap = new FontMap(new Font(FontAlias.System, 48, FontStyle.Bold)); //make a new Game object Game.Instance = new Game(); var game = Game.Instance; Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.RunWithScene(game.Scene, true); System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch(); while (true) { timer.Start(); SystemEvents.CheckEvents(); Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.SetBlendMode(BlendMode.Normal); Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.Update(); Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.Render(); game.FrameUpdate(); timer.Stop(); long ms = timer.ElapsedMilliseconds; //Console.WriteLine("ms: {0}", (int)ms); timer.Reset(); Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.SwapBuffers(); Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.PostSwap(); } }
public void RunWithScene(Scene scene, bool manual_loop = false) { Common.Assert(this.CurrentScene == null); Common.Assert(!this.m_run_with_scene_called, "You can't call RunWithScene more than once."); this.PushScene(scene); this.m_run_with_scene_called = true; if (manual_loop) { return; } while (true) { SystemEvents.CheckEvents(); this.Update(); this.Render(); Director.Instance.GL.Context.SwapBuffers(); this.PostSwap(); } }
/* Correctly Pauses on 'Z' and Exits on 'X' */ public static void Main(string[] args) { Initialize(); while (!exit) { var gamePadData = GamePad.GetData(0); startTime = clock.ElapsedMilliseconds; SystemEvents.CheckEvents(); Update(); Render(); stopTime = clock.ElapsedMilliseconds; deltaTime = stopTime - startTime; gameTime += deltaTime; } }
public static void Main(string[] args) { tcpServer = new LocalTCPConnection(true, 11000); tcpClient = new LocalTCPConnection(false, 11000); tcpServer.Listen(); // tcpClient.Connect(); Init(); while (loop) { SystemEvents.CheckEvents(); Thread.Sleep(100); Update(); Render(); } Term(); }
//private static SpriteUV background; //private static TextureInfo textureInfo; public static void Main(string[] args) { Director.Initialize(); UISystem.Initialize(Director.Instance.GL.Context); stopwatch.Start(); float startSeconds = 0.0f; float endSeconds = 0.016f; float lastSeconds; while (true) { lastSeconds = endSeconds - startSeconds; startSeconds = (float)stopwatch.ElapsedMilliseconds / 1000.0f; SystemEvents.CheckEvents(); SceneManager.Instance.runScene(lastSeconds); endSeconds = (float)stopwatch.ElapsedMilliseconds / 1000.0f; } Director.Terminate(); }
public static void Main(string[] args) { Initialize(); while (loop) { timePassed += (float)(timer.Milliseconds()) - previousTime; previousTime = (float)timer.Milliseconds(); if (timePassed > (1000 / 60)) //60Hz { timePassed = 0; previousTime = 0; timer.Reset(); SystemEvents.CheckEvents(); Update(); Render(); } } Term(); }
public void Update() { //start the timer to measure the frame rendering time timer.Start(); //get the system events(suspend, shut down etc) SystemEvents.CheckEvents(); //set up GL instance Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.SetBlendMode(Sce.PlayStation.HighLevel.GameEngine2D.Base.BlendMode.Normal); //update the Director Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.Update(); //set the additional framebuffer to render to Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.SetFrameBuffer(offscreenBuffer); //set the viewport to the size of the offscreen framebuffer Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.SetViewport(0, 0, 960, 544); //render the scene to the framebuffer Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.CurrentScene.render(); //switch to the default framebuffer again Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.SetFrameBuffer(null); //set the viewport to the size of the device again Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.SetViewport(0, 0, GraphicsContext.ScreenSizes [0].Width, GraphicsContext.ScreenSizes [0].Height); //draw the offscreen framebuffer on the actual screen offscreenSprite.Draw(); //render UI //UISystem.Update(Touch.GetData(0)); //UISystem.Render(); //DEBUG //offscreenSprite.DebugDrawContentLocalBounds(); //stop the timer,calculate the time per frame timer.Stop(); long ms = timer.ElapsedMilliseconds; //sleep to limit the FPS to 30 if (ms < 33) { Thread.Sleep((int)(33 - ms)); ms += (33 - ms); } //calculate the number of FPS and send to console int fps = (int)(1000 / ms); //System.Console.WriteLine ("fps: {0}", fps); //System.Console.WriteLine ("Memory in use in KBytes: " + System.GC.GetTotalMemory (true) / 1024); //if (Game.Instance != null && Game.Instance.ammoList != null) // System.Console.WriteLine ("Number of enemies in the list: {0} ", Game.Instance.bulletList.Count); //reset the timer again timer.Reset(); //swap the buffers and cleanup afterwards Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.SwapBuffers(); Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.PostSwap(); }
public void start() { this.logger.log(this.getName() + " v" + this.getVersion() + " Started."); //Create User Dir try { if (!Directory.Exists(getFilePath())) { Directory.CreateDirectory(getFilePath()); } } catch (Exception e) { } this.getDisplayManager().init(); this.mainThread = Thread.CurrentThread; this.gameThread.Start(); this.gameRunning = true; Scene.setActiveScene(new InitialScene()); while (this.gameRunning) { for (int pd = 0; pd < this.gamePadData.Length; pd++) { try { gamePadData[pd] = GamePad.GetData(pd); } catch (Exception ex) { } } for (int td = 0; td < this.touchData.Length; td++) { try { List <TouchData> tdata = Touch.GetData(td); lock (tdata) { this.touchData[td] = new List <TouchData>(tdata); } } catch (Exception ex) {} } try { SystemEvents.CheckEvents(); } catch (Exception ex) { this.gameRunning = false; this.Dispose(); break; } if (debug) { if (isButtonDown(GamePadButtons.Select)) { this.Dispose(); break; } } getDisplayManager().render(); renderDone = true; } this.Dispose(); }