Пример #1
0
        public static void UpdateTiming()
        {
            uint oldTime = App.Timing.Timer;

            App.Timing.Timer = Agk.GetMilliseconds();
            App.Timing.Delta = App.Timing.Timer - oldTime;

            int oldPause = App.Timing.PauseState;

            if (App.Timing.PauseHold == 0)
            {
                App.Timing.PauseState = 0;
            }
            else
            {
                App.Timing.PauseState = 1;
                if (oldPause == 0)
                {
                    App.Timing.PauseMark = App.Timing.Timer;
                }
                else
                {
                    App.Timing.PauseElapsed = (uint)Agk.Abs(App.Timing.Timer - App.Timing.PauseMark);
                }
            }

            if (App.Timing.PauseState == 2)
            {
                //pause ended and elapsed time has been applied, clear down
                App.Timing.PauseState   = 0;
                App.Timing.PauseMark    = 0;
                App.Timing.PauseElapsed = 0;
            }

            if (App.Timing.PauseState == 0 && oldPause == 1)
            {
                //pause ended, resume all updates but keep the elapsed time available for paused updates to adjust against elapsed times.
                App.Timing.PauseState = 2;
                Hardware.Mouse.MoveX  = 0.0f;
                Hardware.Mouse.MoveY  = 0.0f;
                Hardware.Mouse.MoveZ  = 0.0f;
            }
        }
Пример #2
0
        public static bool Init(string[] args, string title)
        {
            App.Status.LoadState = 1;
            App.Status.LoadStage = 1;

            //config defaults
            App.Config.Log.Level    = 3;
            App.Config.Log.File     = System.AppDomain.CurrentDomain.BaseDirectory + "app.log";
            App.Config.Log.Channels = "*";
            //App.Config.Log.Channels = "|!|error|main|ui|";

            App.Config.Screen.Fullscreen = true;
            App.Config.Screen.Width      = 0;
            App.Config.Screen.Height     = 0;
            App.Config.Screen.Vsync      = true;

            //config overrides
            foreach (string arg in args)
            {
                switch (arg.Split('=').First().ToLower())
                {
                case "sw": App.Config.Screen.Width = Convert.ToInt32(arg.Split('=').Last()); break;

                case "sh": App.Config.Screen.Height = Convert.ToInt32(arg.Split('=').Last()); break;

                case "fs": App.Config.Screen.Fullscreen = Convert.ToBoolean(arg.Split('=').Last()); break;

                case "vsync": App.Config.Screen.Vsync = Convert.ToBoolean(arg.Split('=').Last()); break;

                case "log": App.Config.Log.Level = Convert.ToInt32(arg.Split('=').Last()); break;

                default: break;
                }
            }

            //init the screen

            if (App.Config.Screen.Width == 0)
            {
                App.Config.Screen.Width       = System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Width;
                App.Config.Screen.Height      = System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Height;
                App.Config.Screen.AspectRatio = App.Config.Screen.Width / App.Config.Screen.Height;
            }

            App.Config.Screen.CenterX = (int)Math.Floor(App.Config.Screen.Width * 0.5);
            App.Config.Screen.CenterY = (int)Math.Floor(App.Config.Screen.Height * 0.5);

            if (App.Config.Screen.Width > 1280)
            {
                App.Config.Screen.Layout = 1;
            }
            else
            {
                App.Config.Screen.Layout = 2;
            }

            App.CreateWindow(title, App.Config.Screen.Width, App.Config.Screen.Height, App.Config.Screen.Fullscreen);

            if (!App.InitAGK())
            {
                return(false);
            }

            Agk.SetResolutionMode(1);
            Agk.SetOrientationAllowed(0, 0, 1, 0);
            if (!App.Config.Screen.Fullscreen)
            {
                Agk.SetWindowAllowResize(0);
            }
            Agk.SetVirtualResolution(App.Config.Screen.Width, App.Config.Screen.Height);
            Agk.SetScissor(0, 0, 0, 0);

            Agk.SetVSync(App.Config.Screen.Vsync);
            if (!App.Config.Screen.Vsync)
            {
                Agk.SetSyncRate(0, 0);
            }

            //init AGK Misc
            Agk.SetPrintSize(16.0f);
            Agk.SetPrintColor(255, 255, 255);
            Agk.SetClearColor(0, 0, 0);
            Agk.UseNewDefaultFonts(1);

            //init log
            System.IO.File.WriteAllText(App.Config.Log.File, "Timestamp    | File                     | Level | Channel    | Log" + Environment.NewLine);
            System.IO.File.AppendAllText(App.Config.Log.File, "==================================================================" + Environment.NewLine);

            App.Timing.Timer = Agk.GetMilliseconds();

            App.Status.IsRunning = true;
            return(true);
        }