Exemple #1
0
        public static void RunFrame()
        {
            //Shooting for 30fps
            var startTime = Globals.System.GetTimeMs();

            sMyForm.Update();

            if (sWaterfallTimer < Globals.System.GetTimeMs())
            {
                Globals.WaterfallFrame++;
                if (Globals.WaterfallFrame == 3)
                {
                    Globals.WaterfallFrame = 0;
                }

                sWaterfallTimer = Globals.System.GetTimeMs() + 500;
            }

            if (sAnimationTimer < Globals.System.GetTimeMs())
            {
                Globals.AutotileFrame++;
                if (Globals.AutotileFrame == 3)
                {
                    Globals.AutotileFrame = 0;
                }

                sAnimationTimer = Globals.System.GetTimeMs() + 600;
            }

            DrawFrame();

            GameContentManager.Update();
            Networking.Network.Update();
            Application.DoEvents(); // handle form events

            sFpsCount++;
            if (sFpsTime < Globals.System.GetTimeMs())
            {
                sFps = sFpsCount;
                sMyForm.toolStripLabelFPS.Text = Strings.MainForm.fps.ToString(sFps);
                sFpsCount = 0;
                sFpsTime  = Globals.System.GetTimeMs() + 1000;
            }

            Thread.Sleep(Math.Max(1, (int)(1000 / 60f - (Globals.System.GetTimeMs() - startTime))));
        }