/// <summary> /// Create a new Session. /// </summary> /// <param name="game">The Game that the session is tied to.</param> public Session(Game game, string name) { Game = game; Name = name; var folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/" + Game.GameFolder; var path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/" + Game.GameFolder + "/" + Name + "."; if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } Data = new DataSaver(path); Id = nextSessionId; nextSessionId++; }
/// <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) { #if Unix XInitThreads(); #endif 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 Debugger(this); #endif HasFocus = true; Instance = this; }