Example #1
0
 /// <summary>
 /// Force the creation of a Debugger object (even in Release mode!)
 /// </summary>
 public void ForceDebugger()
 {
     if (Debugger != null)
     {
         return;
     }
     ReleaseModeDebugger = true;
     Debugger            = new Utility.Debugger(this);
     Debugger.WindowInit();
 }
Example #2
0
 void Init()
 {
     if (ReleaseModeDebugger)
     {
         if (Debugger == null)
         {
             Debugger = new Utility.Debugger(this);
             Debugger.WindowInit();
         }
     }
     if (FirstScene != null)
     {
         SwitchScene(FirstScene);
     }
     OnInit();
 }
Example #3
0
        /// <summary>
        /// Creates a new game to run in the program.
        /// </summary>
        /// <param name="title">The title of the window.</param>
        /// <param name="width">The width of the internal game resolution.</param>
        /// <param name="height">The height of the internal game resolution.</param>
        /// <param name="targetFramerate">The target framerate (for fixed framerate.)</param>
        /// <param name="fullscreen">Run the game in fullscreen.</param>
        public Game(string title = "Game", int width = 640, int height = 480, int targetFramerate = 60, bool fullscreen = false)
        {
            Sessions = new List <Session>();
            Scenes   = new Stack <Scene>();
            Surfaces = new List <Surface>();

            SaveData              = new DataSaver(Filepath);
            OptionsData           = new DataSaver(Filepath);
            ConfigData            = new DataSaver(Filepath);
            ConfigData.ExportMode = DataSaver.DataExportMode.Config;
            GameFolder            = "ottergame";

            QuitButton.AddKey(Key.Escape);

            cameraZoom       = 1;
            cameraAngle      = 0;
            Width            = width;
            Height           = height;
            this.title       = title;
            WindowWidth      = width;
            WindowHeight     = height;
            WindowFullscreen = fullscreen;

            ShowDebugger = false;

            TargetFramerate = (int)Util.Clamp(targetFramerate, 999);

            Surface = new Surface(width, height);
            Surface.CenterOrigin();
            Surface.Game = this;

            AspectRatio = width / (float)height;

            Draw.Target     = Surface;
            Draw.GameTarget = Surface;

            Input      = new Input(this);
            DebugInput = new DebugInput(this);
            Coroutine  = new Coroutine(this);
            Tweener    = new Tweener();

            for (int i = 0; i < fpsLogSize; i++)
            {
                fpsTimes.Add(targetFramerate);
            }

            frameTime = 1000f / TargetFramerate;
            skipTime  = frameTime * 2;

#if DEBUG
            try
            {
                Console.Title = string.Format("{0} Debug Console ᶜ(ᵔᴥᵔ)ᵓ", title);
            }
            catch
            {
                // No console
            }
            Console.WriteLine("[ Otter is running in debug mode! ]");
            Debugger = new Utility.Debugger(this);
#endif

            HasFocus = true;

            Instance = this;
        }