Example #1
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        private static void Main(string[] args)
        {
            Packetizable.AddValueTypeOverloads(typeof(Engine.Math.PacketExtensions));
#if FARMATH
            Packetizable.AddValueTypeOverloads(typeof(Engine.FarMath.PacketExtensions));
#endif
            Packetizable.AddValueTypeOverloads(typeof(XnaExtensions.PacketExtensions));

            using (var game = new TestRunner())
            {
                game.Run();
            }
        }
Example #2
0
        private Program()
        {
            // Some window settings.
            Window.Title   = "Space. The Game. Seriously.";
            IsMouseVisible = true;

            // XNA's fixed time step implementation doesn't suit us, to be gentle.
            // So we let it be dynamic and adjust for it as necessary, leading
            // to almost no desynchronizations at all! Yay!
            IsFixedTimeStep = false;

            // We use this to dispose game components that are disposable and
            // were removed from the list of active components. We don't want
            // to dispose them during an update loop, because they will still
            // be updated if they had not been updated before the removal,
            // leading to object disposed exceptions.
            Components.ComponentRemoved += (sender, e) => _pendingComponents.Add(e.GameComponent);

            // Load settings. Save on exit.
            Settings.Load(SettingsFile);
            Exiting += (sender, e) =>
            {
                Logger.Info("Saving settings.");
                Settings.Save(SettingsFile);
            };

            // Set up display.
            GraphicsDeviceManager = new GraphicsDeviceManager(this)
            {
                PreferredBackBufferWidth  = Settings.Instance.ScreenResolution.X,
                PreferredBackBufferHeight = Settings.Instance.ScreenResolution.Y,
                IsFullScreen = Settings.Instance.Fullscreen,
                SynchronizeWithVerticalRetrace = false,
                PreferMultiSampling            = true
            };

            // Create our own, localized content manager.
            Content = new LocalizedContentManager(Services)
            {
                RootDirectory = "data"
            };

            // Register packet overloads for XNA value types.
            Packetizable.AddValueTypeOverloads(typeof(Engine.Math.PacketExtensions));
            Packetizable.AddValueTypeOverloads(typeof(Engine.FarMath.PacketExtensions));
            Packetizable.AddValueTypeOverloads(typeof(Engine.XnaExtensions.PacketExtensions));
        }